/soc/2013/ankitkv/gobjectification: 348356cbc657: Removed PURPLE...

Ankit Vani a at nevitus.org
Tue Oct 1 15:35:17 EDT 2013


Changeset: 348356cbc6575871e58ee2556706f0a064347bc8
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-02 00:51 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/348356cbc657

Description:

Removed PURPLE_CONNECTION_IS_VALID. If needed, use PURPLE_IS_CONNECTION.

diffstat:

 ChangeLog.API                               |   1 +
 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/libymsg.c         |   2 +-
 19 files changed, 37 insertions(+), 48 deletions(-)

diffs (truncated from 406 to 300 lines):

diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -303,6 +303,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/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
@@ -10,5 +10,4 @@ gboolean PURPLE_BUDDY_IS_ONLINE(PurpleBu
 
 /* connection.h */
 gboolean PURPLE_CONNECTION_IS_CONNECTED(PurpleConnection *connection);
-gboolean PURPLE_CONNECTION_IS_VALID(PurpleConnection *connection);
 
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
@@ -407,7 +407,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;
 
 	account = purple_connection_get_account(gc);
@@ -168,7 +168,7 @@ auth_no_pass_cb(PurpleConnection *gc, Pu
 	PurpleAccount *account;
 
 	/* 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);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -84,6 +84,7 @@ GList *jabber_identities = NULL;
 static GHashTable *jabber_cmds = NULL; /* PurplePlugin * => GSList of ids */
 
 static gint plugin_ref = 0;
+static guint conn_close_timeout = 0;
 
 static void jabber_unregister_account_cb(JabberStream *js);
 static void try_srv_connect(JabberStream *js);
@@ -595,7 +596,7 @@ void jabber_send_signal_cb(PurpleConnect
 	if (NULL == packet)
 		return;
 
-	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(pc));
+	g_return_if_fail(PURPLE_IS_CONNECTION(pc));
 
 	js = purple_connection_get_protocol_data(pc);
 
@@ -650,7 +651,7 @@ jabber_recv_cb_ssl(gpointer data, Purple
 	static char buf[4096];
 
 	/* TODO: It should be possible to make this check unnecessary */
-	if(!PURPLE_CONNECTION_IS_VALID(gc)) {
+	if(!PURPLE_IS_CONNECTION(gc)) {
 		purple_ssl_close(gsc);
 		g_return_if_reached();
 	}
@@ -687,7 +688,7 @@ jabber_recv_cb(gpointer data, gint sourc
 	int len;
 	static char buf[4096];
 
-	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
+	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 
 	if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
 		purple_connection_update_last_received(gc);
@@ -745,7 +746,7 @@ jabber_login_callback_ssl(gpointer data,
 	JabberStream *js;
 
 	/* TODO: It should be possible to make this check unnecessary */
-	if(!PURPLE_CONNECTION_IS_VALID(gc)) {
+	if(!PURPLE_IS_CONNECTION(gc)) {
 		purple_ssl_close(gsc);
 		g_return_if_reached();
 	}
@@ -841,7 +842,7 @@ jabber_ssl_connect_failure(PurpleSslConn
 	JabberStream *js;
 
 	/* If the connection is already disconnected, we don't need to do anything else */
-	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
+	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 
 	js = purple_connection_get_protocol_data(gc);
 	js->gsc = NULL;
@@ -1127,7 +1128,7 @@ conn_close_cb(gpointer data)
 static void
 jabber_connection_schedule_close(JabberStream *js)
 {
-	purple_timeout_add(0, conn_close_cb, js);
+	conn_close_timeout = purple_timeout_add(0, conn_close_cb, js);
 }
 
 static void
@@ -1695,6 +1696,8 @@ void jabber_close(PurpleConnection *gc)
 		purple_timeout_remove(js->keepalive_timeout);
 	if (js->inactivity_timer != 0)
 		purple_timeout_remove(js->inactivity_timer);
+	if (conn_close_timeout != 0)
+		purple_timeout_remove(conn_close_timeout);
 
 	g_free(js->srv_rec);
 	js->srv_rec = NULL;
diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
--- a/libpurple/protocols/jabber/presence.c



More information about the Commits mailing list