Mercurial > pidgin
diff libpurple/protocols/mxit/roster.c @ 29331:ecc6217baa1e
struct hiding updates for mxit
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Fri, 11 Dec 2009 00:44:42 +0000 |
parents | 259bbfb423d4 |
children | 085020c013eb |
line wrap: on
line diff
--- a/libpurple/protocols/mxit/roster.c Fri Dec 11 00:21:45 2009 +0000 +++ b/libpurple/protocols/mxit/roster.c Fri Dec 11 00:44:42 2009 +0000 @@ -318,7 +318,7 @@ /* create new buddy */ buddy = purple_buddy_new( session->acc, contact->username, contact->alias ); - buddy->proto_data = contact; + purple_buddy_set_protocol_data(buddy, contact); /* add new buddy to list */ purple_blist_add_buddy( buddy, NULL, group, NULL ); @@ -326,13 +326,15 @@ else { /* buddy was found in the group */ + gpointer data = NULL; + /* now update the buddy's alias */ purple_blist_alias_buddy( buddy, contact->alias ); /* replace the buddy's contact struct */ - if ( buddy->proto_data ) - free( buddy->proto_data ); - buddy->proto_data = contact; + if ( ( data = purple_buddy_get_protocol_data( buddy ) ) ) + free( data ); + purple_buddy_set_protocol_data( buddy, contact ); } /* load buddy's avatar id */ @@ -379,7 +381,7 @@ return; } - contact = buddy->proto_data; + contact = purple_buddy_get_protocol_data( buddy ); if ( !contact ) return; @@ -439,9 +441,12 @@ for ( i = 0; i < g_slist_length( list ); i++ ) { buddy = g_slist_nth_data( list, i ); - if ( !buddy->proto_data ) { + if ( !purple_buddy_get_protocol_data( buddy ) ) { + const gchar *alias = purple_buddy_get_alias( buddy ); + const gchar *name = purple_buddy_get_name( buddy ); + /* this buddy should be removed, because we did not receive him in our roster update from MXit */ - purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", buddy->alias, buddy->name ); + purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name ); purple_blist_remove_buddy( buddy ); } } @@ -535,7 +540,7 @@ return FALSE; } - contact = buddy->proto_data; + contact = purple_buddy_get_protocol_data( buddy ); if ( !contact ) return FALSE; @@ -560,10 +565,13 @@ GSList* list = NULL; PurpleBuddy* mxbuddy = NULL; unsigned int i; + const gchar * buddy_name = purple_buddy_get_name( buddy ); + const gchar * buddy_alias = purple_buddy_get_alias( buddy ); + const gchar * group_name = purple_group_get_name( group ); - purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy '%s' (group='%s')\n", buddy->name, group->name ); + purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy '%s' (group='%s')\n", buddy_name, group_name ); - list = purple_find_buddies( session->acc, buddy->name ); + list = purple_find_buddies( session->acc, buddy_name ); if ( g_slist_length( list ) == 1 ) { purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 1) (list:%i)\n", g_slist_length( list ) ); /* @@ -572,7 +580,7 @@ * you accept an invite. so in that case the user is already * in our blist and ready to be chatted to. */ - mxit_send_invite( session, buddy->name, buddy->alias, group->name ); + mxit_send_invite( session, buddy_name, buddy_alias, group_name ); } else { purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 2) (list:%i)\n", g_slist_length( list ) ); @@ -585,17 +593,17 @@ for ( i = 0; i < g_slist_length( list ); i++ ) { mxbuddy = g_slist_nth_data( list, i ); - if ( mxbuddy->proto_data != NULL ) { + if ( purple_buddy_get_protocol_data( mxbuddy ) != NULL ) { /* this is our REAL MXit buddy! */ /* now update the buddy's alias */ - purple_blist_alias_buddy( mxbuddy, buddy->alias ); + purple_blist_alias_buddy( mxbuddy, buddy_alias ); /* now update the buddy's group */ // mxbuddy = mxit_update_buddy_group( session, mxbuddy, group ); /* send the update to the MXit server */ - mxit_send_update_contact( session, mxbuddy->name, mxbuddy->alias, group->name ); + mxit_send_update_contact( session, purple_buddy_get_name( mxbuddy ), purple_buddy_get_alias( mxbuddy ), group_name ); } } } @@ -623,10 +631,11 @@ void mxit_remove_buddy( PurpleConnection* gc, PurpleBuddy* buddy, PurpleGroup* group ) { struct MXitSession* session = (struct MXitSession*) gc->proto_data; + const gchar * buddy_name = purple_buddy_get_name( buddy ); - purple_debug_info( MXIT_PLUGIN_ID, "mxit_remove_buddy '%s'\n", buddy->name ); + purple_debug_info( MXIT_PLUGIN_ID, "mxit_remove_buddy '%s'\n", buddy_name ); - mxit_send_remove( session, buddy->name ); + mxit_send_remove( session, buddy_name ); } @@ -659,7 +668,7 @@ return; } - mxit_send_update_contact( session, who, alias, group->name ); + mxit_send_update_contact( session, who, alias, purple_group_get_name( group ) ); } @@ -685,7 +694,7 @@ return; } - mxit_send_update_contact( session, who, buddy->alias, new_group ); + mxit_send_update_contact( session, who, purple_buddy_get_alias( buddy ), new_group ); } @@ -704,7 +713,7 @@ PurpleBuddy* buddy = NULL; GList* item = NULL; - purple_debug_info( MXIT_PLUGIN_ID, "mxit_rename_group from '%s' to '%s\n", old_name, group->name ); + purple_debug_info( MXIT_PLUGIN_ID, "mxit_rename_group from '%s' to '%s\n", old_name, purple_group_get_name( group ) ); // TODO: Might be more efficient to use the "rename group" command (cmd=29). @@ -712,7 +721,7 @@ item = moved_buddies; while ( item ) { buddy = item->data; - mxit_send_update_contact( session, buddy->name, buddy->alias, group->name ); + mxit_send_update_contact( session, purple_buddy_get_name( buddy ), purple_buddy_get_alias( buddy ), purple_group_get_name( group ) ); item = g_list_next( item ); } }