From bad41f567bd8b8e04d092e8e6771fee74b205032 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Aug 2010 00:42:11 +0100 Subject: libpurple: Fix typing notifications (in and out). Closes #671. --- protocols/bee_user.c | 2 +- protocols/nogaim.h | 2 +- protocols/purple/purple.c | 50 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 13 deletions(-) (limited to 'protocols') diff --git a/protocols/bee_user.c b/protocols/bee_user.c index 5acd5b83..db7842a0 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -240,7 +240,7 @@ void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, ui imcb_log( ic, "Message from unknown handle %s:\n%s", handle, msg ); } -void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) +void imcb_buddy_typing( struct im_connection *ic, const char *handle, uint32_t flags ) { bee_user_t *bu; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index be67bb24..3407236f 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -309,7 +309,7 @@ G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *h G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname ); G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick ); -G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ); +G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, const char *handle, uint32_t flags ); G_MODULE_EXPORT struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle ); G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle ); diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index c7cfcfda..5522c0fc 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -426,23 +426,16 @@ static void purple_keepalive( struct im_connection *ic ) static int purple_send_typing( struct im_connection *ic, char *who, int flags ) { PurpleTypingState state = PURPLE_NOT_TYPING; - PurpleConversation *conv; + PurpleAccount *pa = ic->proto_data; if( flags & OPT_TYPING ) state = PURPLE_TYPING; else if( flags & OPT_THINKING ) state = PURPLE_TYPED; - if( ( conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_IM, - who, ic->proto_data ) ) == NULL ) - { - purple_conv_im_set_typing_state( purple_conversation_get_im_data( conv ), state ); - return 1; - } - else - { - return 0; - } + serv_send_typing( purple_account_get_connection( pa ), who, state ); + + return 1; } static void purple_chat_msg( struct groupchat *gc, char *message, int flags ) @@ -808,6 +801,32 @@ static void prplcb_conv_im( PurpleConversation *conv, const char *who, const cha imcb_buddy_msg( ic, (char*) who, (char*) message, 0, mtime ); } +/* No, this is not a ui_op but a signal. */ +static void prplcb_buddy_typing( PurpleAccount *account, const char *who, gpointer null ) +{ + PurpleConversation *conv; + PurpleConvIm *im; + int state; + + if( ( conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_IM, who, account ) ) == NULL ) + return; + + im = PURPLE_CONV_IM(conv); + switch( purple_conv_im_get_typing_state( im ) ) + { + case PURPLE_TYPING: + state = OPT_TYPING; + break; + case PURPLE_TYPED: + state = OPT_THINKING; + break; + default: + state = 0; + } + + imcb_buddy_typing( purple_ic_by_pa( account ), who, state ); +} + static PurpleConversationUiOps bee_conv_uiops = { prplcb_conv_new, /* create_conversation */ @@ -1138,6 +1157,15 @@ void purple_initmodule() /* Meh? */ purple_prefs_load(); + /* No, really. So far there were ui_ops for everything, but now suddenly + one needs to use signals for typing notification stuff. :-( */ + purple_signal_connect( purple_conversations_get_handle(), "buddy-typing", + &funcs, PURPLE_CALLBACK(prplcb_buddy_typing), NULL ); + purple_signal_connect( purple_conversations_get_handle(), "buddy-typed", + &funcs, PURPLE_CALLBACK(prplcb_buddy_typing), NULL ); + purple_signal_connect( purple_conversations_get_handle(), "buddy-typing-stopped", + &funcs, PURPLE_CALLBACK(prplcb_buddy_typing), NULL ); + memset( &funcs, 0, sizeof( funcs ) ); funcs.login = purple_login; funcs.init = purple_init; -- cgit v1.2.3 From 0ebf919dd8b47e50ce060f46f2dc5f10f3867207 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Aug 2010 23:25:37 +0100 Subject: Pass "user is mobile" info coming from OSCAR up to BitlBee and show mobile people as away=Mobile. Bug #462 (and others for other protocols). --- protocols/bee.c | 1 + protocols/bee.h | 2 ++ protocols/bee_user.c | 7 +++++++ protocols/nogaim.h | 1 + protocols/oscar/oscar.c | 4 ++++ 5 files changed, 15 insertions(+) (limited to 'protocols') diff --git a/protocols/bee.c b/protocols/bee.c index c5eeee17..81cb7619 100644 --- a/protocols/bee.c +++ b/protocols/bee.c @@ -39,6 +39,7 @@ bee_t *bee_new() s = set_add( &b->set, "auto_reconnect", "true", set_eval_bool, b ); s = set_add( &b->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, b ); s = set_add( &b->set, "debug", "false", set_eval_bool, b ); + s = set_add( &b->set, "mobile_is_away", "false", set_eval_bool, b ); s = set_add( &b->set, "save_on_quit", "true", set_eval_bool, b ); s = set_add( &b->set, "status", NULL, set_eval_away_status, b ); s->flags |= SET_NULL_OK; diff --git a/protocols/bee.h b/protocols/bee.h index 5792e988..2fd3562e 100644 --- a/protocols/bee.h +++ b/protocols/bee.h @@ -55,10 +55,12 @@ typedef struct bee bee_t *bee_new(); void bee_free( bee_t *b ); +/* TODO(wilmer): Kill at least the OPT_ flags that have an equivalent here. */ typedef enum { BEE_USER_ONLINE = 1, /* Compatibility with old OPT_LOGGED_IN flag */ BEE_USER_AWAY = 4, /* Compatibility with old OPT_AWAY flag */ + BEE_USER_MOBILE = 8, /* Compatibility with old OPT_MOBILE flag */ BEE_USER_LOCAL = 256, /* Locally-added contacts (not in real contact list) */ } bee_user_flags_t; diff --git a/protocols/bee_user.c b/protocols/bee_user.c index db7842a0..04253c47 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -189,6 +189,13 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, bu->status = g_strdup( ( flags & OPT_AWAY ) && state == NULL ? "Away" : state ); bu->status_msg = g_strdup( message ); + if( bu->status == NULL && ( flags & OPT_MOBILE ) && + set_getbool( &bee->set, "mobile_is_away" ) ) + { + bu->flags |= BEE_USER_AWAY; + bu->status = g_strdup( "Mobile" ); + } + if( bee->ui->user_status ) bee->ui->user_status( bee, bu, old ); diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 3407236f..693b5d16 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -62,6 +62,7 @@ #define OPT_LOGGED_IN 0x00000001 #define OPT_LOGGING_OUT 0x00000002 #define OPT_AWAY 0x00000004 +#define OPT_MOBILE 0x00000008 #define OPT_DOES_HTML 0x00000010 #define OPT_LOCALBUDDY 0x00000020 /* For nicks local to one groupchat */ #define OPT_TYPING 0x00000100 /* Some pieces of code make assumptions */ diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 3f5272cd..db6a28f4 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -898,6 +898,10 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { flags |= OPT_AWAY; } + /* Maybe this should be done just for AIM contacts, not sure. */ + if (info->flags & AIM_FLAG_WIRELESS) + flags |= OPT_MOBILE; + if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { -- cgit v1.2.3 From c00dd7117be2a5fda92d6f7d72b0e4e54fa5d615 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Aug 2010 23:39:22 +0100 Subject: Pick up away info from Yahoo! too. --- protocols/yahoo/yahoo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'protocols') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 9f7a7896..7708ed63 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -588,6 +588,8 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms if( away ) flags |= OPT_AWAY; + if( mobile ) + flags |= OPT_MOBILE; switch (stat) { -- cgit v1.2.3