pidgin: eda397a1: Convert bonjour prpl to use accessor fun...

andrew.victor at mxit.com andrew.victor at mxit.com
Mon Aug 29 18:51:00 EDT 2011


----------------------------------------------------------------------
Revision: eda397a1bd6df17413728a2b9faf13283d706bbf
Parent:   0de22eda160f79c40e05273d6c9a35170a251441
Author:   andrew.victor at mxit.com
Date:     08/29/11 17:32:30
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/eda397a1bd6df17413728a2b9faf13283d706bbf

Changelog: 

Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().


Changes against parent 0de22eda160f79c40e05273d6c9a35170a251441

  patched  libpurple/protocols/bonjour/bonjour.c
  patched  libpurple/protocols/bonjour/bonjour_ft.c
  patched  libpurple/protocols/bonjour/jabber.c
  patched  libpurple/protocols/bonjour/mdns_avahi.c
  patched  libpurple/protocols/bonjour/mdns_common.c

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/bonjour.c	a35cb3fab8c4877f943c31f64fad53a6d95e1bcb
+++ libpurple/protocols/bonjour/bonjour.c	467b49e676585227c96ce203e0a050b8fb6915db
@@ -51,7 +51,7 @@ bonjour_get_jid(PurpleAccount *account)
 bonjour_get_jid(PurpleAccount *account)
 {
 	PurpleConnection *conn = purple_account_get_connection(account);
-	BonjourData *bd = conn->proto_data;
+	BonjourData *bd = purple_connection_get_protocol_data(conn);
 	return bd->jid;
 }
 
@@ -103,7 +103,8 @@ bonjour_login(PurpleAccount *account)
 #endif /* _WIN32 */
 
 	gc->flags |= PURPLE_CONNECTION_HTML;
-	gc->proto_data = bd = g_new0(BonjourData, 1);
+	bd = g_new0(BonjourData, 1);
+	purple_connection_set_protocol_data(gc, bd);
 
 	/* Start waiting for jabber connections (iChat style) */
 	bd->jabber_data = g_new0(BonjourJabber, 1);
@@ -157,7 +158,7 @@ bonjour_close(PurpleConnection *connecti
 bonjour_close(PurpleConnection *connection)
 {
 	PurpleGroup *bonjour_group;
-	BonjourData *bd = connection->proto_data;
+	BonjourData *bd = purple_connection_get_protocol_data(connection);
 
 	bonjour_group = purple_find_group(BONJOUR_GROUP_NAME);
 
@@ -192,7 +193,7 @@ bonjour_close(PurpleConnection *connecti
 	if (bd != NULL)
 		g_free(bd->jid);
 	g_free(bd);
-	connection->proto_data = NULL;
+	purple_connection_set_protocol_data(connection, NULL);
 }
 
 static const char *
@@ -204,10 +205,12 @@ bonjour_send_im(PurpleConnection *connec
 static int
 bonjour_send_im(PurpleConnection *connection, const char *to, const char *msg, PurpleMessageFlags flags)
 {
+	BonjourData *bd = purple_connection_get_protocol_data(connection);
+
 	if(!to || !msg)
 		return 0;
 
-	return bonjour_jabber_send_message(((BonjourData*)(connection->proto_data))->jabber_data, to, msg);
+	return bonjour_jabber_send_message(bd->jabber_data, to, msg);
 }
 
 static void
@@ -220,7 +223,7 @@ bonjour_set_status(PurpleAccount *accoun
 	gchar *stripped;
 
 	gc = purple_account_get_connection(account);
-	bd = gc->proto_data;
+	bd = purple_connection_get_protocol_data(gc);
 	presence = purple_account_get_presence(account);
 
 	message = purple_status_get_attr_string(status, "message");
@@ -325,7 +328,7 @@ void bonjour_set_buddy_icon(PurpleConnec
 static
 void bonjour_set_buddy_icon(PurpleConnection *conn, PurpleStoredImage *img)
 {
-	BonjourData *bd = conn->proto_data;
+	BonjourData *bd = purple_connection_get_protocol_data(conn);
 	bonjour_dns_sd_update_buddy_icon(bd->dns_sd_data);
 }
 
============================================================
--- libpurple/protocols/bonjour/jabber.c	bcfcd3ad026dbc0097dcceae84f565ff341cd4bb
+++ libpurple/protocols/bonjour/jabber.c	4ad335c20b278e3753d7242721c9f94705286ecc
@@ -930,7 +930,8 @@ bonjour_jabber_conv_match_by_name(Bonjou
 			ip = tmp->data;
 			if (ip != NULL && g_ascii_strcasecmp(ip, bconv->ip) == 0) {
 				PurpleConnection *pc = purple_account_get_connection(bconv->account);
-				BonjourJabber *jdata = ((BonjourData *)pc->proto_data)->jabber_data;
+				BonjourData *bd = purple_connection_get_protocol_data(pc);
+				BonjourJabber *jdata = bd->jabber_data;
 
 				purple_debug_info("bonjour", "Matched buddy %s to incoming conversation \"from\" attrib and IP (%s)\n",
 					purple_buddy_get_name(pb), bconv->ip);
@@ -964,7 +965,8 @@ bonjour_jabber_conv_match_by_ip(BonjourJ
 void
 bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) {
 	PurpleConnection *pc = purple_account_get_connection(bconv->account);
-	BonjourJabber *jdata = ((BonjourData *)pc->proto_data)->jabber_data;
+	BonjourData *bd = purple_connection_get_protocol_data(pc);
+	BonjourJabber *jdata = bd->jabber_data;
 	struct _match_buddies_by_address_t *mbba;
 	GSList *buddies;
 
@@ -1125,7 +1127,8 @@ async_bonjour_jabber_close_conversation(
 void
 async_bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) {
 	PurpleConnection *pc = purple_account_get_connection(bconv->account);
-	BonjourJabber *jdata = ((BonjourData *)pc->proto_data)->jabber_data;
+	BonjourData *bd = purple_connection_get_protocol_data(pc);
+	BonjourJabber *jdata = bd->jabber_data;
 
 	jdata->pending_conversations = g_slist_remove(jdata->pending_conversations, bconv);
 
@@ -1147,7 +1150,7 @@ bonjour_jabber_close_conversation(Bonjou
 
 		PurpleConnection *pc = purple_account_get_connection(bconv->account);
 		if (PURPLE_CONNECTION_IS_VALID(pc)) {
-			bd = pc->proto_data;
+			bd = purple_connection_get_protocol_data(pc);
 			bd->jabber_data->pending_conversations = g_slist_remove(bd->jabber_data->pending_conversations, bconv);
 		}
 
============================================================
--- libpurple/protocols/bonjour/mdns_common.c	9ac6232226f1774d123022c929729861fb9be9e2
+++ libpurple/protocols/bonjour/mdns_common.c	26d8d9facbb4d7d30d7abfdaa3604c2304ca11d2
@@ -257,7 +257,7 @@ bonjour_dns_sd_set_jid(PurpleAccount *ac
 bonjour_dns_sd_set_jid(PurpleAccount *account, const char *hostname)
 {
 	PurpleConnection *conn = purple_account_get_connection(account);
-	BonjourData *bd = conn->proto_data;
+	BonjourData *bd = purple_connection_get_protocol_data(conn);
 	const char *tmp, *account_name = purple_account_get_username(account);
 
 	/* Previously we allowed the hostname part of the jid to be set
============================================================
--- libpurple/protocols/bonjour/mdns_avahi.c	7da97ca06c35f9dc1dc1e5b106a7dad3ea2fc107
+++ libpurple/protocols/bonjour/mdns_avahi.c	395a3ce684c46be2640b3cc1fe9a0b85feca05b7
@@ -615,7 +615,7 @@ void _mdns_retrieve_buddy_icon(BonjourBu
 
 void _mdns_retrieve_buddy_icon(BonjourBuddy* buddy) {
 	PurpleConnection *conn = purple_account_get_connection(buddy->account);
-	BonjourData *bd = conn->proto_data;
+	BonjourData *bd = purple_connection_get_protocol_data(conn);
 	AvahiSessionImplData *session_idata = bd->dns_sd_data->mdns_impl_data;
 	AvahiBuddyImplData *idata = buddy->mdns_impl_data;
 	gchar *name;
============================================================
--- libpurple/protocols/bonjour/bonjour_ft.c	94c46fde60d77f35adc3e566a1d27d8ed281ea37
+++ libpurple/protocols/bonjour/bonjour_ft.c	3c6ad0c0e0b7f86d9c6d41f5885ce90049b1db33
@@ -328,7 +328,7 @@ bonjour_new_xfer(PurpleConnection *gc, c
 		return NULL;
 
 	purple_debug_info("bonjour", "Bonjour-new-xfer to %s.\n", who);
-	bd = (BonjourData*) gc->proto_data;
+	bd = purple_connection_get_protocol_data(gc);
 	if(bd == NULL)
 		return NULL;
 
@@ -417,7 +417,7 @@ xep_si_parse(PurpleConnection *pc, xmlno
 	g_return_if_fail(packet != NULL);
 	g_return_if_fail(pb != NULL);
 
-	bd = (BonjourData*) pc->proto_data;
+	bd = purple_connection_get_protocol_data(pc);
 	if(bd == NULL)
 		return;
 
@@ -503,7 +503,7 @@ xep_bytestreams_parse(PurpleConnection *
 	g_return_if_fail(packet != NULL);
 	g_return_if_fail(pb != NULL);
 
-	bd = (BonjourData*) pc->proto_data;
+	bd = purple_connection_get_protocol_data(pc);
 	if(bd == NULL)
 		return;
 
@@ -585,7 +585,7 @@ bonjour_xfer_receive(PurpleConnection *p
 	if(pc == NULL || id == NULL || from == NULL)
 		return;
 
-	bd = (BonjourData*) pc->proto_data;
+	bd = purple_connection_get_protocol_data(pc);
 	if(bd == NULL)
 		return;
 


More information about the Commits mailing list