changeset 17275:319bcb73eb4e

Use utility functions to get user info. Closes #964.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 24 May 2007 21:15:16 +0000
parents 5241d388f463
children b7fa0e44d723
files ChangeLog.API finch/gntblist.c finch/gntblist.h finch/gntconv.c pidgin/gtkblist.c pidgin/gtkconv.c pidgin/gtkdialogs.c pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 9 files changed, 49 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Thu May 24 20:35:07 2007 +0000
+++ b/ChangeLog.API	Thu May 24 21:15:16 2007 +0000
@@ -4,6 +4,8 @@
 	Added:
 	* purple_conversation_get_extended_menu
 	* purple_conversation_do_command
+	* pidgin_retrieve_user_info, shows immediate feedback when getting
+	  information about a user.
 
 	Changed:
 	* pidgin_separator returns the separator added to the menu.
@@ -11,6 +13,9 @@
 	Signals - Added: (See the Doxygen docs for details on all signals.)
 	* "conversation-extended-menu"
 
+	Finch - Added:
+	* finch_retrieve_user_info
+
 version 2.0.0 (5/3/2007):
 	Please note all functions, defines, and data structures have been
 	re-namespaced to match the new names of Pidgin, Finch, and libpurple.
--- a/finch/gntblist.c	Thu May 24 20:35:07 2007 +0000
+++ b/finch/gntblist.c	Thu May 24 21:15:16 2007 +0000
@@ -824,17 +824,20 @@
 			PURPLE_CALLBACK(finch_add_group), group);
 }
 
+void finch_retrieve_user_info(PurpleConnection *conn, const char *name)
+{
+	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
+	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
+	purple_notify_userinfo(conn, name, info, NULL, NULL);
+	purple_notify_user_info_destroy(info);
+
+	serv_get_info(conn, name);
+}
+
 static void
 finch_blist_get_buddy_info_cb(PurpleBuddy *buddy, PurpleBlistNode *selected)
 {
-	/* Add a userinfo with a "Retrieving information", which will later be updated
-	 * when the server finally returns the information. */
-	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
-	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
-	purple_notify_userinfo(buddy->account->gc, purple_buddy_get_name(buddy), info, NULL, NULL);
-	purple_notify_user_info_destroy(info);
-
-	serv_get_info(buddy->account->gc, purple_buddy_get_name(buddy));
+	finch_retrieve_user_info(buddy->account->gc, purple_buddy_get_name(buddy));
 }
 
 static void
--- a/finch/gntblist.h	Thu May 24 20:35:07 2007 +0000
+++ b/finch/gntblist.h	Thu May 24 21:15:16 2007 +0000
@@ -90,6 +90,14 @@
  */
 void finch_blist_set_size(int width, int height);
 
+/**
+ * Get information about a user. Show immediate feedback.
+ *
+ * @param conn   The connection to get information fro
+ * @param name   The user to get information about.
+ */
+void finch_retrieve_user_info(PurpleConnection *conn, const char *name);
+
 /*@}*/
 
 #endif
--- a/finch/gntconv.c	Thu May 24 20:35:07 2007 +0000
+++ b/finch/gntconv.c	Thu May 24 21:15:16 2007 +0000
@@ -313,12 +313,7 @@
 get_info_cb(GntMenuItem *item, gpointer ggconv)
 {
 	FinchConv *ggc = ggconv;
-	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
-	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
-	purple_notify_userinfo(ggc->active_conv->account->gc, purple_conversation_get_name(ggc->active_conv), info, NULL, NULL);
-	purple_notify_user_info_destroy(info);
-
-	serv_get_info(purple_conversation_get_gc(ggc->active_conv),
+	finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv),
 			purple_conversation_get_name(ggc->active_conv));
 }
 
--- a/pidgin/gtkblist.c	Thu May 24 20:35:07 2007 +0000
+++ b/pidgin/gtkblist.c	Thu May 24 21:15:16 2007 +0000
@@ -274,12 +274,7 @@
 
 static void gtk_blist_menu_info_cb(GtkWidget *w, PurpleBuddy *b)
 {
-	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
-	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
-	purple_notify_userinfo(b->account->gc, purple_buddy_get_name(b), info, NULL, NULL);
-	purple_notify_user_info_destroy(info);
-
-	serv_get_info(b->account->gc, b->name);
+	pidgin_retrieve_user_info(b->account->gc, purple_buddy_get_name(b));
 }
 
 static void gtk_blist_menu_im_cb(GtkWidget *w, PurpleBuddy *b)
@@ -1147,7 +1142,8 @@
 }
 
 static gboolean
-gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data) {
+gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data)
+{
 	PurpleBlistNode *node;
 	GValue val;
 	GtkTreeIter iter;
@@ -1174,7 +1170,7 @@
 			return FALSE;
 		}
 		if(buddy)
-			serv_get_info(buddy->account->gc, buddy->name);
+			pidgin_retrieve_user_info(buddy->account->gc, buddy->name);
 	} else if (event->keyval == GDK_F2) {
 		gtk_blist_menu_alias_cb(tv, node);
 	}
@@ -1428,7 +1424,7 @@
 			prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 
 		if (prpl && prpl_info->get_info)
-			serv_get_info(b->account->gc, b->name);
+			pidgin_retrieve_user_info(b->account->gc, b->name);
 		handled = TRUE;
 	}
 
--- a/pidgin/gtkconv.c	Thu May 24 20:35:07 2007 +0000
+++ b/pidgin/gtkconv.c	Thu May 24 21:15:16 2007 +0000
@@ -673,14 +673,8 @@
 	PurpleConversation *conv = gtkconv->active_conv;
 
 	if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
-		PurpleNotifyUserInfo *info = purple_notify_user_info_new();
-		purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
-		purple_notify_userinfo(conv->account->gc, purple_conversation_get_name(conv), info, NULL, NULL);
-		purple_notify_user_info_destroy(info);
-
-		serv_get_info(purple_conversation_get_gc(conv),
+		pidgin_retrieve_user_info(purple_conversation_get_gc(conv),
 					  purple_conversation_get_name(conv));
-
 		gtk_widget_grab_focus(gtkconv->entry);
 	} else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
 		/* Get info of the person currently selected in the GtkTreeView */
--- a/pidgin/gtkdialogs.c	Thu May 24 20:35:07 2007 +0000
+++ b/pidgin/gtkdialogs.c	Thu May 24 21:15:16 2007 +0000
@@ -823,7 +823,7 @@
 		found = pidgin_dialogs_ee(username);
 
 	if (!found && username != NULL && *username != '\0' && account != NULL)
-		serv_get_info(purple_account_get_connection(account), username);
+		pidgin_retrieve_user_info(purple_account_get_connection(account), username);
 
 	g_free(username);
 }
--- a/pidgin/gtkutils.c	Thu May 24 20:35:07 2007 +0000
+++ b/pidgin/gtkutils.c	Thu May 24 21:15:16 2007 +0000
@@ -947,6 +947,15 @@
 	g_free(filename);
 }
 
+void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
+{
+	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
+	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
+	purple_notify_userinfo(conn, name, info, NULL, NULL);
+	purple_notify_user_info_destroy(info);
+	serv_get_info(conn, name);
+}
+
 gboolean
 pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
 							PurpleAccount **ret_account, char **ret_protocol,
--- a/pidgin/gtkutils.h	Thu May 24 20:35:07 2007 +0000
+++ b/pidgin/gtkutils.h	Thu May 24 21:15:16 2007 +0000
@@ -309,6 +309,14 @@
 void pidgin_load_accels(void);
 
 /**
+ * Get information about a user. Show immediate feedback.
+ *
+ * @param conn   The connection to get information from.
+ * @param name   The user to get information about.
+ */
+void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
+
+/**
  * Parses an application/x-im-contact MIME message and returns the
  * data inside.
  *