/soc/2013/ankitkv/gobjectification: cd2f92ba0543: Merged soc.201...

Ankit Vani a at nevitus.org
Tue Oct 1 16:50:53 EDT 2013


Changeset: cd2f92ba05433ba31835dc3c067dc1a5e46baba5
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-02 02:20 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/cd2f92ba0543

Description:

Merged soc.2013.gobjectification branch

diffstat:

 libpurple/account.c                     |  46 ++++++++++++++++++++------------
 libpurple/protocols/gg/chat.c           |   5 ++-
 libpurple/protocols/msn/msn.c           |  13 +++++++--
 libpurple/protocols/null/nullprotocol.c |   6 ++-
 4 files changed, 47 insertions(+), 23 deletions(-)

diffs (202 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -188,21 +188,26 @@ purple_account_unregister_got_password_c
 	g_free(cbb);
 }
 
+struct register_completed_closure
+{
+	PurpleAccount *account;
+	gboolean succeeded;
+};
+
 static gboolean
-purple_account_register_completed_cb(gpointer *data)
+purple_account_register_completed_cb(gpointer data)
 {
-	PurpleAccount *account = PURPLE_ACCOUNT(data[0]);
-	gboolean succeeded = (data[1] != NULL);
+	struct register_completed_closure *closure = data;
 	PurpleAccountPrivate *priv;
 
-	g_free(data);
-
-	g_return_val_if_fail(account != NULL, FALSE);
-
-	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(closure->account);
 
 	if (priv->registration_cb)
-		(priv->registration_cb)(account, succeeded, priv->registration_cb_user_data);
+		(priv->registration_cb)(closure->account, closure->succeeded,
+				priv->registration_cb_user_data);
+
+	g_object_unref(closure->account);
+	g_free(closure);
 
 	return FALSE;
 }
@@ -210,12 +215,15 @@ purple_account_register_completed_cb(gpo
 void
 purple_account_register_completed(PurpleAccount *account, gboolean succeeded)
 {
-	gpointer *data = g_new0(gpointer, 2);
-	data[0] = account;
-	data[1] = succeeded ? GINT_TO_POINTER(1) : NULL;
-
-	purple_timeout_add(0, (GSourceFunc)purple_account_register_completed_cb,
-			(gpointer)data);
+	struct register_completed_closure *closure;
+
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+
+	closure = g_new0(struct register_completed_closure, 1);
+	closure->account = g_object_ref(account);
+	closure->succeeded = succeeded;
+
+	purple_timeout_add(0, purple_account_register_completed_cb, closure);
 }
 
 void
@@ -1015,6 +1023,8 @@ set_public_alias_unsupported(gpointer da
 
 	failure_cb(closure->account,
 	           _("This protocol does not support setting a public alias."));
+
+	g_object_unref(closure->account);
 	g_free(closure);
 
 	return FALSE;
@@ -1039,7 +1049,7 @@ purple_account_set_public_alias(PurpleAc
 	else if (failure_cb) {
 		struct public_alias_closure *closure =
 				g_new0(struct public_alias_closure, 1);
-		closure->account = account;
+		closure->account = g_object_ref(account);
 		closure->failure_cb = failure_cb;
 		purple_timeout_add(0, set_public_alias_unsupported, closure);
 	}
@@ -1053,6 +1063,8 @@ get_public_alias_unsupported(gpointer da
 
 	failure_cb(closure->account,
 	           _("This protocol does not support fetching the public alias."));
+
+	g_object_unref(closure->account);
 	g_free(closure);
 
 	return FALSE;
@@ -1077,7 +1089,7 @@ purple_account_get_public_alias(PurpleAc
 	else if (failure_cb) {
 		struct public_alias_closure *closure =
 				g_new0(struct public_alias_closure, 1);
-		closure->account = account;
+		closure->account = g_object_ref(account);
 		closure->failure_cb = failure_cb;
 		purple_timeout_add(0, get_public_alias_unsupported, closure);
 	}
diff --git a/libpurple/protocols/gg/chat.c b/libpurple/protocols/gg/chat.c
--- a/libpurple/protocols/gg/chat.c
+++ b/libpurple/protocols/gg/chat.c
@@ -535,7 +535,9 @@ void ggp_chat_got_message(PurpleConnecti
 
 static gboolean ggp_chat_roomlist_get_list_finish(gpointer roomlist)
 {
-	purple_roomlist_set_in_progress((PurpleRoomlist*)roomlist, FALSE);
+	purple_roomlist_set_in_progress(PURPLE_ROOMLIST(roomlist), FALSE);
+	g_object_unref(roomlist);
+
 	return FALSE;
 }
 
@@ -601,6 +603,7 @@ PurpleRoomlist * ggp_chat_roomlist_get_l
 
 	//TODO
 	//purple_roomlist_set_in_progress(roomlist, FALSE);
+	g_object_ref(roomlist);
 	purple_timeout_add(1, ggp_chat_roomlist_get_list_finish, roomlist);
 	return roomlist;
 }
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -185,6 +185,8 @@ set_public_alias_length_error(gpointer d
 	PurpleSetPublicAliasFailureCallback failure_cb = closure->failure_cb;
 
 	failure_cb(closure->account, _("Your new MSN friendly name is too long."));
+
+	g_object_unref(closure->account);
 	g_free(closure);
 
 	return FALSE;
@@ -257,7 +259,7 @@ msn_set_public_alias(PurpleConnection *p
 			if (failure_cb) {
 				struct public_alias_closure *closure =
 					g_new0(struct public_alias_closure, 1);
-				closure->account = account;
+				closure->account = g_object_ref(account);
 				closure->failure_cb = failure_cb;
 				purple_timeout_add(0, set_public_alias_length_error, closure);
 			} else {
@@ -299,6 +301,8 @@ get_public_alias_cb(gpointer data)
 	alias = purple_account_get_string(closure->account, "display-name",
 	                                  purple_account_get_username(closure->account));
 	success_cb(closure->account, alias);
+
+	g_object_unref(closure->account);
 	g_free(closure);
 
 	return FALSE;
@@ -312,7 +316,7 @@ msn_get_public_alias(PurpleConnection *p
 	struct public_alias_closure *closure = g_new0(struct public_alias_closure, 1);
 	PurpleAccount *account = purple_connection_get_account(pc);
 
-	closure->account = account;
+	closure->account = g_object_ref(account);
 	closure->success_cb = success_cb;
 	purple_timeout_add(0, get_public_alias_cb, closure);
 }
@@ -1403,8 +1407,11 @@ msn_send_me_im(gpointer data)
 {
 	MsnIMData *imdata = data;
 	serv_got_im(imdata->gc, imdata->who, imdata->msg, imdata->flags, imdata->when);
+
+	g_object_unref(imdata->gc);
 	g_free(imdata->msg);
 	g_free(imdata);
+
 	return FALSE;
 }
 
@@ -1625,7 +1632,7 @@ msn_send_im(PurpleConnection *gc, const 
 		g_free(post);
 
 		serv_got_typing_stopped(gc, who);
-		imdata->gc = gc;
+		imdata->gc = g_object_ref(gc);
 		imdata->who = who;
 		imdata->msg = body_str;
 		imdata->flags = flags & ~PURPLE_MESSAGE_SEND;
diff --git a/libpurple/protocols/null/nullprotocol.c b/libpurple/protocols/null/nullprotocol.c
--- a/libpurple/protocols/null/nullprotocol.c
+++ b/libpurple/protocols/null/nullprotocol.c
@@ -975,7 +975,9 @@ static void null_set_chat_topic(PurpleCo
 }
 
 static gboolean null_finish_get_roomlist(gpointer roomlist) {
-  purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE);
+  purple_roomlist_set_in_progress(PURPLE_ROOMLIST(roomlist), FALSE);
+  g_object_unref(roomlist);
+
   return FALSE;
 }
 
@@ -1024,7 +1026,7 @@ static PurpleRoomlist *null_roomlist_get
   }
 
   g_list_free(seen_ids);
-  purple_timeout_add(1 /* ms */, null_finish_get_roomlist, roomlist);
+  purple_timeout_add(1 /* ms */, null_finish_get_roomlist, g_object_ref(roomlist));
   return roomlist;
 }
 



More information about the Commits mailing list