/soc/2013/ankitkv/gobjectification: 9401f9b1ca68: Used GObject-s...

Ankit Vani a at nevitus.org
Tue Jul 9 16:27:52 EDT 2013


Changeset: 9401f9b1ca681cf6f0639373517e326fd1a8e9e2
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-10 01:57 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/9401f9b1ca68

Description:

Used GObject-style casts in plugins.
This will help people who refer to other plugins to write their own.

diffstat:

 finch/plugins/gnthistory.c                 |   8 ++++----
 finch/plugins/grouping.c                   |  18 +++++++++---------
 libpurple/plugins/autoaccept.c             |   4 ++--
 libpurple/plugins/mono/loader/blist-glue.c |   2 +-
 libpurple/plugins/signals-test.c           |  16 ++++++++--------
 libpurple/plugins/tcl/tcl_cmds.c           |  10 +++++-----
 libpurple/plugins/tcl/tcl_signals.c        |  10 +++++-----
 pidgin/plugins/cap/cap.c                   |   2 +-
 pidgin/plugins/gevolution/gevo-util.c      |   2 +-
 pidgin/plugins/gevolution/gevolution.c     |   6 +++---
 pidgin/plugins/history.c                   |   8 ++++----
 pidgin/plugins/ticker/ticker.c             |   2 +-
 12 files changed, 44 insertions(+), 44 deletions(-)

diffs (truncated from 345 to 300 lines):

diff --git a/finch/plugins/gnthistory.c b/finch/plugins/gnthistory.c
--- a/finch/plugins/gnthistory.c
+++ b/finch/plugins/gnthistory.c
@@ -67,7 +67,7 @@ static void historize(PurpleConversation
 
 		/* If we found at least one buddy, save the first buddy's alias. */
 		if (buddies != NULL)
-			alias = purple_buddy_get_contact_alias((PurpleBuddy *)buddies->data);
+			alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(buddies->data));
 
 		for (cur = buddies; cur != NULL; cur = cur->next) {
 			PurpleBListNode *node = cur->data;
@@ -76,7 +76,7 @@ static void historize(PurpleConversation
 						(purple_blist_node_get_sibling_next(node) != NULL))) {
 				PurpleBListNode *node2;
 
-				alias = purple_buddy_get_contact_alias((PurpleBuddy *)node);
+				alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node));
 
 				/* We've found a buddy that matches this conversation.  It's part of a
 				 * PurpleContact with more than one PurpleBuddy.  Loop through the PurpleBuddies
@@ -85,8 +85,8 @@ static void historize(PurpleConversation
 						node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
 					logs = g_list_concat(
 							purple_log_get_logs(PURPLE_LOG_IM,
-								purple_buddy_get_name((PurpleBuddy *)node2),
-								purple_buddy_get_account((PurpleBuddy *)node2)),
+								purple_buddy_get_name(PURPLE_BUDDY(node2)),
+								purple_buddy_get_account(PURPLE_BUDDY(node2))),
 							logs);
 				}
 				break;
diff --git a/finch/plugins/grouping.c b/finch/plugins/grouping.c
--- a/finch/plugins/grouping.c
+++ b/finch/plugins/grouping.c
@@ -92,12 +92,12 @@ static gboolean on_offline_init()
 static gboolean on_offline_can_add_node(PurpleBListNode *node)
 {
 	if (PURPLE_IS_CONTACT(node)) {
-		PurpleContact *contact = (PurpleContact*)node;
+		PurpleContact *contact = PURPLE_CONTACT(node);
 		if (purple_counting_node_get_current_size(PURPLE_COUNTING_NODE(contact)) > 0)
 			return TRUE;
 		return FALSE;
 	} else if (PURPLE_IS_BUDDY(node)) {
-		PurpleBuddy *buddy = (PurpleBuddy*)node;
+		PurpleBuddy *buddy = PURPLE_BUDDY(node);
 		if (PURPLE_IS_BUDDY_ONLINE(buddy))
 			return TRUE;
 		if (purple_prefs_get_bool("/finch/blist/showoffline") &&
@@ -105,7 +105,7 @@ static gboolean on_offline_can_add_node(
 			return TRUE;
 		return FALSE;
 	} else if (PURPLE_IS_CHAT(node)) {
-		PurpleChat *chat = (PurpleChat*)node;
+		PurpleChat *chat = PURPLE_CHAT(node);
 		return purple_account_is_connected(purple_chat_get_account(chat));
 	}
 
@@ -118,7 +118,7 @@ static gpointer on_offline_find_parent(P
 
 	if (PURPLE_IS_CONTACT(node)) {
 		node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
-		ret = PURPLE_IS_BUDDY_ONLINE((PurpleBuddy*)node) ? online : offline;
+		ret = PURPLE_IS_BUDDY_ONLINE(PURPLE_BUDDY(node)) ? online : offline;
 	} else if (PURPLE_IS_BUDDY(node)) {
 		ret = purple_blist_node_get_parent(node);
 		finch_blist_manager_add_node(ret);
@@ -175,7 +175,7 @@ static gboolean meebo_init()
 static gpointer meebo_find_parent(PurpleBListNode *node)
 {
 	if (PURPLE_IS_CONTACT(node)) {
-		PurpleBuddy *buddy = purple_contact_get_priority_buddy((PurpleContact*)node);
+		PurpleBuddy *buddy = purple_contact_get_priority_buddy(PURPLE_CONTACT(node));
 		if (buddy && !PURPLE_IS_BUDDY_ONLINE(buddy)) {
 			return &meebo;
 		}
@@ -274,7 +274,7 @@ nested_group_find_parent(PurpleBListNode
 	if (!PURPLE_IS_GROUP(node))
 		return default_manager->find_parent(node);
 
-	group = (PurpleGroup *)node;
+	group = PURPLE_GROUP(node);
 	name = g_strdup(purple_group_get_name(group));
 	if (!(sep = strchr(name, '/'))) {
 		g_free(name);
@@ -327,13 +327,13 @@ nested_group_can_add_node(PurpleBListNod
 	if (default_manager->can_add_node(node))
 		return TRUE;
 
-	len = strlen(purple_group_get_name((PurpleGroup*)node));
+	len = strlen(purple_group_get_name(PURPLE_GROUP(node)));
 	group = purple_blist_get_root();
 	for (; group; group = purple_blist_node_get_sibling_next(group)) {
 		if (group == node)
 			continue;
-		if (strncmp(purple_group_get_name((PurpleGroup *)node),
-					purple_group_get_name((PurpleGroup *)group), len) == 0 &&
+		if (strncmp(purple_group_get_name(PURPLE_GROUP(node)),
+					purple_group_get_name(PURPLE_GROUP(group)), len) == 0 &&
 				default_manager->can_add_node(group))
 			return TRUE;
 	}
diff --git a/libpurple/plugins/autoaccept.c b/libpurple/plugins/autoaccept.c
--- a/libpurple/plugins/autoaccept.c
+++ b/libpurple/plugins/autoaccept.c
@@ -198,7 +198,7 @@ set_auto_accept_settings(PurpleBListNode
 	g_return_if_fail(PURPLE_IS_CONTACT(node));
 
 	message = g_strdup_printf(_("When a file-transfer request arrives from %s"),
-					purple_contact_get_alias((PurpleContact *)node));
+					purple_contact_get_alias(PURPLE_CONTACT(node)));
 	purple_request_choice(plugin, _("Set Autoaccept Setting"), message,
 						NULL, purple_blist_node_get_int(node, "autoaccept"),
 						_("_Save"), G_CALLBACK(save_cb),
@@ -208,7 +208,7 @@ set_auto_accept_settings(PurpleBListNode
 						_("Ask"), FT_ASK,
 						_("Auto Accept"), FT_ACCEPT,
 						_("Auto Reject"), FT_REJECT,
-						NULL, purple_contact_get_alias((PurpleContact *)node), NULL,
+						NULL, purple_contact_get_alias(PURPLE_CONTACT(node)), NULL,
 						NULL);
 	g_free(message);
 }
diff --git a/libpurple/plugins/mono/loader/blist-glue.c b/libpurple/plugins/mono/loader/blist-glue.c
--- a/libpurple/plugins/mono/loader/blist-glue.c
+++ b/libpurple/plugins/mono/loader/blist-glue.c
@@ -14,7 +14,7 @@ MonoObject* purple_blist_build_buddy_obj
 {
 	MonoObject *obj = NULL;
 
-	PurpleBuddy *buddy = (PurpleBuddy*)data;
+	PurpleBuddy *buddy = PURPLE_BUDDY(data);
 
 	obj = ml_create_api_object("Buddy");
 	g_return_val_if_fail(obj != NULL, NULL);
diff --git a/libpurple/plugins/signals-test.c b/libpurple/plugins/signals-test.c
--- a/libpurple/plugins/signals-test.c
+++ b/libpurple/plugins/signals-test.c
@@ -183,10 +183,10 @@ blist_node_removed_cb(PurpleBListNode *b
 static void
 blist_node_aliased(PurpleBListNode *node, const char *old_alias)
 {
-	PurpleContact *p = (PurpleContact *)node;
-	PurpleBuddy *b = (PurpleBuddy *)node;
-	PurpleChat *c = (PurpleChat *)node;
-	PurpleGroup *g = (PurpleGroup *)node;
+	PurpleContact *p = PURPLE_CONTACT(node);
+	PurpleBuddy *b = PURPLE_BUDDY(node);
+	PurpleChat *c = PURPLE_CHAT(node);
+	PurpleGroup *g = PURPLE_GROUP(node);
 
 	if (PURPLE_IS_CONTACT(node)) {
 		purple_debug_misc("signals test",
@@ -210,10 +210,10 @@ blist_node_aliased(PurpleBListNode *node
 static void
 blist_node_extended_menu_cb(PurpleBListNode *node, void *data)
 {
-	PurpleContact *p = (PurpleContact *)node;
-	PurpleBuddy *b = (PurpleBuddy *)node;
-	PurpleChat *c = (PurpleChat *)node;
-	PurpleGroup *g = (PurpleGroup *)node;
+	PurpleContact *p = PURPLE_CONTACT(node);
+	PurpleBuddy *b = PURPLE_BUDDY(node);
+	PurpleChat *c = PURPLE_CHAT(node);
+	PurpleGroup *g = PURPLE_GROUP(node);
 
 	if (PURPLE_IS_CONTACT(node)) {
 		purple_debug_misc("signals test",
diff --git a/libpurple/plugins/tcl/tcl_cmds.c b/libpurple/plugins/tcl/tcl_cmds.c
--- a/libpurple/plugins/tcl/tcl_cmds.c
+++ b/libpurple/plugins/tcl/tcl_cmds.c
@@ -439,10 +439,10 @@ int tcl_cmd_buddy(ClientData unused, Tcl
 			return TCL_ERROR;
 		if (PURPLE_IS_CHAT(node))
 			Tcl_SetObjResult(interp,
-					 Tcl_NewStringObj(purple_chat_get_name((PurpleChat *)node), -1));
+					 Tcl_NewStringObj(purple_chat_get_name(PURPLE_CHAT(node)), -1));
 		else if (PURPLE_IS_BUDDY(node))
 			Tcl_SetObjResult(interp,
-                                         Tcl_NewStringObj((char *)purple_buddy_get_alias((PurpleBuddy *)node), -1));
+                                         Tcl_NewStringObj((char *)purple_buddy_get_alias(PURPLE_BUDDY(node)), -1));
 		return TCL_OK;
 		break;
 	case CMD_BUDDY_HANDLE:
@@ -497,7 +497,7 @@ int tcl_cmd_buddy(ClientData unused, Tcl
 			tclgroup = Tcl_NewListObj(0, NULL);
 			Tcl_ListObjAppendElement(interp, tclgroup, Tcl_NewStringObj("group", -1));
 			Tcl_ListObjAppendElement(interp, tclgroup,
-						 Tcl_NewStringObj(purple_group_get_name((PurpleGroup *)gnode), -1));
+						 Tcl_NewStringObj(purple_group_get_name(PURPLE_GROUP(gnode)), -1));
 			tclgrouplist = Tcl_NewListObj(0, NULL);
 			for (node = purple_blist_node_get_first_child(gnode); node != NULL; node = purple_blist_node_get_sibling_next(node)) {
 				PurpleAccount *account;
@@ -512,7 +512,7 @@ int tcl_cmd_buddy(ClientData unused, Tcl
 					for (bnode = purple_blist_node_get_first_child(node); bnode != NULL; bnode = purple_blist_node_get_sibling_next(bnode)) {
 						if (!PURPLE_IS_BUDDY(bnode))
 							continue;
-						bud = (PurpleBuddy *)bnode;
+						bud = PURPLE_BUDDY(bnode);
 						account = purple_buddy_get_account(bud);
 						if (!all && !purple_account_is_connected(account))
 							continue;
@@ -530,7 +530,7 @@ int tcl_cmd_buddy(ClientData unused, Tcl
 					Tcl_DecrRefCount(tclcontact);
 					Tcl_DecrRefCount(tclcontactlist);
 				} else if (PURPLE_IS_CHAT(node)) {
-					cnode = (PurpleChat *)node;
+					cnode = PURPLE_CHAT(node);
 					account = purple_chat_get_account(cnode);
 					if (!all && !purple_account_is_connected(account))
 						continue;
diff --git a/libpurple/plugins/tcl/tcl_signals.c b/libpurple/plugins/tcl/tcl_signals.c
--- a/libpurple/plugins/tcl/tcl_signals.c
+++ b/libpurple/plugins/tcl/tcl_signals.c
@@ -299,7 +299,7 @@ static void *tcl_signal_callback(va_list
 					Tcl_ListObjAppendElement(handler->interp, arg,
 								 Tcl_NewStringObj("group", -1));
 					Tcl_ListObjAppendElement(handler->interp, arg,
-								 Tcl_NewStringObj(purple_group_get_name((PurpleGroup *)node), -1));
+								 Tcl_NewStringObj(purple_group_get_name(PURPLE_GROUP(node)), -1));
 				} else if (PURPLE_IS_CONTACT(node)) {
 					/* g_string_printf(val, "contact {%s}", Contact Name? ); */
 					arg = Tcl_NewStringObj("contact", -1);
@@ -308,19 +308,19 @@ static void *tcl_signal_callback(va_list
 					Tcl_ListObjAppendElement(handler->interp, arg,
 								 Tcl_NewStringObj("buddy", -1));
 					Tcl_ListObjAppendElement(handler->interp, arg,
-								 Tcl_NewStringObj(purple_buddy_get_name((PurpleBuddy *)node), -1));
+								 Tcl_NewStringObj(purple_buddy_get_name(PURPLE_BUDDY(node)), -1));
 					Tcl_ListObjAppendElement(handler->interp, arg,
 								 purple_tcl_ref_new(PurpleTclRefAccount,
-										    purple_buddy_get_account((PurpleBuddy *)node)));
+										    purple_buddy_get_account(PURPLE_BUDDY(node))));
 				} else if (PURPLE_IS_CHAT(node)) {
 					arg = Tcl_NewListObj(0, NULL);
 					Tcl_ListObjAppendElement(handler->interp, arg,
 								 Tcl_NewStringObj("chat", -1));
 					Tcl_ListObjAppendElement(handler->interp, arg,
-								 Tcl_NewStringObj(purple_chat_get_name((PurpleChat *)node), -1));
+								 Tcl_NewStringObj(purple_chat_get_name(PURPLE_CHAT(node)), -1));
 					Tcl_ListObjAppendElement(handler->interp, arg,
 								 purple_tcl_ref_new(PurpleTclRefAccount,
-										  purple_chat_get_account((PurpleChat *)node)));
+										  purple_chat_get_account(PURPLE_CHAT(node))));
 				}
 			}
 		}
diff --git a/pidgin/plugins/cap/cap.c b/pidgin/plugins/cap/cap.c
--- a/pidgin/plugins/cap/cap.c
+++ b/pidgin/plugins/cap/cap.c
@@ -439,7 +439,7 @@ static void buddy_signed_off(PurpleBuddy
 /* drawing-tooltip */
 static void drawing_tooltip(PurpleBListNode *node, GString *text, gboolean full) {
 	if(node->type == PURPLE_BLIST_BUDDY_NODE) {
-		PurpleBuddy *buddy = (PurpleBuddy *)node;
+		PurpleBuddy *buddy = PURPLE_BUDDY(node);
 		CapStatistics *stats = get_stats_for(buddy);
 		/* get the probability that this buddy will respond and add to the tooltip */
 		if(stats->prediction->probability >= 0.0) {
diff --git a/pidgin/plugins/gevolution/gevo-util.c b/pidgin/plugins/gevolution/gevo-util.c
--- a/pidgin/plugins/gevolution/gevo-util.c
+++ b/pidgin/plugins/gevolution/gevo-util.c
@@ -80,7 +80,7 @@ gevo_get_groups(void)
 		{
 			if (PURPLE_IS_GROUP(gnode))
 			{
-				g = (PurpleGroup *)gnode;
+				g = PURPLE_GROUP(gnode);
 				list = g_list_append(list, g->name);
 			}
 		}
diff --git a/pidgin/plugins/gevolution/gevolution.c b/pidgin/plugins/gevolution/gevolution.c
--- a/pidgin/plugins/gevolution/gevolution.c
+++ b/pidgin/plugins/gevolution/gevolution.c
@@ -220,14 +220,14 @@ signed_on_cb(PurpleConnection *gc)
 static void
 menu_item_activate_cb(PurpleBListNode *node, gpointer user_data)
 {
-	PurpleBuddy *buddy = (PurpleBuddy *)node;
+	PurpleBuddy *buddy = PURPLE_BUDDY(node);
 	gevo_associate_buddy_dialog_new(buddy);
 }
 
 static void
 menu_item_send_mail_activate_cb(PurpleBListNode *node, gpointer user_data)
 {
-	PurpleBuddy *buddy = (PurpleBuddy *)node;
+	PurpleBuddy *buddy = PURPLE_BUDDY(node);
 	char *mail = NULL;
 
 	mail = gevo_get_email_for_buddy(buddy);
@@ -271,7 +271,7 @@ blist_node_extended_menu_cb(PurpleBListN
 	if (!PURPLE_IS_BUDDY(node))
 		return;
 
-	buddy = (PurpleBuddy *)node;
+	buddy = PURPLE_BUDDY(node);
 	account = purple_buddy_get_account(buddy);
 



More information about the Commits mailing list