pidgin.next.minor: 9a1d56a4: struct hiding updates for mxit

grim at pidgin.im grim at pidgin.im
Thu Dec 10 20:00:40 EST 2009


-----------------------------------------------------------------
Revision: 9a1d56a43f84cdccdbad14d5ab9b89f436d82714
Ancestor: f951fda387f4773e8984afdcb826cb40b99191b5
Author: grim at pidgin.im
Date: 2009-12-11T00:44:42
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/9a1d56a43f84cdccdbad14d5ab9b89f436d82714

Modified files:
        libpurple/protocols/mxit/mxit.c
        libpurple/protocols/mxit/profile.c
        libpurple/protocols/mxit/roster.c

ChangeLog: 

struct hiding updates for mxit


-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/mxit.c	b8a2aadcdb394ae3c1616ef07ddeba1e7aedbc64
+++ libpurple/protocols/mxit/mxit.c	a7a941573ecfc0bc7f7fb21dbdd3868c8ecd8210
@@ -188,15 +188,18 @@ static void mxit_cb_chat_created( Purple
 
 	/* find the buddy object */
 	buddy = purple_find_buddy( session->acc, who );
-	if ( ( !buddy ) || ( !buddy->proto_data ) )
+	if ( !buddy )
 		return;
 
+	contact = purple_buddy_get_protocol_data(buddy);
+	if ( !contact )
+		return;
+
 	/* we ignore all conversations with which we have chatted with in this session */
 	if ( find_active_chat( session->active_chats, who ) )
 		return;
 
 	/* determite if this buddy is a MXit service */
-	contact = buddy->proto_data;
 	switch ( contact->type ) {
 		case MXIT_TYPE_BOT :
 		case MXIT_TYPE_CHATROOM :
@@ -258,7 +261,7 @@ static const char* mxit_list_emblem( Pur
  */
 static const char* mxit_list_emblem( PurpleBuddy* buddy )
 {
-	struct contact*	contact = buddy->proto_data;
+	struct contact*	contact = purple_buddy_get_protocol_data(buddy);
 
 	if ( !contact )
 		return NULL;
@@ -295,7 +298,7 @@ char* mxit_status_text( PurpleBuddy* bud
  */
 char* mxit_status_text( PurpleBuddy* buddy )
 {
-	struct contact*	contact = buddy->proto_data;
+	struct contact*	contact = purple_buddy_get_protocol_data(buddy);
 
 	if ( !contact )
 		return NULL;
@@ -320,7 +323,7 @@ static void mxit_tooltip( PurpleBuddy* b
  */
 static void mxit_tooltip( PurpleBuddy* buddy, PurpleNotifyUserInfo* info, gboolean full )
 {
-	struct contact*	contact = buddy->proto_data;
+	struct contact*	contact = purple_buddy_get_protocol_data(buddy);
 
 	if ( !contact )
 		return;
@@ -455,7 +458,7 @@ static void mxit_free_buddy( PurpleBuddy
 
 	purple_debug_info( MXIT_PLUGIN_ID, "mxit_free_buddy\n" );
 
-	contact = buddy->proto_data;
+	contact = purple_buddy_get_protocol_data(buddy);
 	if ( contact ) {
 		if ( contact->statusMsg )
 			g_free( contact->statusMsg );
@@ -463,7 +466,8 @@ static void mxit_free_buddy( PurpleBuddy
 			g_free( contact->avatarId );
 		g_free( contact );
 	}
-	buddy->proto_data = NULL;
+
+	purple_buddy_set_protocol_data(buddy, NULL);
 }
 
 
============================================================
--- libpurple/protocols/mxit/profile.c	bff65d9cb9f81b6f352b785a047810311a5960b0
+++ libpurple/protocols/mxit/profile.c	7d483ca8919ab3c3cfa252bd761c40ead462f736
@@ -115,9 +115,9 @@ void mxit_show_profile( struct MXitSessi
 
 	buddy = purple_find_buddy( session->acc, username );
 	if ( buddy ) {
-		purple_notify_user_info_add_pair( info, _( "Alias" ), buddy->alias );
+		purple_notify_user_info_add_pair( info, _( "Alias" ), purple_buddy_get_alias( buddy ) );
 		purple_notify_user_info_add_section_break( info );
-		contact = buddy->proto_data;
+		contact = purple_buddy_get_protocol_data(buddy);
 	}
 
 	purple_notify_user_info_add_pair( info, _( "Nick Name" ), profile->nickname );
============================================================
--- libpurple/protocols/mxit/roster.c	ec97361cac5d5caa5406dfe0693f938bfc260619
+++ libpurple/protocols/mxit/roster.c	8c795ffe438cf7c334304f92aa58ce668a0fe379
@@ -318,7 +318,7 @@ void mxit_update_contact( struct MXitSes
 
 		/* 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 @@ void mxit_update_contact( struct MXitSes
 	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 @@ void mxit_update_buddy_presence( struct 
 		return;
 	}
 
-	contact = buddy->proto_data;
+	contact = purple_buddy_get_protocol_data( buddy );
 	if ( !contact )
 		return;
 
@@ -439,9 +441,12 @@ void mxit_update_blist( struct MXitSessi
 	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 @@ gboolean is_mxit_chatroom_contact( struc
 		return FALSE;
 	}
 
-	contact = buddy->proto_data;
+	contact = purple_buddy_get_protocol_data( buddy );
 	if ( !contact )
 		return FALSE;
 
@@ -560,10 +565,13 @@ void mxit_add_buddy( PurpleConnection* g
 	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 @@ void mxit_add_buddy( PurpleConnection* g
 		 * 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 @@ void mxit_add_buddy( PurpleConnection* g
 		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
 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 @@ void mxit_buddy_alias( PurpleConnection*
 		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 @@ void mxit_buddy_group( PurpleConnection*
 		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 @@ void mxit_rename_group( PurpleConnection
 	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 @@ void mxit_rename_group( PurpleConnection
 	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 );
 	}
 }


More information about the Commits mailing list