/soc/2013/ankitkv/gobjectification: adbcbe04077c: Refactored rem...

Ankit Vani a at nevitus.org
Wed Jun 26 19:27:54 EDT 2013


Changeset: adbcbe04077c25f43a7e5e892a0924bc8490aed5
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-27 04:44 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/adbcbe04077c

Description:

Refactored remaining libpurple to use the GObject conversation API

diffstat:

 libpurple/Makefile.am                         |    8 +-
 libpurple/account.c                           |    2 +-
 libpurple/accounts.c                          |    2 +-
 libpurple/conversation.c                      |    2 +-
 libpurple/conversation.h                      |    3 -
 libpurple/dbus-analyze-functions.py           |   18 ++--
 libpurple/dbus-define-api.h                   |    5 -
 libpurple/ft.c                                |   22 ++--
 libpurple/plugins/perl/common/Conversation.xs |    8 +-
 libpurple/pounce.c                            |    8 +-
 libpurple/prpl.c                              |    8 +-
 libpurple/server.c                            |  105 ++++++++++---------------
 12 files changed, 83 insertions(+), 108 deletions(-)

diffs (truncated from 551 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -233,9 +233,11 @@ CLEANFILES = \
 dbus_sources  = dbus-server.c dbus-useful.c
 dbus_headers  = dbus-bindings.h dbus-purple.h dbus-server.h dbus-useful.h dbus-define-api.h dbus-types.h
 
-dbus_exported = dbus-useful.h dbus-define-api.h accounts.h blist.h buddyicon.h \
-                connection.h conversations.h core.h ft.h log.h notify.h prefs.h roomlist.h \
-                savedstatuses.h smiley.h status.h server.h util.h xmlnode.h prpl.h
+dbus_exported = dbus-useful.h dbus-define-api.h account.h accounts.h blist.h \
+                buddyicon.h connection.h conversation.h conversationtypes.h \
+                conversations.h core.h ft.h log.h notify.h prefs.h roomlist.h \
+                savedstatuses.h smiley.h status.h server.h util.h xmlnode.h \
+                prpl.h
 
 purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \
 		$(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -2894,7 +2894,7 @@ purple_account_dispose(GObject *object)
 	purple_signal_emit(purple_accounts_get_handle(), "account-destroying",
 						account);
 
-	for (l = purple_conversations_get(); l != NULL; l = l->next)
+	for (l = purple_conversations_get_all(); l != NULL; l = l->next)
 	{
 		PurpleConversation *conv = (PurpleConversation *)l->data;
 
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -697,7 +697,7 @@ purple_accounts_delete(PurpleAccount *ac
 	}
 
 	/* Remove any open conversation for this account */
-	for (iter = purple_conversations_get(); iter; ) {
+	for (iter = purple_conversations_get_all(); iter; ) {
 		PurpleConversation *conv = iter->data;
 		iter = iter->next;
 		if (purple_conversation_get_account(conv) == account)
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -534,7 +534,7 @@ purple_conversation_write(PurpleConversa
 		return;
 
 	if (PURPLE_IS_IM_CONVERSATION(conv) &&
-		!g_list_find(purple_conversations_get(), conv))
+		!g_list_find(purple_conversations_get_all(), conv))
 		return;
 
 	displayed = g_strdup(message);
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -149,9 +149,6 @@ struct _PurpleConversationClass {
 /**************************************************************************/
 /** PurpleConversationUiOps                                               */
 /**************************************************************************/
-typedef struct _PurpleIMConversation         PurpleIMConversation;
-typedef struct _PurpleChatConversation       PurpleChatConversation;
-typedef struct _PurpleChatConversationBuddy  PurpleChatConversationBuddy;
 /**
  * Conversation operations and events.
  *
diff --git a/libpurple/dbus-analyze-functions.py b/libpurple/dbus-analyze-functions.py
--- a/libpurple/dbus-analyze-functions.py
+++ b/libpurple/dbus-analyze-functions.py
@@ -22,10 +22,10 @@ excluded = [\
     # functions with untranslatable types are skipped, but this script
     # assumes that all non-pointer type names beginning with "Purple"
     # are enums, which is not true in this case.
-    "purple_conv_placement_add_fnc",
-    "purple_conv_placement_get_fnc",
-    "purple_conv_placement_get_current_func",
-    "purple_conv_placement_set_current_func",
+    "purple_conversation_placement_add_fnc",
+    "purple_conversation_placement_get_fnc",
+    "purple_conversation_placement_get_current_func",
+    "purple_conversation_placement_set_current_func",
 
     # Similar to the above:
     "purple_account_set_register_callback",
@@ -70,11 +70,11 @@ constlists = [
     "purple_account_option_get_list",
     "purple_connections_get_all",
     "purple_connections_get_connecting",
-    "purple_get_conversations",
-    "purple_get_ims",
-    "purple_get_chats",
-    "purple_conv_chat_get_users",
-    "purple_conv_chat_get_ignored",
+    "purple_conversations_get_all",
+    "purple_conversations_get_ims",
+    "purple_conversations_get_chats",
+    "purple_chat_conversation_get_users",
+    "purple_chat_conversation_get_ignored",
     "purple_mime_document_get_fields",
     "purple_mime_document_get_parts",
     "purple_mime_part_get_fields",
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
@@ -18,8 +18,3 @@ gboolean PURPLE_BLIST_NODE_SHOULD_SAVE(P
 gboolean PURPLE_CONNECTION_IS_CONNECTED(PurpleConnection *connection);
 gboolean PURPLE_CONNECTION_IS_VALID(PurpleConnection *connection);
 
-/* conversation.h */
-PurpleIMConversation *PURPLE_CONV_IM(const PurpleConversation *conversation);
-PurpleIMConversation *PURPLE_CONV_CHAT(const PurpleConversation *conversation);
-
-
diff --git a/libpurple/ft.c b/libpurple/ft.c
--- a/libpurple/ft.c
+++ b/libpurple/ft.c
@@ -278,7 +278,7 @@ static void
 purple_xfer_conversation_write_internal(PurpleXfer *xfer,
 	const char *message, gboolean is_error, gboolean print_thumbnail)
 {
-	PurpleConversation *conv = NULL;
+	PurpleIMConversation *im = NULL;
 	PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
 	char *escaped;
 	gconstpointer thumbnail_data;
@@ -289,10 +289,10 @@ purple_xfer_conversation_write_internal(
 
 	thumbnail_data = purple_xfer_get_thumbnail(xfer, &size);
 
-	conv = purple_conversations_find_im_with_account(xfer->who,
+	im = purple_conversations_find_im_with_account(xfer->who,
 											   purple_xfer_get_account(xfer));
 
-	if (conv == NULL)
+	if (im == NULL)
 		return;
 
 	escaped = g_markup_escape_text(message, -1);
@@ -308,12 +308,13 @@ purple_xfer_conversation_write_internal(
 		message_with_img =
 			g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'> %s",
 			                id, escaped);
-		purple_conversation_write(conv, NULL, message_with_img, flags,
-			time(NULL));
+		purple_conversation_write(PURPLE_CONVERSATION(im), NULL,
+			message_with_img, flags, time(NULL));
 		purple_imgstore_unref_by_id(id);
 		g_free(message_with_img);
 	} else {
-		purple_conversation_write(conv, NULL, escaped, flags, time(NULL));
+		purple_conversation_write(PURPLE_CONVERSATION(im), NULL, escaped, flags,
+			time(NULL));
 	}
 	g_free(escaped);
 }
@@ -901,7 +902,7 @@ purple_xfer_set_completed(PurpleXfer *xf
 
 	if (completed == TRUE) {
 		char *msg = NULL;
-		PurpleConversation *conv;
+		PurpleIMConversation *im;
 
 		purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE);
 
@@ -924,11 +925,12 @@ purple_xfer_set_completed(PurpleXfer *xf
 		else
 			msg = g_strdup(_("File transfer complete"));
 
-		conv = purple_conversations_find_im_with_account(xfer->who,
+		im = purple_conversations_find_im_with_account(xfer->who,
 		                                             purple_xfer_get_account(xfer));
 
-		if (conv != NULL)
-			purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		if (im != NULL)
+			purple_conversation_write(PURPLE_CONVERSATION(im), NULL, msg,
+					PURPLE_MESSAGE_SYSTEM, time(NULL));
 		g_free(msg);
 	}
 
diff --git a/libpurple/plugins/perl/common/Conversation.xs b/libpurple/plugins/perl/common/Conversation.xs
--- a/libpurple/plugins/perl/common/Conversation.xs
+++ b/libpurple/plugins/perl/common/Conversation.xs
@@ -110,15 +110,15 @@ PREINIT:
 	GList *l;
 PPCODE:
 	for (l = purple_conversations_get_ims(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::IMConversation")));
 	}
 
 void
-purple_conversations_get()
+purple_conversations_get_all()
 PREINIT:
 	GList *l;
 PPCODE:
-	for (l = purple_conversations_get(); l != NULL; l = l->next) {
+	for (l = purple_conversations_get_all(); l != NULL; l = l->next) {
 		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
 	}
 
@@ -128,7 +128,7 @@ PREINIT:
 	GList *l;
 PPCODE:
 	for (l = purple_conversations_get_chats(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ChatConversation")));
 	}
 
 Purple::Conversation
diff --git a/libpurple/pounce.c b/libpurple/pounce.c
--- a/libpurple/pounce.c
+++ b/libpurple/pounce.c
@@ -1126,15 +1126,15 @@ buddy_idle_changed_cb(PurpleBuddy *buddy
 static void
 buddy_typing_cb(PurpleAccount *account, const char *name, void *data)
 {
-	PurpleConversation *conv;
+	PurpleIMConversation *im;
 
-	conv = purple_conversations_find_im_with_account(name, account);
-	if (conv != NULL)
+	im = purple_conversations_find_im_with_account(name, account);
+	if (im != NULL)
 	{
 		PurpleIMConversationTypingState state;
 		PurplePounceEvent event;
 
-		state = purple_im_conversation_get_typing_state(PURPLE_CONV_IM(conv));
+		state = purple_im_conversation_get_typing_state(im);
 		if (state == PURPLE_IM_CONVERSATION_TYPED)
 			event = PURPLE_POUNCE_TYPED;
 		else if (state == PURPLE_IM_CONVERSATION_NOT_TYPING)
diff --git a/libpurple/prpl.c b/libpurple/prpl.c
--- a/libpurple/prpl.c
+++ b/libpurple/prpl.c
@@ -437,7 +437,7 @@ purple_prpl_send_attention(PurpleConnect
 	PurpleAttentionType *attn;
 	PurpleMessageFlags flags;
 	PurplePlugin *prpl;
-	PurpleConversation *conv;
+	PurpleIMConversation *im;
 	gboolean (*send_attention)(PurpleConnection *, const char *, guint);
 	PurpleBuddy *buddy;
 	const char *alias;
@@ -474,9 +474,9 @@ purple_prpl_send_attention(PurpleConnect
 	if (!send_attention(gc, who, type_code))
 		return;
 
-	conv = purple_im_conversation_new(purple_connection_get_account(gc), who);
-	purple_im_conversation_write_message(PURPLE_CONV_IM(conv), NULL, description, flags, mtime);
-	purple_prpl_attention(conv, who, type_code, PURPLE_MESSAGE_SEND, time(NULL));
+	im = purple_im_conversation_new(purple_connection_get_account(gc), who);
+	purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, description, flags, mtime);
+	purple_prpl_attention(PURPLE_CONVERSATION(im), who, type_code, PURPLE_MESSAGE_SEND, time(NULL));
 
 	g_free(description);
 }
diff --git a/libpurple/server.c b/libpurple/server.c
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -119,7 +119,7 @@ get_last_auto_response(PurpleConnection 
 int serv_send_im(PurpleConnection *gc, const char *name, const char *message,
 				 PurpleMessageFlags flags)
 {
-	PurpleConversation *conv = NULL;
+	PurpleIMConversation *im = NULL;
 	PurpleAccount *account = NULL;
 	PurplePresence *presence = NULL;
 	PurplePlugin *prpl = NULL;
@@ -138,7 +138,7 @@ int serv_send_im(PurpleConnection *gc, c
 	account  = purple_connection_get_account(gc);
 	presence = purple_account_get_presence(account);
 
-	conv = purple_conversations_find_im_with_account(name, account);
+	im = purple_conversations_find_im_with_account(name, account);
 
 	if (prpl_info->send_im)
 		val = prpl_info->send_im(gc, name, message, flags);
@@ -157,8 +157,8 @@ int serv_send_im(PurpleConnection *gc, c
 		lar->sent = time(NULL);
 	}
 
-	if(conv && purple_im_conversation_get_send_typed_timeout(PURPLE_CONV_IM(conv)))
-		purple_im_conversation_stop_send_typed_timeout(PURPLE_CONV_IM(conv));
+	if(im && purple_im_conversation_get_send_typed_timeout(im))
+		purple_im_conversation_stop_send_typed_timeout(im);
 
 	return val;
 }
@@ -237,7 +237,7 @@ serv_got_alias(PurpleConnection *gc, con
 	PurpleAccount *account;
 	GSList *buddies;
 	PurpleBuddy *b;
-	PurpleConversation *conv;
+	PurpleIMConversation *im;
 
 	account = purple_connection_get_account(gc);



More information about the Commits mailing list