/soc/2013/ankitkv/gobjectification: 45425605f156: Merged soc.201...

Ankit Vani a at nevitus.org
Fri Sep 6 12:15:32 EDT 2013


Changeset: 45425605f156bb11132f00ed72e519e3ebfa9592
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-06 21:45 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/45425605f156

Description:

Merged soc.2013.gobjectification branch

diffstat:

 finch/gntroomlist.c                       |    6 +-
 libpurple/Makefile.am                     |    1 +
 libpurple/plugins/perl/common/Roomlist.xs |    8 -
 libpurple/protocols/irc/irc.c             |    4 +-
 libpurple/protocols/irc/msgs.c            |    2 +-
 libpurple/protocols/jabber/chat.c         |   12 +-
 libpurple/protocols/silc/chat.c           |    4 +-
 libpurple/protocols/silc/ops.c            |    6 +-
 libpurple/protocols/yahoo/yahoochat.c     |    6 +-
 libpurple/roomlist.c                      |  461 ++++++++++++++++++++++-------
 libpurple/roomlist.h                      |   76 +++-
 pidgin/gtkroomlist.c                      |   14 +-
 12 files changed, 428 insertions(+), 172 deletions(-)

diffs (truncated from 1048 to 300 lines):

diff --git a/finch/gntroomlist.c b/finch/gntroomlist.c
--- a/finch/gntroomlist.c
+++ b/finch/gntroomlist.c
@@ -68,7 +68,7 @@ unset_roomlist(gpointer null)
 {
 	froomlist.window = NULL;
 	if (froomlist.roomlist) {
-		purple_roomlist_unref(froomlist.roomlist);
+		g_object_unref(froomlist.roomlist);
 		froomlist.roomlist = NULL;
 	}
 	froomlist.account = NULL;
@@ -82,10 +82,10 @@ update_roomlist(PurpleRoomlist *list)
 		return;
 
 	if (froomlist.roomlist)
-		purple_roomlist_unref(froomlist.roomlist);
+		g_object_unref(froomlist.roomlist);
 
 	if ((froomlist.roomlist = list) != NULL)
-		purple_roomlist_ref(list);
+		g_object_ref(list);
 }
 
 static void fl_stop(GntWidget *button, gpointer null)
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -197,6 +197,7 @@ purple_enumheaders = \
 	plugins.h \
 	protocol.h \
 	protocols.h \
+	roomlist.h \
 	status.h \
 	xfer.h
 
diff --git a/libpurple/plugins/perl/common/Roomlist.xs b/libpurple/plugins/perl/common/Roomlist.xs
--- a/libpurple/plugins/perl/common/Roomlist.xs
+++ b/libpurple/plugins/perl/common/Roomlist.xs
@@ -50,10 +50,6 @@ purple_roomlist_new(account)
 	Purple::Account account
 
 void 
-purple_roomlist_ref(list)
-	Purple::Roomlist list
-
-void 
 purple_roomlist_room_add(list, room)
 	Purple::Roomlist list
 	Purple::Roomlist::Room room
@@ -94,7 +90,3 @@ void
 purple_roomlist_show_with_account(account)
 	Purple::Account account
 
-void 
-purple_roomlist_unref(list)
-	Purple::Roomlist list
-
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -867,7 +867,7 @@ static PurpleRoomlist *irc_roomlist_get_
 	irc = purple_connection_get_protocol_data(gc);
 
 	if (irc->roomlist)
-		purple_roomlist_unref(irc->roomlist);
+		g_object_unref(irc->roomlist);
 
 	irc->roomlist = purple_roomlist_new(purple_connection_get_account(gc));
 
@@ -904,7 +904,7 @@ static void irc_roomlist_cancel(PurpleRo
 
 	if (irc->roomlist == list) {
 		irc->roomlist = NULL;
-		purple_roomlist_unref(list);
+		g_object_unref(list);
 	}
 }
 
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
@@ -540,7 +540,7 @@ void irc_msg_list(struct irc_conn *irc, 
 
 	if (!strcmp(name, "323")) {
 		purple_roomlist_set_in_progress(irc->roomlist, FALSE);
-		purple_roomlist_unref(irc->roomlist);
+		g_object_unref(irc->roomlist);
 		irc->roomlist = NULL;
 		return;
 	}
diff --git a/libpurple/protocols/jabber/chat.c b/libpurple/protocols/jabber/chat.c
--- a/libpurple/protocols/jabber/chat.c
+++ b/libpurple/protocols/jabber/chat.c
@@ -811,7 +811,7 @@ static void roomlist_disco_result_cb(Jab
 		purple_notify_error(js->gc, _("Error"),
 				_("Error retrieving room list"), err);
 		purple_roomlist_set_in_progress(js->roomlist, FALSE);
-		purple_roomlist_unref(js->roomlist);
+		g_object_unref(js->roomlist);
 		js->roomlist = NULL;
 		g_free(err);
 		return;
@@ -822,7 +822,7 @@ static void roomlist_disco_result_cb(Jab
 		purple_notify_error(js->gc, _("Error"),
 				_("Error retrieving room list"), err);
 		purple_roomlist_set_in_progress(js->roomlist, FALSE);
-		purple_roomlist_unref(js->roomlist);
+		g_object_unref(js->roomlist);
 		js->roomlist = NULL;
 		g_free(err);
 		return;
@@ -848,14 +848,14 @@ static void roomlist_disco_result_cb(Jab
 		jabber_id_free(jid);
 	}
 	purple_roomlist_set_in_progress(js->roomlist, FALSE);
-	purple_roomlist_unref(js->roomlist);
+	g_object_unref(js->roomlist);
 	js->roomlist = NULL;
 }
 
 static void roomlist_cancel_cb(JabberStream *js, const char *server) {
 	if(js->roomlist) {
 		purple_roomlist_set_in_progress(js->roomlist, FALSE);
-		purple_roomlist_unref(js->roomlist);
+		g_object_unref(js->roomlist);
 		js->roomlist = NULL;
 	}
 }
@@ -897,7 +897,7 @@ PurpleRoomlist *jabber_roomlist_get_list
 	PurpleRoomlistField *f;
 
 	if(js->roomlist)
-		purple_roomlist_unref(js->roomlist);
+		g_object_unref(js->roomlist);
 
 	js->roomlist = purple_roomlist_new(purple_connection_get_account(js->gc));
 
@@ -939,7 +939,7 @@ void jabber_roomlist_cancel(PurpleRoomli
 
 	if (js->roomlist == list) {
 		js->roomlist = NULL;
-		purple_roomlist_unref(list);
+		g_object_unref(list);
 	}
 }
 
diff --git a/libpurple/protocols/silc/chat.c b/libpurple/protocols/silc/chat.c
--- a/libpurple/protocols/silc/chat.c
+++ b/libpurple/protocols/silc/chat.c
@@ -1394,7 +1394,7 @@ PurpleRoomlist *silcpurple_roomlist_get_
 		return NULL;
 
 	if (sg->roomlist)
-		purple_roomlist_unref(sg->roomlist);
+		g_object_unref(sg->roomlist);
 
 	sg->roomlist_cancelled = FALSE;
 
@@ -1429,7 +1429,7 @@ void silcpurple_roomlist_cancel(PurpleRo
 
 	purple_roomlist_set_in_progress(list, FALSE);
 	if (sg->roomlist == list) {
-		purple_roomlist_unref(sg->roomlist);
+		g_object_unref(sg->roomlist);
 		sg->roomlist = NULL;
 		sg->roomlist_cancelled = TRUE;
 	}
diff --git a/libpurple/protocols/silc/ops.c b/libpurple/protocols/silc/ops.c
--- a/libpurple/protocols/silc/ops.c
+++ b/libpurple/protocols/silc/ops.c
@@ -1479,7 +1479,7 @@ silc_command_reply(SilcClient client, Si
 				purple_notify_error(gc, _("Error"), _("Error retrieving room list"),
 						    silc_get_status_message(error));
 				purple_roomlist_set_in_progress(sg->roomlist, FALSE);
-				purple_roomlist_unref(sg->roomlist);
+				g_object_unref(sg->roomlist);
 				sg->roomlist = NULL;
 				return;
 			}
@@ -1490,7 +1490,7 @@ silc_command_reply(SilcClient client, Si
 				purple_notify_error(gc, _("Roomlist"), _("Cannot get room list"),
 						    _("Network is empty"));
 				purple_roomlist_set_in_progress(sg->roomlist, FALSE);
-				purple_roomlist_unref(sg->roomlist);
+				g_object_unref(sg->roomlist);
 				sg->roomlist = NULL;
 				return;
 			}
@@ -1508,7 +1508,7 @@ silc_command_reply(SilcClient client, Si
 			if (status == SILC_STATUS_LIST_END ||
 			    status == SILC_STATUS_OK) {
 				purple_roomlist_set_in_progress(sg->roomlist, FALSE);
-				purple_roomlist_unref(sg->roomlist);
+				g_object_unref(sg->roomlist);
 				sg->roomlist = NULL;
 			}
 		}
diff --git a/libpurple/protocols/yahoo/yahoochat.c b/libpurple/protocols/yahoo/yahoochat.c
--- a/libpurple/protocols/yahoo/yahoochat.c
+++ b/libpurple/protocols/yahoo/yahoochat.c
@@ -1368,7 +1368,7 @@ static void yahoo_roomlist_cleanup(Purpl
 		yahoo_roomlist_destroy(yrl);
 	}
 
-	purple_roomlist_unref(list);
+	g_object_unref(list);
 }
 
 static void
@@ -1502,7 +1502,7 @@ void yahoo_roomlist_cancel(PurpleRoomlis
 
 	for (; l; l = l->next) {
 		yahoo_roomlist_destroy(l->data);
-		purple_roomlist_unref(list);
+		g_object_unref(list);
 	}
 	g_list_free(k);
 }
@@ -1553,5 +1553,5 @@ void yahoo_roomlist_expand_category(Purp
 
 	yahoo_roomlist_make_request(yrl);
 	purple_roomlist_set_in_progress(list, TRUE);
-	purple_roomlist_ref(list);
+	g_object_ref(list);
 }
diff --git a/libpurple/roomlist.c b/libpurple/roomlist.c
--- a/libpurple/roomlist.c
+++ b/libpurple/roomlist.c
@@ -2,7 +2,6 @@
  * @file roomlist.c Room List API
  * @ingroup core
  */
-
 /* purple
  *
  * Purple is the legal property of its developers, whose names are too numerous
@@ -32,17 +31,23 @@
 #include "roomlist.h"
 #include "server.h"
 
+#define PURPLE_ROOMLIST_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_ROOMLIST, PurpleRoomlistPrivate))
+
+/** @copydoc _PurpleRoomlistPrivate */
+typedef struct _PurpleRoomlistPrivate  PurpleRoomlistPrivate;
+
 /**
- * Represents a list of rooms for a given connection on a given protocol.
+ * Private data for a room list.
  */
-struct _PurpleRoomlist {
-	PurpleAccount *account; /**< The account this list belongs to. */
-	GList *fields; /**< The fields. */
-	GList *rooms; /**< The list of rooms. */
-	gboolean in_progress; /**< The listing is in progress. */
-	gpointer ui_data; /**< UI private data. */
-	gpointer proto_data; /** Protocol private data. */
-	guint ref; /**< The reference count. */
+struct _PurpleRoomlistPrivate {
+	PurpleAccount *account;  /**< The account this list belongs to. */
+	GList *fields;           /**< The fields.                       */
+	GList *rooms;            /**< The list of rooms.                */
+	gboolean in_progress;    /**< The listing is in progress.       */
+	gpointer proto_data;     /** Protocol private data.
+	                             TODO Remove this, and use
+	                                  protocol-specific subclasses  */
 };
 
 /**
@@ -66,8 +71,22 @@ struct _PurpleRoomlistField {
 	gboolean hidden; /**< Hidden? */
 };
 
+/* Room list property enums */
+enum
+{
+	PROP_0,
+	PROP_ACCOUNT,
+	PROP_FIELDS,
+	PROP_IN_PROGRESS,
+	PROP_LAST
+};
+
+static GObjectClass *parent_class;
 static PurpleRoomlistUiOps *ops = NULL;
 
+static void purple_roomlist_field_free(PurpleRoomlistField *f);
+static void purple_roomlist_room_destroy(PurpleRoomlist *list, PurpleRoomlistRoom *r);
+
 /**************************************************************************/
 /** @name Room List API                                                   */
 /**************************************************************************/
@@ -79,99 +98,22 @@ void purple_roomlist_show_with_account(P
 		ops->show_with_account(account);
 }
 
-PurpleRoomlist *purple_roomlist_new(PurpleAccount *account)
-{
-	PurpleRoomlist *list;



More information about the Commits mailing list