diff options
-rw-r--r-- | protocols/jabber/iq.c | 22 | ||||
-rw-r--r-- | protocols/jabber/jabber_util.c | 6 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 2 | ||||
-rw-r--r-- | protocols/msn/ns.c | 26 | ||||
-rw-r--r-- | protocols/nogaim.c | 42 | ||||
-rw-r--r-- | protocols/nogaim.h | 7 | ||||
-rw-r--r-- | protocols/oscar/oscar.c | 24 | ||||
-rw-r--r-- | protocols/yahoo/libyahoo2.c | 19 | ||||
-rw-r--r-- | protocols/yahoo/yahoo.c | 7 | ||||
-rw-r--r-- | root_commands.c | 12 |
10 files changed, 91 insertions, 76 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 46ae9a64..2aa9d432 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -359,28 +359,20 @@ static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node * c = query->children; while( ( c = xt_find_node( c, "item" ) ) ) { + struct xt_node *group = xt_find_node( node->children, "group" ); char *jid = xt_find_attr( c, "jid" ); char *name = xt_find_attr( c, "name" ); char *sub = xt_find_attr( c, "subscription" ); - if( !jid || !sub ) - { - /* Maybe warn. But how likely is this to happen in the first place? */ - } - else if( initial ) + if( jid && sub ) { if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) - add_buddy( ic, NULL, jid, name ); - } - else - { - /* This is a roster push item. Find out what changed exactly. */ - if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) { - if( find_buddy( ic, jid ) == NULL ) - add_buddy( ic, NULL, jid, name ); - else if( name ) - serv_buddy_rename( ic, jid, name ); + if( initial || imcb_find_buddy( ic, jid ) == NULL ) + imcb_add_buddy( ic, jid, ( group && group->text_len ) ? + group->text : NULL ); + + imcb_rename_buddy( ic, jid, name ); } else if( strcmp( sub, "remove" ) == 0 ) { diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 949a7a4b..3c0e71f4 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -222,7 +222,7 @@ static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla { presence_send_request( bla->ic, bla->handle, "subscribed" ); - if( find_buddy( bla->ic, bla->handle ) == NULL ) + if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) imcb_ask_add( bla->ic, bla->handle, NULL ); g_free( bla->handle ); @@ -370,7 +370,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, } } - if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid ) ) + if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid ) ) { *s = '/'; bud = jabber_buddy_add( ic, jid ); @@ -390,7 +390,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, if( bud == NULL ) /* No match. Create it now? */ - return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid_ ) ) ? + return ( ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid_ ) ) ? jabber_buddy_add( ic, jid_ ) : NULL; else if( bud->resource && ( flags & GET_BUDDY_EXACT ) ) /* We want an exact match, so in thise case there shouldn't be a /resource. */ diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 80f351a2..c9eb5ee2 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -93,7 +93,7 @@ static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) { msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); - if( find_buddy( bla->ic, bla->handle ) == NULL ) + if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) imcb_ask_add( bla->ic, bla->handle, NULL ); g_free( bla->handle ); diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index c80fc177..9bd7f152 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -304,10 +304,11 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) char *group = NULL; int num; - if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 ) + if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 && num < md->groupcount ) group = md->grouplist[num]; - add_buddy( ic, group, cmd[1], cmd[2] ); + imcb_add_buddy( ic, cmd[1], group ); + imcb_rename_buddy( ic, cmd[1], cmd[2] ); } if( list & 2 ) /* AL */ { @@ -390,7 +391,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } http_decode( cmd[4] ); - serv_buddy_rename( ic, cmd[3], cmd[4] ); + imcb_rename_buddy( ic, cmd[3], cmd[4] ); st = msn_away_state_by_code( cmd[2] ); if( !st ) @@ -419,7 +420,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } http_decode( cmd[3] ); - serv_buddy_rename( ic, cmd[2], cmd[3] ); + imcb_rename_buddy( ic, cmd[2], cmd[3] ); st = msn_away_state_by_code( cmd[1] ); if( !st ) @@ -481,20 +482,27 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); - return( 0 ); + return 0; } - /* We got added by someone. If we don't have this person in permit/deny yet, inform the user. */ + /* We got added by someone. If we don't have this + person in permit/deny yet, inform the user. */ for( l = ic->permit; l; l = l->next ) if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return( 1 ); + return 1; for( l = ic->deny; l; l = l->next ) if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return( 1 ); + return 1; msn_buddy_ask( ic, cmd[4], cmd[5] ); } + else if( num_parts >= 6 && strcmp( cmd[2], "FL" ) == 0 ) + { + http_decode( cmd[5] ); + imcb_add_buddy( ic, cmd[4], NULL ); + imcb_rename_buddy( ic, cmd[4], cmd[5] ); + } } else if( strcmp( cmd[0], "OUT" ) == 0 ) { @@ -544,7 +552,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { /* This is not supposed to happen, but let's handle it anyway... */ http_decode( cmd[4] ); - serv_buddy_rename( ic, cmd[3], cmd[4] ); + imcb_rename_buddy( ic, cmd[3], cmd[4] ); } } else if( strcmp( cmd[0], "IPG" ) == 0 ) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2a452e57..02a1bf71 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -351,16 +351,12 @@ void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void /* list.c */ -void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ) +void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ) { user_t *u; - char nick[MAX_NICK_LENGTH+1]; - char *s; + char nick[MAX_NICK_LENGTH+1], *s; irc_t *irc = ic->irc; - if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ - imcb_log( ic, "Receiving user add from handle: %s", handle ); - if( user_findhandle( ic, handle ) ) { if( set_getbool( &irc->set, "debug" ) ) @@ -368,16 +364,19 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn return; - /* Buddy seems to exist already. Let's ignore this request then... */ + /* Buddy seems to exist already. Let's ignore this request then... + Eventually subsequent calls to this function *should* be possible + when a buddy is in multiple groups. But for now BitlBee doesn't + even support groups so let's silently ignore this for now. */ } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( ic->acc, handle, realname ) ); + strcpy( nick, nick_get( ic->acc, handle, NULL ) ); u = user_add( ic->irc, nick ); - if( !realname || !*realname ) realname = nick; - u->realname = g_strdup( realname ); +// if( !realname || !*realname ) realname = nick; +// u->realname = g_strdup( realname ); if( ( s = strchr( handle, '@' ) ) ) { @@ -386,14 +385,7 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn } else if( ic->acc->server ) { - char *colon; - - if( ( colon = strchr( ic->acc->server, ':' ) ) ) - u->host = g_strndup( ic->acc->server, - colon - ic->acc->server ); - else - u->host = g_strdup( ic->acc->server ); - + u->host = g_strdup( ic->acc->server ); u->user = g_strdup( handle ); /* s/ /_/ ... important for AOL screennames */ @@ -414,7 +406,7 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn u->last_typing_notice = 0; } -struct buddy *find_buddy( struct im_connection *ic, char *handle ) +struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) { static struct buddy b[1]; user_t *u; @@ -434,11 +426,11 @@ struct buddy *find_buddy( struct im_connection *ic, char *handle ) } -void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) +void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); - if( !u ) return; + if( !u || !realname ) return; if( g_strcasecmp( u->realname, realname ) != 0 ) { @@ -469,7 +461,7 @@ void show_got_added_no( gpointer w, struct show_got_added_data *data ) void show_got_added_yes( gpointer w, struct show_got_added_data *data ) { data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); - add_buddy( data->ic, NULL, data->handle, data->handle ); + /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */ return show_got_added_no( w, data ); } @@ -504,7 +496,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, { if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) { - add_buddy( ic, NULL, (char*) handle, NULL ); + imcb_add_buddy( ic, (char*) handle, NULL ); u = user_findhandle( ic, (char*) handle ); } else @@ -608,7 +600,7 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ private = 0; } - add_buddy( ic, NULL, handle, NULL ); + imcb_add_buddy( ic, handle, NULL ); u = user_findhandle( ic, handle ); u->is_private = private; } @@ -778,7 +770,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) your contact list. Try to handle that here */ if( !u ) { - add_buddy( b->ic, NULL, handle, NULL ); + imcb_add_buddy( b->ic, handle, NULL ); u = user_findhandle( b->ic, handle ); } diff --git a/protocols/nogaim.h b/protocols/nogaim.h index e249ae0e..e17c9523 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -200,9 +200,10 @@ G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c ); struct groupchat *chat_by_channel( char *channel ); /* Buddy management */ -G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ); -G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle ); -G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ); +G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ); +G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ); +G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ); +G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ); /* Buddy activity */ G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 407aba7f..7e5dbee0 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1118,7 +1118,7 @@ static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) { message = 0; aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); - if(find_buddy(data->ic, uin) == NULL) + if(imcb_find_buddy(data->ic, uin) == NULL) imcb_ask_add(data->ic, uin, NULL); g_free(uin); @@ -1874,7 +1874,7 @@ static void oscar_get_info(struct im_connection *g, char *name) { static void oscar_get_away(struct im_connection *g, char *who) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; if (odata->icq) { - struct buddy *budlight = find_buddy(g, who); + struct buddy *budlight = imcb_find_buddy(g, who); if (budlight) if ((budlight->uc & 0xff80) >> 7) if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) @@ -2012,16 +2012,18 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { for (curitem=sess->ssi.items; curitem; curitem=curitem->next) { switch (curitem->type) { case 0x0000: /* Buddy */ - if ((curitem->name) && (!find_buddy(ic, curitem->name))) { + if ((curitem->name) && (!imcb_find_buddy(ic, curitem->name))) { char *realname = NULL; if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) realname = aim_gettlv_str(curitem->data, 0x0131, 1); - add_buddy(ic, NULL, curitem->name, realname); + imcb_add_buddy(ic, curitem->name, NULL); - if (realname) - g_free(realname); + if (realname) { + imcb_rename_buddy(ic, curitem->name, realname); + g_free(realname); + } } break; @@ -2104,13 +2106,21 @@ static int gaim_ssi_parseack( aim_session_t *sess, aim_frame_t *fr, ... ) for( i = 0; i < count; i ++ ) { st = aimbs_get16( &fr->data ); - if( st == 0x0E ) + if( st == 0x00 ) + { + imcb_add_buddy( sess->aux_data, list, NULL ); + } + else if( st == 0x0E ) { imcb_log( sess->aux_data, "Buddy %s can't be added without authorization, requesting authorization", list ); aim_ssi_auth_request( sess, fr->conn, list, "" ); aim_ssi_addbuddies( sess, fr->conn, OSCAR_GROUP, &list, 1, 1 ); } + else + { + imcb_error( sess->aux_data, "Error while adding buddy: 0x%04x", st ); + } list += strlen( list ) + 1; } } diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 38041ad4..5beae687 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -2402,12 +2402,19 @@ static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_pa if(!where) where = "Unknown"; - bud = y_new0(struct yahoo_buddy, 1); - bud->id = strdup(who); - bud->group = strdup(where); - bud->real_name = NULL; - - yd->buddies = y_list_append(yd->buddies, bud); + /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */ + if( status == 0 ) { + bud = y_new0(struct yahoo_buddy, 1); + bud->id = strdup(who); + bud->group = strdup(where); + bud->real_name = NULL; + + yd->buddies = y_list_append(yd->buddies, bud); + + /* Possibly called already, but at least the call above doesn't + seem to happen every time (not anytime I tried). */ + YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, me, who, NULL); + } /* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ } diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 191a197c..c3d57a94 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -531,7 +531,9 @@ void ext_yahoo_got_buddies( int id, YList *buds ) yd->buddygroups = g_slist_append( yd->buddygroups, bg ); } - add_buddy( ic, b->group, b->id, b->real_name ); + imcb_add_buddy( ic, b->id, b->group ); + imcb_rename_buddy( ic, b->id, b->real_name ); + bl = bl->next; } } @@ -903,6 +905,9 @@ void ext_yahoo_chat_yahooerror( int id, const char *me ) void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) { + /* Groups schmoups. If I want to handle groups properly I can get the + buddy data from some internal libyahoo2 structure. */ + imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL ); } void ext_yahoo_rejected( int id, const char *who, const char *msg ) diff --git a/root_commands.c b/root_commands.c index acbf579f..a7582936 100644 --- a/root_commands.c +++ b/root_commands.c @@ -436,11 +436,11 @@ static void cmd_account( irc_t *irc, char **cmd ) static void cmd_add( irc_t *irc, char **cmd ) { account_t *a; - int add_for_real = 1; + int add_on_server = 1; if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) { - add_for_real = 0; + add_on_server = 0; cmd ++; /* So evil... :-D */ } @@ -475,12 +475,12 @@ static void cmd_add( irc_t *irc, char **cmd ) /* By making this optional, you can talk to people without having to add them to your *real* (server-side) contact list. */ - if( add_for_real ) + if( add_on_server ) a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); - - add_buddy( a->ic, NULL, cmd[2], cmd[2] ); - irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->ic, cmd[2] )->nick ); + /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */ + + irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); } static void cmd_info( irc_t *irc, char **cmd ) |