/soc/2013/ankitkv/gobjectification: 68c776e3436e: Refactored pid...

Ankit Vani a at nevitus.org
Thu Jun 27 16:12:44 EDT 2013


Changeset: 68c776e3436e26f97e88a93799e8949210be893b
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-28 01:42 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/68c776e3436e

Description:

Refactored pidgin plugins to use the GObject conversation API

diffstat:

 pidgin/gtkconv.c                               |   4 ++--
 pidgin/plugins/convcolors.c                    |   6 ++----
 pidgin/plugins/extplacement.c                  |   2 +-
 pidgin/plugins/gestures/gestures.c             |   2 +-
 pidgin/plugins/history.c                       |   6 ++----
 pidgin/plugins/markerline.c                    |  11 ++++-------
 pidgin/plugins/musicmessaging/musicmessaging.c |  10 ++++++----
 pidgin/plugins/notify.c                        |  18 +++++++++---------
 pidgin/plugins/ticker/ticker.c                 |   7 +++----
 9 files changed, 30 insertions(+), 36 deletions(-)

diffs (247 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -10645,7 +10645,7 @@ pidgin_conv_window_last_im(void)
 
 			conv = convs->data;
 
-			if (PURPLE_IS_IM_CONVERSATION(conv->active_conv) == type)
+			if (PURPLE_IS_IM_CONVERSATION(conv->active_conv))
 				return win;
 		}
 	}
@@ -10696,7 +10696,7 @@ pidgin_conv_window_last_chat(void)
 
 			conv = convs->data;
 
-			if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv) == type)
+			if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv))
 				return win;
 		}
 	}
diff --git a/pidgin/plugins/convcolors.c b/pidgin/plugins/convcolors.c
--- a/pidgin/plugins/convcolors.c
+++ b/pidgin/plugins/convcolors.c
@@ -113,10 +113,8 @@ displaying_msg(PurpleAccount *account, c
 	g_snprintf(tmp, sizeof(tmp), "%s/enabled", formats[i].prefix);
 
 	if (!purple_prefs_get_bool(tmp) ||
-			(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM &&
-			!purple_prefs_get_bool(PREF_IMS)) ||
-			(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT &&
-			!purple_prefs_get_bool(PREF_CHATS)))
+			(PURPLE_IS_IM_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_IMS)) ||
+			(PURPLE_IS_CHAT_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_CHATS)))
 		return FALSE;
 
 	g_snprintf(tmp, sizeof(tmp), "%s/color", formats[i].prefix);
diff --git a/pidgin/plugins/extplacement.c b/pidgin/plugins/extplacement.c
--- a/pidgin/plugins/extplacement.c
+++ b/pidgin/plugins/extplacement.c
@@ -58,7 +58,7 @@ conv_placement_by_number(PidginConversat
 				win = l->data;
 
 				if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
-					purple_conversation_get_type(pidgin_conv_window_get_active_conversation(win)) != purple_conversation_get_type(conv->active_conv))
+					PURPLE_IS_IM_CONVERSATION(pidgin_conv_window_get_active_conversation(win)) != PURPLE_IS_IM_CONVERSATION(conv->active_conv))
 					continue;
 
 				count = pidgin_conv_window_get_gtkconv_count(win);
diff --git a/pidgin/plugins/gestures/gestures.c b/pidgin/plugins/gestures/gestures.c
--- a/pidgin/plugins/gestures/gestures.c
+++ b/pidgin/plugins/gestures/gestures.c
@@ -49,7 +49,7 @@ stroke_close(GtkWidget *widget, void *da
 	gtkconv = PIDGIN_CONVERSATION(conv);
 
 	gstroke_cleanup(gtkconv->webview);
-	purple_conversation_destroy(conv);
+	g_object_unref(conv);
 }
 
 static void
diff --git a/pidgin/plugins/history.c b/pidgin/plugins/history.c
--- a/pidgin/plugins/history.c
+++ b/pidgin/plugins/history.c
@@ -34,7 +34,6 @@ static void historize(PurpleConversation
 {
 	PurpleAccount *account = purple_conversation_get_account(c);
 	const char *name = purple_conversation_get_name(c);
-	PurpleConversationType convtype;
 	GList *logs = NULL;
 	const char *alias = name;
 	guint flags;
@@ -52,13 +51,12 @@ static void historize(PurpleConversation
 	char *escaped_alias;
 	const char *header_date;
 
-	convtype = purple_conversation_get_type(c);
 	gtkconv = PIDGIN_CONVERSATION(c);
 	g_return_if_fail(gtkconv != NULL);
 
 	/* An IM which is the first active conversation. */
 	g_return_if_fail(gtkconv->convs != NULL);
-	if (convtype == PURPLE_CONV_TYPE_IM && !gtkconv->convs->next)
+	if (PURPLE_IS_IM_CONVERSATION(c) && !gtkconv->convs->next)
 	{
 		GSList *buddies;
 		GSList *cur;
@@ -108,7 +106,7 @@ static void historize(PurpleConversation
 		else
 			logs = g_list_sort(logs, purple_log_compare);
 	}
-	else if (convtype == PURPLE_CONV_TYPE_CHAT)
+	else if (PURPLE_IS_CHAT_CONVERSATION(c))
 	{
 		/* If we're not logging, don't show anything.
 		 * Otherwise, we might show a very old log. */
diff --git a/pidgin/plugins/markerline.c b/pidgin/plugins/markerline.c
--- a/pidgin/plugins/markerline.c
+++ b/pidgin/plugins/markerline.c
@@ -45,15 +45,13 @@ static void
 update_marker_for_gtkconv(PidginConversation *gtkconv)
 {
 	PurpleConversation *conv;
-	PurpleConversationType type;
 
 	g_return_if_fail(gtkconv != NULL);
 
 	conv = gtkconv->active_conv;
-	type = purple_conversation_get_type(conv);
 
-	if ((type == PURPLE_CONV_TYPE_CHAT && !purple_prefs_get_bool(PREF_CHATS)) ||
-	    (type == PURPLE_CONV_TYPE_IM && !purple_prefs_get_bool(PREF_IMS)))
+	if ((PURPLE_IS_CHAT_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_CHATS)) ||
+	    (PURPLE_IS_IM_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_IMS)))
 		return;
 
 	gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview),
@@ -166,9 +164,8 @@ jump_to_markerline(PurpleConversation *c
 static void
 conv_menu_cb(PurpleConversation *conv, GList **list)
 {
-	PurpleConversationType type = purple_conversation_get_type(conv);
-	gboolean enabled = ((type == PURPLE_CONV_TYPE_IM && purple_prefs_get_bool(PREF_IMS)) ||
-		(type == PURPLE_CONV_TYPE_CHAT && purple_prefs_get_bool(PREF_CHATS)));
+	gboolean enabled = ((PURPLE_IS_IM_CONVERSATION(conv) && purple_prefs_get_bool(PREF_IMS)) ||
+		(PURPLE_IS_CHAT_CONVERSATION(conv) && purple_prefs_get_bool(PREF_CHATS)));
 	PurpleMenuAction *action = purple_menu_action_new(_("Jump to markerline"),
 			enabled ? PURPLE_CALLBACK(jump_to_markerline) : NULL, NULL, NULL);
 	*list = g_list_append(*list, action);
diff --git a/pidgin/plugins/musicmessaging/musicmessaging.c b/pidgin/plugins/musicmessaging/musicmessaging.c
--- a/pidgin/plugins/musicmessaging/musicmessaging.c
+++ b/pidgin/plugins/musicmessaging/musicmessaging.c
@@ -111,7 +111,7 @@ void music_messaging_change_request(cons
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## request %s %s##MM##", command, parameters);
 
-			purple_im_conversation_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
+			purple_conversation_send(mmconv->conv, to_send->str);
 
 			purple_debug_misc("musicmessaging", "Sent request: %s\n", to_send->str);
 		}
@@ -131,7 +131,7 @@ void music_messaging_change_confirmed(co
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## confirm %s %s##MM##", command, parameters);
 
-			purple_im_conversation_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
+			purple_conversation_send(mmconv->conv, to_send->str);
 		} else
 		{
 			/* Do nothing. If they aren't the originator, then they can't confirm. */
@@ -154,7 +154,7 @@ void music_messaging_change_failed(const
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## failed %s %s %s##MM##", id, command, parameters);
 
-			purple_im_conversation_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
+			purple_conversation_send(mmconv->conv, to_send->str);
 		} else
 		{
 			/* Do nothing. If they aren't the originator, then they can't confirm. */
@@ -261,6 +261,7 @@ mmconv_from_conv(PurpleConversation *con
 static gboolean
 plugin_load(PurplePlugin *plugin) {
 	void *conv_list_handle;
+	GList *l;
 
 	PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin);
 
@@ -273,7 +274,8 @@ plugin_load(PurplePlugin *plugin) {
 	plugin_pointer = plugin;
 
 	/* Add the button to all the current conversations */
-	purple_conversation_foreach (init_conversation);
+	for (l = purple_conversations_get_all(); l != NULL; l = l->next)
+		init_conversation((PurpleConversation *)l->data);
 
 	/* Listen for any new conversations */
 	conv_list_handle = purple_conversations_get_handle();
diff --git a/pidgin/plugins/notify.c b/pidgin/plugins/notify.c
--- a/pidgin/plugins/notify.c
+++ b/pidgin/plugins/notify.c
@@ -173,9 +173,9 @@ notify(PurpleConversation *conv, gboolea
 	purplewin = PIDGIN_CONVERSATION(conv)->win;
 
 	/* If we aren't doing notifications for this type of conversation, return */
-	if (((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) &&
+	if ((PURPLE_IS_IM_CONVERSATION(conv) &&
 	     !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) ||
-	    ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) &&
+	    (PURPLE_IS_CHAT_CONVERSATION(conv) &&
 	     !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat")))
 		return 0;
 
@@ -260,7 +260,7 @@ static gboolean
 message_displayed_cb(PurpleAccount *account, const char *who, char *message,
                      PurpleConversation *conv, PurpleMessageFlags flags)
 {
-	if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT &&
+	if ((PURPLE_IS_CHAT_CONVERSATION(conv) &&
 	     purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick") &&
 	     !(flags & PURPLE_MESSAGE_NICK)))
 	    return FALSE;
@@ -274,22 +274,22 @@ message_displayed_cb(PurpleAccount *acco
 static void
 im_sent_im(PurpleAccount *account, const char *receiver, const char *message)
 {
-	PurpleConversation *conv = NULL;
+	PurpleIMConversation *im = NULL;
 
 	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) {
-		conv = purple_conversations_find_im_with_account(receiver, account);
-		unnotify(conv, TRUE);
+		im = purple_conversations_find_im_with_account(receiver, account);
+		unnotify(PURPLE_CONVERSATION(im), TRUE);
 	}
 }
 
 static void
 chat_sent_im(PurpleAccount *account, const char *message, int id)
 {
-	PurpleConversation *conv = NULL;
+	PurpleChatConversation *chat = NULL;
 
 	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) {
-		conv = purple_conversations_find_chat(purple_account_get_connection(account), id);
-		unnotify(conv, TRUE);
+		chat = purple_conversations_find_chat(purple_account_get_connection(account), id);
+		unnotify(PURPLE_CONVERSATION(chat), TRUE);
 	}
 }
 
diff --git a/pidgin/plugins/ticker/ticker.c b/pidgin/plugins/ticker/ticker.c
--- a/pidgin/plugins/ticker/ticker.c
+++ b/pidgin/plugins/ticker/ticker.c
@@ -92,10 +92,9 @@ static gboolean buddy_click_cb(GtkWidget
 	PurpleContact *contact = user_data;
 	PurpleBuddy *b = purple_contact_get_priority_buddy(contact);
 
-	PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
-	                                purple_buddy_get_account(b),
-	                                purple_buddy_get_name(b));
-	purple_conversation_present(conv);
+	PurpleIMConversation *im = purple_im_conversation_new(purple_buddy_get_account(b),
+			purple_buddy_get_name(b));
+	purple_conversation_present(PURPLE_CONVERSATION(im));
 	return TRUE;
 }
 



More information about the Commits mailing list