/soc/2013/ankitkv/gobjectification: 826c1611ef90: Refactored pro...

Ankit Vani a at nevitus.org
Thu Jul 11 12:30:05 EDT 2013


Changeset: 826c1611ef9034e2c8812eeda62955ffad2b7e0e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-11 21:59 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/826c1611ef90

Description:

Refactored protocols to use the initial GObject connection API.
* Renamed PurpleConnection's private member buddy_chats to active_chats
* Added purple_connection_get_active_chats()
* Disabled bits of jabber protocol that use members of connection in a way it shouldn't
  I will have to revisit these to find proper alternatives.

diffstat:

 libpurple/connection.c                      |   2 +-
 libpurple/connection.h                      |   9 +++++++++
 libpurple/plugins/perl/common/Connection.xs |  10 ++++++++++
 libpurple/protocols/irc/msgs.c              |   5 +++--
 libpurple/protocols/jabber/jabber.c         |   3 +++
 libpurple/protocols/jabber/parser.c         |   3 +++
 6 files changed, 29 insertions(+), 3 deletions(-)

diffs (101 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -60,7 +60,7 @@ struct _PurpleConnectionPrivate
 	PurpleAccount *account;       /**< The account being connected to.   */
 	char *password;               /**< The password used.                */
 
-	GSList *buddy_chats;          /**< A list of active chats
+	GSList *active_chats;         /**< A list of active chats
 	                                  (#PurpleChatConversation structs). */
 	void *proto_data;             /**< Protocol-specific data.            
 	                                  TODO Remove this, and use
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -362,6 +362,15 @@ PurplePlugin * purple_connection_get_prp
 const char *purple_connection_get_password(const PurpleConnection *gc);
 
 /**
+ * Returns a list of active chat conversations on a connection.
+ *
+ * @param gc The connection.
+ *
+ * @return The active chats on the connection.
+ */
+GSList *purple_connection_get_active_chats(const PurpleConnection *gc);
+
+/**
  * Returns the connection's displayed name.
  *
  * @param gc The connection.
diff --git a/libpurple/plugins/perl/common/Connection.xs b/libpurple/plugins/perl/common/Connection.xs
--- a/libpurple/plugins/perl/common/Connection.xs
+++ b/libpurple/plugins/perl/common/Connection.xs
@@ -26,6 +26,16 @@ const char *
 purple_connection_get_password(gc)
 	Purple::Connection gc
 
+void
+purple_connection_get_active_chats(gc)
+	Purple::Connection gc
+PREINIT:
+	GSList *l;
+PPCODE:
+	for (l = purple_connection_get_active_chats(gc); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ChatConversation")));
+	}
+
 const char *
 purple_connection_get_display_name(gc)
 	Purple::Connection gc
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -1130,7 +1130,7 @@ void irc_msg_nick(struct irc_conn *irc, 
 		g_free(nick);
 		return;
 	}
-	chats = gc->buddy_chats;
+	chats = purple_connection_get_active_chats(gc);
 
 	if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
 		purple_connection_set_display_name(gc, args[0]);
@@ -1400,7 +1400,8 @@ void irc_msg_quit(struct irc_conn *irc, 
 	data[0] = irc_mask_nick(from);
 	data[1] = args[0];
 	/* XXX this should have an API, I shouldn't grab this directly */
-	g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data);
+	g_slist_foreach(purple_connection_get_active_chats(gc),
+			(GFunc)irc_chat_remove_buddy, data);
 
 	if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) {
 		ib->new_online_status = FALSE;
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
@@ -1377,7 +1377,10 @@ void jabber_register_parse(JabberStream 
 				g_free(href);
 
 				if(js->registration) {
+#warning Is this (gc->wants_to_die) required here? If so, an alternative needed.
+#if 0
 					js->gc->wants_to_die = TRUE;
+#endif
 					/* succeeded, but we have no login info */
 					purple_account_register_completed(account, TRUE);
 					jabber_connection_schedule_close(js);
diff --git a/libpurple/protocols/jabber/parser.c b/libpurple/protocols/jabber/parser.c
--- a/libpurple/protocols/jabber/parser.c
+++ b/libpurple/protocols/jabber/parser.c
@@ -308,7 +308,10 @@ void jabber_parser_process(JabberStream 
 	}
 
 	if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 &&
+#warning Is this (gc->disconnect_timeout) required here? If so, an alternative is needed.
+#if 0
 			!js->gc->disconnect_timeout &&
+#endif
 			(js->state == JABBER_STREAM_INITIALIZING ||
 			 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) {
 		/*



More information about the Commits mailing list