/soc/2013/ankitkv/gobjectification: f17f9d4e710e: Refactored pid...

Ankit Vani a at nevitus.org
Sat Sep 14 12:47:16 EDT 2013


Changeset: f17f9d4e710eae6d8a777f161792d3123f26804e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-14 22:16 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f17f9d4e710e

Description:

Refactored pidgin to use the new protocol API

diffstat:

 pidgin/gtkaccount.c        |  12 ++++++------
 pidgin/gtkblist.c          |  34 +++++++++++++++++-----------------
 pidgin/gtkconv.c           |  38 +++++++++++++++++++-------------------
 pidgin/gtkdocklet.c        |   6 +++---
 pidgin/gtkimhtmltoolbar.c  |   2 +-
 pidgin/gtkroomlist.c       |   4 ++--
 pidgin/gtkutils.c          |   7 ++-----
 pidgin/gtkwebviewtoolbar.c |   2 +-
 8 files changed, 51 insertions(+), 54 deletions(-)

diffs (truncated from 422 to 300 lines):

diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -255,7 +255,7 @@ set_account_protocol_cb(GtkWidget *widge
 
 	gtk_widget_grab_focus(dialog->protocol_menu);
 
-	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, register_user)) {
+	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, SERVER_IFACE, register_user)) {
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
 			dialog->register_button), FALSE);
 		gtk_widget_hide(dialog->register_button);
@@ -307,7 +307,7 @@ username_focus_cb(GtkWidget *widget, Gdk
 	const char *label;
 
 	if (!dialog->protocol || ! PURPLE_PROTOCOL_IMPLEMENTS(
-		dialog->protocol, get_account_text_table)) {
+		dialog->protocol, CLIENT_IFACE, get_account_text_table)) {
 		return FALSE;
 	}
 
@@ -334,7 +334,7 @@ username_nofocus_cb(GtkWidget *widget, G
 	GHashTable *table = NULL;
 	const char *label = NULL;
 
-	if(PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, get_account_text_table)) {
+	if(PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, CLIENT_IFACE, get_account_text_table)) {
 		table = purple_protocol_client_iface_get_account_text_table(dialog->protocol, NULL);
 		label = g_hash_table_lookup(table, "login_label");
 
@@ -626,7 +626,7 @@ add_login_options(AccountPrefsDialog *di
 		username = g_strdup(purple_account_get_username(dialog->account));
 
 	if (!username && dialog->protocol
-			&& PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, get_account_text_table)) {
+			&& PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, CLIENT_IFACE, get_account_text_table)) {
 		GHashTable *table;
 		const char *label;
 		table = purple_protocol_client_iface_get_account_text_table(dialog->protocol, NULL);
@@ -1326,7 +1326,7 @@ static void
 add_voice_options(AccountPrefsDialog *dialog)
 {
 #ifdef USE_VV
-	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, initiate_media)) {
+	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, MEDIA_IFACE, initiate_session)) {
 		if (dialog->voice_frame) {
 			gtk_widget_destroy(dialog->voice_frame);
 			dialog->voice_frame = NULL;
@@ -1786,7 +1786,7 @@ pidgin_account_dialog_show_continue(Purp
 	if (dialog->account == NULL)
 		gtk_widget_set_sensitive(button, FALSE);
 
-	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, register_user))
+	if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, SERVER_IFACE, register_user))
 		gtk_widget_hide(button);
 
 	/* Setup the page with 'Advanced' (protocol options). */
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -910,7 +910,7 @@ set_sensitive_if_input_chat_cb(GtkWidget
 
 	gc = purple_account_get_connection(data->rq_data.account);
 	protocol = (gc != NULL) ? purple_connection_get_protocol(gc) : NULL;
-	sensitive = (protocol != NULL && PURPLE_PROTOCOL_IMPLEMENTS(protocol, roomlist_get_list));
+	sensitive = (protocol != NULL && PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST_IFACE, get_list));
 
 	gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), 1, sensitive);
 }
@@ -950,7 +950,7 @@ chat_account_filter_func(PurpleAccount *
 
 	protocol = purple_connection_get_protocol(gc);
 
-	return (PURPLE_PROTOCOL_IMPLEMENTS(protocol, chat_info));
+	return (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, info));
 }
 
 gboolean
@@ -1422,7 +1422,7 @@ pidgin_append_blist_node_proto_menu(GtkW
 	GList *l, *ll;
 	PurpleProtocol *protocol = purple_connection_get_protocol(gc);
 
-	if(!protocol || !PURPLE_PROTOCOL_IMPLEMENTS(protocol, blist_node_menu))
+	if(!protocol || !PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, blist_node_menu))
 		return;
 
 	for(l = ll = purple_protocol_client_iface_blist_node_menu(protocol, node); l; l = l->next) {
@@ -1496,7 +1496,7 @@ pidgin_blist_make_buddy_menu(GtkWidget *
 		contact_expanded = node->contact_expanded;
 	}
 
-	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_info)) {
+	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info)) {
 		pidgin_new_item_from_stock(menu, _("Get _Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO,
 				G_CALLBACK(gtk_blist_menu_info_cb), buddy, 0, 0, NULL);
 	}
@@ -1504,7 +1504,7 @@ pidgin_blist_make_buddy_menu(GtkWidget *
 			G_CALLBACK(gtk_blist_menu_im_cb), buddy, 0, 0, NULL);
 
 #ifdef USE_VV
-	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_media_caps)) {
+	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, MEDIA_IFACE, get_caps)) {
 		PurpleAccount *account = purple_buddy_get_account(buddy);
 		const gchar *who = purple_buddy_get_name(buddy);
 		PurpleMediaCaps caps = purple_protocol_get_media_caps(account, who);
@@ -1526,8 +1526,8 @@ pidgin_blist_make_buddy_menu(GtkWidget *
 
 #endif
 
-	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, send_file)) {
-		if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, can_receive_file) ||
+	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send)) {
+		if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
 			purple_protocol_xfer_iface_can_receive(protocol,
 			purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)))
 		{
@@ -1971,7 +1971,7 @@ gtk_blist_button_press_cb(GtkWidget *tv,
 
 		protocol = purple_protocols_find(purple_account_get_protocol_id(purple_buddy_get_account(b)));
 
-		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_info))
+		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info))
 			pidgin_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(b)), purple_buddy_get_name(b));
 		handled = TRUE;
 	}
@@ -3624,7 +3624,7 @@ set_mood_cb(GtkWidget *widget, PurpleAcc
 
 	/* TODO: rlaager wants this sorted. */
 	/* TODO: darkrain wants it sorted post-translation */
-	if (account && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_moods))
+	if (account && PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, get_moods))
 		mood = purple_protocol_client_iface_get_moods(protocol, account);
 	else
 		mood = global_moods;
@@ -3823,7 +3823,7 @@ static char *pidgin_get_tooltip_text(Pur
 			conv = PURPLE_CHAT_CONVERSATION(bnode->conv.conv);
 		} else {
 			char *chat_name;
-			if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_chat_name))
+			if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, get_name))
 				chat_name = purple_protocol_chat_iface_get_name(protocol, purple_chat_get_components(chat));
 			else
 				chat_name = g_strdup(purple_chat_get_name(chat));
@@ -4363,7 +4363,7 @@ pidgin_blist_get_name_markup(PurpleBuddy
 		/* Status Info */
 		protocol = purple_protocols_find(purple_account_get_protocol_id(purple_buddy_get_account(b)));
 
-		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, status_text) &&
+		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, status_text) &&
 				purple_account_get_connection(purple_buddy_get_account(b))) {
 			char *tmp = purple_protocol_client_iface_status_text(protocol, b);
 			const char *end;
@@ -7412,7 +7412,7 @@ pidgin_blist_request_add_chat(PurpleAcco
 		gc = purple_account_get_connection(account);
 		protocol = purple_connection_get_protocol(gc);
 
-		if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, join_chat)) {
+		if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, join)) {
 			purple_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL);
 			return;
 		}
@@ -7422,7 +7422,7 @@ pidgin_blist_request_add_chat(PurpleAcco
 			gc = (PurpleConnection *)l->data;
 			protocol = purple_connection_get_protocol(gc);
 
-			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, join_chat)) {
+			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, join)) {
 				account = purple_connection_get_account(gc);
 				break;
 			}
@@ -8297,9 +8297,9 @@ pidgin_blist_update_accounts_menu(void)
 				purple_connection_get_protocol(gc) : NULL;
 
 		if (protocol &&
-		    (PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_moods) ||
-			 PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_actions))) {
-			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_moods) &&
+		    (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, get_moods) ||
+			 PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, get_actions))) {
+			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, get_moods) &&
 			    (purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_SUPPORT_MOODS)) {
 
 				if (purple_account_get_status(account, "mood")) {
@@ -8310,7 +8310,7 @@ pidgin_blist_update_accounts_menu(void)
 				}
 			}
 
-			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_actions)) {
+			if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT_IFACE, get_actions)) {
 				GtkWidget *menuitem;
 				PurpleProtocolAction *action = NULL;
 				GList *actions, *l;
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -1661,7 +1661,7 @@ create_chat_menu(PurpleChatConversation 
 			g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
 
 
-		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, send_file))
+		if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send))
 		{
 			gboolean can_receive_file = TRUE;
 
@@ -1675,7 +1675,7 @@ create_chat_menu(PurpleChatConversation 
 				gchar *real_who = NULL;
 				real_who = purple_protocol_chat_iface_get_user_real_name(protocol, gc,
 					purple_chat_conversation_get_id(chat), who);
-				if (!(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, can_receive_file) ||
+				if (!(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
 						purple_protocol_xfer_iface_can_receive(protocol, gc, real_who ? real_who : who)))
 					can_receive_file = FALSE;
 				g_free(real_who);
@@ -1701,7 +1701,7 @@ create_chat_menu(PurpleChatConversation 
 			g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
 	}
 
-	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_info)) {
+	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info)) {
 		button = pidgin_new_item_from_stock(menu, _("Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO,
 						G_CALLBACK(menu_chat_info_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
 
@@ -3272,7 +3272,7 @@ populate_menu_with_options(GtkWidget *me
 			PurpleProtocol *protocol =
 					purple_protocols_find(purple_account_get_protocol_id(account));
 			if (purple_account_get_connection(account) != NULL &&
-					PURPLE_PROTOCOL_IMPLEMENTS(protocol, chat_info_defaults)) {
+					PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, info_defaults)) {
 				components = purple_protocol_chat_iface_info_defaults(protocol, purple_account_get_connection(account),
 						purple_conversation_get_name(conv));
 			} else {
@@ -3408,7 +3408,7 @@ regenerate_attention_items(PidginWindow 
 	if (pc != NULL)
 		protocol = purple_connection_get_protocol(pc);
 
-	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_attention_types)) {
+	if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, get_types)) {
 		list = purple_protocol_attention_iface_get_types(protocol, purple_connection_get_account(pc));
 
 		/* Multiple attention types */
@@ -4464,7 +4464,7 @@ static void topic_callback(GtkWidget *w,
 	if(!gc || !(protocol = purple_connection_get_protocol(gc)))
 		return;
 
-	if(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, set_chat_topic))
+	if(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, set_topic))
 		return;
 
 	gtkconv = PIDGIN_CONVERSATION(conv);
@@ -4844,7 +4844,7 @@ setup_chat_topic(PidginConversation *gtk
 		gtkchat->topic_text = gtk_entry_new();
 		gtk_widget_set_size_request(gtkchat->topic_text, -1, BUDDYICON_SIZE_MIN);
 
-		if(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, set_chat_topic)) {
+		if(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, set_topic)) {
 			gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE);
 		} else {
 			g_signal_connect(G_OBJECT(gtkchat->topic_text), "activate",
@@ -5537,7 +5537,7 @@ conv_dnd_recv(GtkWidget *widget, GdkDrag
 		 * invite him to the chat.
 		 */
 		if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
-				protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, chat_invite) &&
+				protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, invite) &&
 				strcmp(purple_account_get_protocol_id(convaccount),
 					purple_account_get_protocol_id(buddyaccount)) == 0) {
 		    purple_chat_conversation_invite_user(PURPLE_CHAT_CONVERSATION(conv), buddyname, NULL, TRUE);
@@ -5593,7 +5593,7 @@ conv_dnd_recv(GtkWidget *widget, GdkDrag
 				 * invite him to the chat.
 				 */
 				if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
-						protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, chat_invite) &&
+						protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, invite) &&
 						strcmp(purple_account_get_protocol_id(convaccount), protocol_id) == 0) {
 					purple_chat_conversation_invite_user(PURPLE_CHAT_CONVERSATION(conv), username, NULL, TRUE);
 				} else {
@@ -7252,28 +7252,28 @@ gray_stuff_out(PidginConversation *gtkco
 		/* Deal with menu items */
 		gtk_action_set_sensitive(win->menu.view_log, TRUE);
 		gtk_action_set_sensitive(win->menu.add_pounce, TRUE);
-		gtk_action_set_sensitive(win->menu.get_info, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, get_info)));
-		gtk_action_set_sensitive(win->menu.invite, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, chat_invite)));
+		gtk_action_set_sensitive(win->menu.get_info, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info)));
+		gtk_action_set_sensitive(win->menu.invite, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT_IFACE, invite)));
 		gtk_action_set_sensitive(win->menu.insert_link, (features & PURPLE_CONNECTION_FLAG_HTML));
 		gtk_action_set_sensitive(win->menu.insert_image, !(features & PURPLE_CONNECTION_FLAG_NO_IMAGES));
 
 		if (PURPLE_IS_IM_CONVERSATION(conv))
 		{
-			gtk_action_set_sensitive(win->menu.add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, add_buddy)));
-			gtk_action_set_sensitive(win->menu.remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, remove_buddy)));
+			gtk_action_set_sensitive(win->menu.add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, add_buddy)));
+			gtk_action_set_sensitive(win->menu.remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, remove_buddy)));
 			gtk_action_set_sensitive(win->menu.send_file,
-									 (PURPLE_PROTOCOL_IMPLEMENTS(protocol, send_file) &&
-									 (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, can_receive_file) ||
+									 (PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send) &&
+									 (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
 									  purple_protocol_xfer_iface_can_receive(protocol, gc, purple_conversation_get_name(conv)))));
-			gtk_action_set_sensitive(win->menu.get_attention, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, send_attention)));



More information about the Commits mailing list