/soc/2013/ankitkv/gobjectification: 7fafdda14844: Merged soc.201...

Ankit Vani a at nevitus.org
Tue Oct 1 15:46:12 EDT 2013


Changeset: 7fafdda14844690c9453ab2a2065d4a7d519ee5a
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-02 01:15 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7fafdda14844

Description:

Merged soc.2013.gobjectification branch

diffstat:

 ChangeLog.API                               |   1 +
 libpurple/account.c                         |  47 ++++++++++++++++++----------
 libpurple/connection.h                      |  14 --------
 libpurple/dbus-define-api.h                 |   1 -
 libpurple/protocols/bonjour/jabber.c        |   2 +-
 libpurple/protocols/gg/avatar.c             |   8 ++--
 libpurple/protocols/gg/edisc.c              |   2 +-
 libpurple/protocols/gg/gg.c                 |   2 +-
 libpurple/protocols/gg/oauth/oauth-purple.c |   4 +-
 libpurple/protocols/gg/pubdir-prpl.c        |   6 +-
 libpurple/protocols/gg/roster.c             |   2 +-
 libpurple/protocols/jabber/auth.c           |   4 +-
 libpurple/protocols/jabber/auth_cyrus.c     |   4 +-
 libpurple/protocols/jabber/jabber.c         |  15 +++++---
 libpurple/protocols/jabber/presence.c       |   4 +-
 libpurple/protocols/msn/userlist.c          |   4 +-
 libpurple/protocols/mxit/actions.c          |   4 +-
 libpurple/protocols/mxit/login.c            |   2 +-
 libpurple/protocols/silc/silc.c             |   4 +-
 libpurple/protocols/yahoo/ymsg.c            |   2 +-
 pidgin/gtkaccount.c                         |   6 +-
 21 files changed, 70 insertions(+), 68 deletions(-)

diffs (truncated from 523 to 300 lines):

diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -393,6 +393,7 @@ version 3.0.0 (??/??/????):
 		* purple_connection_new_unregister
 		* purple_connection_destroy
 		* purple_connection_set_account
+		* PURPLE_CONNECTION_IS_VALID
 		* purple_contact_set_alias
 		* purple_conv_chat_set_users
 		* PurpleConversationType
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -188,17 +188,34 @@ purple_account_unregister_got_password_c
 	g_free(cbb);
 }
 
+static gboolean
+purple_account_register_completed_cb(gpointer *data)
+{
+	PurpleAccount *account = PURPLE_ACCOUNT(data[0]);
+	gboolean succeeded = (data[1] != NULL);
+	PurpleAccountPrivate *priv;
+
+	g_free(data);
+
+	g_return_val_if_fail(account != NULL, FALSE);
+
+	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
+	if (priv->registration_cb)
+		(priv->registration_cb)(account, succeeded, priv->registration_cb_user_data);
+
+	return FALSE;
+}
+
 void
 purple_account_register_completed(PurpleAccount *account, gboolean succeeded)
 {
-	PurpleAccountPrivate *priv;
-
-	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
-	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
-
-	if (priv->registration_cb)
-		(priv->registration_cb)(account, succeeded, priv->registration_cb_user_data);
+	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);
 }
 
 void
@@ -860,10 +877,10 @@ purple_account_set_enabled(PurpleAccount
 {
 	PurpleConnection *gc;
 	PurpleAccountPrivate *priv;
-	gboolean was_enabled = FALSE;
+	gboolean was_enabled = FALSE, wants_to_die = FALSE;
 
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-	g_return_if_fail(ui      != NULL);
+	g_return_if_fail(ui != NULL);
 
 	was_enabled = purple_account_get_enabled(account, ui);
 
@@ -876,11 +893,11 @@ purple_account_set_enabled(PurpleAccount
 		purple_signal_emit(purple_accounts_get_handle(), "account-enabled", account);
 
 	if ((gc != NULL) && (_purple_connection_wants_to_die(gc)))
-		return;
+		wants_to_die = TRUE;
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 
-	if (value && purple_presence_is_online(priv->presence))
+	if (!wants_to_die && value && purple_presence_is_online(priv->presence))
 		purple_account_connect(account);
 	else if (!value && !purple_account_is_disconnected(account))
 		purple_account_disconnect(account);
@@ -2907,11 +2924,7 @@ purple_account_constructed(GObject *obje
 static void
 purple_account_dispose(GObject *object)
 {
-	PurpleAccount *account = PURPLE_ACCOUNT(object);
-	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
-
-	if (!purple_account_is_disconnected(account))
-		purple_account_disconnect(account);
+	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(object);
 
 	if (priv->presence) {
 		g_object_unref(priv->presence);
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -483,20 +483,6 @@ GList *purple_connections_get_all(void);
  */
 GList *purple_connections_get_connecting(void);
 
-/**
- * Checks if gc is still a valid pointer to a gc.
- *
- * @return @c TRUE if gc is valid.
- *
- * @deprecated Do not use this.  Instead, cancel your asynchronous request
- *             when the PurpleConnection is destroyed.
- */
-/*
- * TODO: Eventually this bad boy will be removed, because it is
- *       a gross fix for a crashy problem.
- */
-#define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
-
 /*@}*/
 
 /**************************************************************************/
diff --git a/libpurple/dbus-define-api.h b/libpurple/dbus-define-api.h
--- a/libpurple/dbus-define-api.h
+++ b/libpurple/dbus-define-api.h
@@ -11,6 +11,5 @@ gboolean PURPLE_BUDDY_IS_ONLINE(PurpleBu
 
 /* connection.h */
 gboolean PURPLE_CONNECTION_IS_CONNECTED(PurpleConnection *connection);
-gboolean PURPLE_CONNECTION_IS_VALID(PurpleConnection *connection);
 
 #endif /* __GI_SCANNER__ */
diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -1151,7 +1151,7 @@ bonjour_jabber_close_conversation(Bonjou
 		BonjourData *bd = NULL;
 
 		PurpleConnection *pc = purple_account_get_connection(bconv->account);
-		if (PURPLE_CONNECTION_IS_VALID(pc)) {
+		if (PURPLE_IS_CONNECTION(pc)) {
 			bd = purple_connection_get_protocol_data(pc);
 			bd->jabber_data->pending_conversations = g_slist_remove(bd->jabber_data->pending_conversations, bconv);
 		}
diff --git a/libpurple/protocols/gg/avatar.c b/libpurple/protocols/gg/avatar.c
--- a/libpurple/protocols/gg/avatar.c
+++ b/libpurple/protocols/gg/avatar.c
@@ -127,7 +127,7 @@ static gboolean ggp_avatar_timer_cb(gpoi
 	PurpleConnection *gc = _gc;
 	ggp_avatar_session_data *avdata;
 	
-	g_return_val_if_fail(PURPLE_CONNECTION_IS_VALID(gc), FALSE);
+	g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), FALSE);
 	
 	avdata = ggp_avatar_get_avdata(gc);
 	if (avdata->current_update != NULL)
@@ -271,7 +271,7 @@ static void ggp_avatar_buddy_update_rece
 	const gchar *got_data;
 	size_t got_len;
 
-	if (!PURPLE_CONNECTION_IS_VALID(gc))
+	if (!PURPLE_IS_CONNECTION(gc))
 	{
 		g_free(pending_update);
 		return;
@@ -330,7 +330,7 @@ void ggp_avatar_own_set(PurpleConnection
 {
 	ggp_avatar_own_data *own_data;
 	
-	if (!PURPLE_CONNECTION_IS_VALID(gc) || !PURPLE_CONNECTION_IS_CONNECTED(gc))
+	if (!PURPLE_IS_CONNECTION(gc) || !PURPLE_CONNECTION_IS_CONNECTED(gc))
 		return;
 	
 	purple_debug_info("gg", "ggp_avatar_own_set(%p, %p)", gc, img);
@@ -396,7 +396,7 @@ static void ggp_avatar_own_sent(PurpleHt
 	PurpleConnection *gc =
 		purple_http_conn_get_purple_connection(http_conn);
 
-	if (!PURPLE_CONNECTION_IS_VALID(gc))
+	if (!PURPLE_IS_CONNECTION(gc))
 		return;
 
 	if (!purple_http_response_is_successful(response)) {
diff --git a/libpurple/protocols/gg/edisc.c b/libpurple/protocols/gg/edisc.c
--- a/libpurple/protocols/gg/edisc.c
+++ b/libpurple/protocols/gg/edisc.c
@@ -100,7 +100,7 @@ ggp_edisc_get_sdata(PurpleConnection *gc
 {
 	GGPInfo *accdata;
 
-	g_return_val_if_fail(PURPLE_CONNECTION_IS_VALID(gc), NULL);
+	g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), NULL);
 
 	accdata = purple_connection_get_protocol_data(gc);
 	g_return_val_if_fail(accdata != NULL, NULL);
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -411,7 +411,7 @@ void ggp_async_login_handler(gpointer _g
 	GGPInfo *info;
 	struct gg_event *ev;
 
-	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
+	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 
 	info = purple_connection_get_protocol_data(gc);
 
diff --git a/libpurple/protocols/gg/oauth/oauth-purple.c b/libpurple/protocols/gg/oauth/oauth-purple.c
--- a/libpurple/protocols/gg/oauth/oauth-purple.c
+++ b/libpurple/protocols/gg/oauth/oauth-purple.c
@@ -115,7 +115,7 @@ static void ggp_oauth_request_token_got(
 	gboolean succ = TRUE;
 	const gchar *xml_raw;
 
-	if (!PURPLE_CONNECTION_IS_VALID(data->gc))
+	if (!PURPLE_IS_CONNECTION(data->gc))
 	{
 		ggp_oauth_data_free(data);
 		return;
@@ -185,7 +185,7 @@ static void ggp_oauth_authorization_done
 	const char *url = "http://api.gadu-gadu.pl/access_token";
 	int response_code;
 
-	if (!PURPLE_CONNECTION_IS_VALID(data->gc))
+	if (!PURPLE_IS_CONNECTION(data->gc))
 	{
 		ggp_oauth_data_free(data);
 		return;
diff --git a/libpurple/protocols/gg/pubdir-prpl.c b/libpurple/protocols/gg/pubdir-prpl.c
--- a/libpurple/protocols/gg/pubdir-prpl.c
+++ b/libpurple/protocols/gg/pubdir-prpl.c
@@ -200,7 +200,7 @@ static void ggp_pubdir_get_info_got_toke
 	PurpleHttpRequest *req;
 	ggp_pubdir_request *request = _request;
 
-	if (!token || !PURPLE_CONNECTION_IS_VALID(gc))
+	if (!token || !PURPLE_IS_CONNECTION(gc))
 	{
 		request->cb(gc, -1, NULL, 0, request->user_data);
 		ggp_pubdir_request_free(request);
@@ -634,7 +634,7 @@ static void ggp_pubdir_search_got_token(
 	ggp_pubdir_request *request = _request;
 	gchar *query;
 
-	if (!token || !PURPLE_CONNECTION_IS_VALID(gc))
+	if (!token || !PURPLE_IS_CONNECTION(gc))
 	{
 		request->cb(gc, -1, NULL, 0, request->user_data);
 		ggp_pubdir_request_free(request);
@@ -911,7 +911,7 @@ static void ggp_pubdir_set_info_got_toke
 	gchar *name, *surname, *city;
 	uin_t uin = record->uin;
 
-	if (!token || !PURPLE_CONNECTION_IS_VALID(gc))
+	if (!token || !PURPLE_IS_CONNECTION(gc))
 	{
 		// TODO: notify about failure
 		ggp_pubdir_record_free(record, 1);
diff --git a/libpurple/protocols/gg/roster.c b/libpurple/protocols/gg/roster.c
--- a/libpurple/protocols/gg/roster.c
+++ b/libpurple/protocols/gg/roster.c
@@ -189,7 +189,7 @@ static gboolean ggp_roster_timer_cb(gpoi
 {
 	PurpleConnection *gc = _gc;
 	
-	g_return_val_if_fail(PURPLE_CONNECTION_IS_VALID(gc), FALSE);
+	g_return_val_if_fail(PURPLE_IS_CONNECTION(gc), FALSE);
 	
 	ggp_roster_send_update(gc);
 	
diff --git a/libpurple/protocols/jabber/auth.c b/libpurple/protocols/jabber/auth.c
--- a/libpurple/protocols/jabber/auth.c
+++ b/libpurple/protocols/jabber/auth.c
@@ -94,7 +94,7 @@ auth_old_pass_cb(PurpleConnection *gc, P
 	gboolean remember;
 
 	/* The password prompt dialog doesn't get disposed if the account disconnects */
-	if (!PURPLE_CONNECTION_IS_VALID(gc))
+	if (!PURPLE_IS_CONNECTION(gc))
 		return;
 
 	account = purple_connection_get_account(gc);
@@ -123,7 +123,7 @@ static void
 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
 {
 	/* The password prompt dialog doesn't get disposed if the account disconnects */
-	if (!PURPLE_CONNECTION_IS_VALID(gc))
+	if (!PURPLE_IS_CONNECTION(gc))
 		return;
 
 	/* Disable the account as the user has cancelled connecting */
diff --git a/libpurple/protocols/jabber/auth_cyrus.c b/libpurple/protocols/jabber/auth_cyrus.c
--- a/libpurple/protocols/jabber/auth_cyrus.c
+++ b/libpurple/protocols/jabber/auth_cyrus.c
@@ -134,7 +134,7 @@ static void auth_pass_cb(PurpleConnectio
 	gboolean remember;
 
 	/* The password prompt dialog doesn't get disposed if the account disconnects */
-	if (!PURPLE_CONNECTION_IS_VALID(gc))
+	if (!PURPLE_IS_CONNECTION(gc))
 		return;



More information about the Commits mailing list