changeset 9797:62eb9fe24692

[gaim-migrate @ 10665] "This patch adds gaim_notify_userinfo() and a notify_userinfo() UI callback. gaim_notify_userinfo() is much like gaim_notify_formatted() except that it always takes a GaimConnection* as its handle and has an additional argument, const char* who. gaim_gtk_notify_userinfo() currently passes all the information except the GaimConnection* and the const char* who to gaim_gtk_notify_formatted(). This could be changed in the future to, for example, have a standardized window title which would note the account and/or user associated with the information. This is needed because some UIs (Adium, for example) don't want to present the information in a standalone window - they want to associate the information with a particular contact / buddy and display it with that object's other information. Previously, gaim_notify_formatted() was not useful for this purpose as it could not be determined what user's info it was; gaim_notify_userinfo() makes this possible. This patch modifies notify.c and notify.h for the new function, modifies gtknotify.c to register the ui op and pass calls to it on the gaim_gtk_notify_formatted, and modifies all prpls except SILC (which I don't understand well enough to modify, but there's no actual harm in leaving it as gaim_notify_formatted() for now) to use gaim_notify_userinfo() and pass their gc and username when calling the function." -- Evan Schoenberg committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 20 Aug 2004 22:05:18 +0000
parents 68574cef02e2
children 255596f41014
files src/gtknotify.c src/notify.c src/notify.h src/protocols/gg/gg.c src/protocols/irc/msgs.c src/protocols/jabber/buddy.c src/protocols/msn/msn.c src/protocols/napster/napster.c src/protocols/novell/novell.c src/protocols/oscar/oscar.c src/protocols/silc/ops.c src/protocols/yahoo/yahoo_profile.c src/protocols/zephyr/zephyr.c
diffstat 13 files changed, 93 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtknotify.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/gtknotify.c	Fri Aug 20 22:05:18 2004 +0000
@@ -388,6 +388,16 @@
 	return window;
 }
 
+static void *
+gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who,
+						 const char *title, const char *primary,
+						 const char *secondary, const char *text,
+						 GCallback cb, void *user_data)
+{
+	return (gaim_gtk_notify_formatted(title, primary, secondary,
+									  text, cb, user_data));
+}
+
 static void
 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle)
 {
@@ -622,6 +632,7 @@
 	gaim_gtk_notify_email,
 	gaim_gtk_notify_emails,
 	gaim_gtk_notify_formatted,
+	gaim_gtk_notify_userinfo,
 	gaim_gtk_notify_uri,
 	gaim_gtk_close_notify
 };
--- a/src/notify.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/notify.c	Fri Aug 20 22:05:18 2004 +0000
@@ -155,6 +155,33 @@
 	return NULL;
 }
 
+void *gaim_notify_userinfo(GaimConnection *gc, const char *who, const char *title,
+						   const char *primary, const char *secondary, 
+						   const char *text, GCallback cb, void *user_data)
+{
+	GaimNotifyUiOps *ops;
+
+	g_return_val_if_fail(primary != NULL, NULL);
+
+	ops = gaim_notify_get_ui_ops();
+
+	if (ops != NULL && ops->notify_userinfo != NULL) {
+		GaimNotifyInfo *info;
+
+		info            = g_new0(GaimNotifyInfo, 1);
+		info->type      = GAIM_NOTIFY_USERINFO;
+		info->handle    = gc;
+		info->ui_handle = ops->notify_userinfo(gc, who, title, primary,
+											   secondary, text, cb, user_data);
+
+		handles = g_list_append(handles, info);
+
+		return info->ui_handle;
+	}
+
+	return NULL;
+}
+
 void *
 gaim_notify_uri(void *handle, const char *uri)
 {
--- a/src/notify.h	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/notify.h	Fri Aug 20 22:05:18 2004 +0000
@@ -29,6 +29,8 @@
 #include <glib-object.h>
 #include <glib.h>
 
+#include "connection.h"
+
 /**
  * Notification types.
  */
@@ -38,6 +40,7 @@
 	GAIM_NOTIFY_EMAIL,       /**< Single e-mail notification.   */
 	GAIM_NOTIFY_EMAILS,      /**< Multiple e-mail notification. */
 	GAIM_NOTIFY_FORMATTED,   /**< Formatted text.               */
+	GAIM_NOTIFY_USERINFO,    /**< Formatted userinfo text.      */
 	GAIM_NOTIFY_URI          /**< URI notification or display.  */
 
 } GaimNotifyType;
@@ -71,6 +74,10 @@
 	void *(*notify_formatted)(const char *title, const char *primary,
 							  const char *secondary, const char *text,
 							  GCallback cb, void *user_data);
+	void *(*notify_userinfo)(GaimConnection *gc, const char *who,
+							  const char *title, const char *primary,
+							  const char *secondary, const char *text,
+							  GCallback cb, void *user_data);
 	void *(*notify_uri)(const char *uri);
 
 	void (*close_notify)(GaimNotifyType type, void *ui_handle);
@@ -169,6 +176,30 @@
 							const char *text, GCallback cb, void *user_data);
 
 /**
+	* Displays user information with formatted text, passing information giving
+    * the connection and username from which the user information came.
+ *
+ * The text is essentially a stripped-down format of HTML, the same that
+ * IMs may send.
+ *
+ * @param gc		The GaimConnection handle associated with the information.
+ * @param who		The username associated with the information.
+ * @param title     The title of the message.
+ * @param primary   The main point of the message.
+ * @param secondary The secondary information.
+ * @param text      The formatted text.
+ * @param cb        The callback to call when the user closes
+ *                  the notification.
+ * @param user_data The data to pass to the callback.
+ *
+ * @return A UI-specific handle.
+ */
+void *gaim_notify_userinfo(GaimConnection *gc, const char *who,
+						   const char *title, const char *primary,
+						   const char *secondary, const char *text,
+						   GCallback cb, void *user_data);
+
+/**
  * Opens a URI or somehow presents it to the user.
  *
  * @param handle The plugin or connection handle.
--- a/src/protocols/gg/gg.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/gg/gg.c	Fri Aug 20 22:05:18 2004 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 10621 2004-08-15 19:34:20Z lschiere $
+ * $Id: gg.c 10665 2004-08-20 22:05:18Z lschiere $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  *
@@ -240,7 +240,7 @@
 		splitmsg = g_strsplit(buddy->proto_data, "\r\n", 0);
     
 		dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, (char *)buddy->proto_data, g_strjoinv("<BR>", splitmsg));
-		gaim_notify_formatted(gc, NULL, _("Buddy Information"), buddy->proto_data, dialog_msg, NULL, (char *)who);
+		gaim_notify_userinfo(gc, who, NULL, _("Buddy Information"), buddy->proto_data, dialog_msg, NULL, NULL);
     }
 }
 #endif
--- a/src/protocols/irc/msgs.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/irc/msgs.c	Fri Aug 20 22:05:18 2004 +0000
@@ -222,7 +222,7 @@
 
 	g_snprintf(buffer, sizeof(buffer),
 			   _("Buddy Information for %s"), irc->whois.nick);
-	gaim_notify_formatted(gc, NULL, buffer, NULL, str, NULL, NULL);
+	gaim_notify_userinfo(gc, irc->whois.nick, NULL, buffer, NULL, str, NULL, NULL);
 
 	g_free(str);
 	memset(&irc->whois, 0, sizeof(irc->whois));
--- a/src/protocols/jabber/buddy.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/jabber/buddy.c	Fri Aug 20 22:05:18 2004 +0000
@@ -774,7 +774,7 @@
 
 	text = gaim_strdup_withhtml(info_text->str);
 
-	gaim_notify_formatted(NULL, title, _("Jabber Profile"),
+	gaim_notify_userinfo(js->gc, from, title, _("Jabber Profile"),
 			NULL, text, NULL, NULL);
 
 	g_free(title);
--- a/src/protocols/msn/msn.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/msn/msn.c	Fri Aug 20 22:05:18 2004 +0000
@@ -1246,7 +1246,7 @@
 		g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>",
 				tooltip_text, _("Error retrieving profile"));
 
-		gaim_notify_formatted(info_data->gc, NULL,
+		gaim_notify_userinfo(info_data->gc, info_data->name, NULL,
 				title, NULL, buf, NULL, NULL);
 
 		g_free(tooltip_text);
@@ -1575,8 +1575,8 @@
 #endif
 
 	g_string_prepend(s, tooltip_text);
-	gaim_notify_formatted(info_data->gc, NULL, title,
-						  NULL, s->str, NULL, NULL);
+	gaim_notify_userinfo(info_data->gc, info_data->name, NULL, 
+						 title, NULL, s->str, NULL, NULL);
 
 	g_free(stripped);
 	g_free(url_buffer);
--- a/src/protocols/napster/napster.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/napster/napster.c	Fri Aug 20 22:05:18 2004 +0000
@@ -389,7 +389,7 @@
 		/* XXX - Format is:   "Elite" 37 " " "Active" 0 0 0 0 "gaim 0.63cvs" 0 0 192.168.1.41 32798 0 unknown flounder */
 		res = g_strsplit(buf, " ", 2);
 		/* res[0] == username */
-		gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL,
+		gaim_notify_userinfo(gc, res[0], NULL, _("Buddy Information"), NULL,
 							  res[1], NULL, NULL);
 		g_strfreev(res);
 		break;
--- a/src/protocols/novell/novell.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/novell/novell.c	Fri Aug 20 22:05:18 2004 +0000
@@ -1476,8 +1476,9 @@
 		}
 	}
 
-	gaim_notify_formatted(NULL, NULL, _("User Properties"),
-						  NULL, info_text->str, NULL, NULL);
+	gaim_notify_userinfo(gc, nm_user_record_get_userid(user_record), NULL,
+						 _("User Properties"), NULL, info_text->str,
+						 NULL, NULL);
 
 	g_string_free(info_text, TRUE);
 }
--- a/src/protocols/oscar/oscar.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Fri Aug 20 22:05:18 2004 +0000
@@ -3820,7 +3820,7 @@
 			g_free(statusmsg);
 			g_strfreev(splitmsg);
 
-			gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL);
+			gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL);
 
 			g_free(title);
 			g_free(dialogmsg);
@@ -4041,7 +4041,7 @@
 	tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account));
 	g_string_free(str, TRUE);
 	title = g_strdup_printf(_("Info for %s"), userinfo->sn);
-	gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, tmp, NULL, NULL);
+	gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL);
 	g_free(title);
 	g_free(tmp);
 
@@ -4936,7 +4936,7 @@
 	else
 		alias = who;
 	primary = g_strdup_printf(_("ICQ Info for %s"), alias);
-	gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL);
+	gaim_notify_userinfo(gc, buddy->name, NULL, primary, NULL, str->str, NULL, NULL);
 	g_free(primary);
 	g_string_free(str, TRUE);
 
--- a/src/protocols/silc/ops.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/silc/ops.c	Fri Aug 20 22:05:18 2004 +0000
@@ -1082,6 +1082,7 @@
 						_("More..."), G_CALLBACK(silcgaim_whois_more));
 			else
 #endif
+				/* XXX this should use gaim_notify_userinfo, but it is unclear to me what should be passed for 'who' */
 				gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, buf, NULL, NULL);
 			g_free(buf);
 		}
@@ -1143,6 +1144,7 @@
 			}
 
 			buf = g_string_free(s, FALSE);
+			/* XXX this should use gaim_notify_userinfo, but it is unclear to me what should be passed for 'who' */
 			gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, buf, NULL, NULL);
 			g_free(buf);
 		}
--- a/src/protocols/yahoo/yahoo_profile.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/yahoo/yahoo_profile.c	Fri Aug 20 22:05:18 2004 +0000
@@ -760,8 +760,8 @@
 		g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>",
 				tooltip_text, _("Error retrieving profile"));
 
-		gaim_notify_formatted(info_data->gc, NULL, title, NULL,
-				buf, NULL, NULL);
+		gaim_notify_userinfo(info_data->gc, info_data->name, NULL, title,
+			NULL, buf, NULL, NULL);
 
 		g_free(profile_url_text);
 		g_free(tooltip_text);
@@ -797,8 +797,8 @@
 				  "you will need to visit this link in your web browser"),
 				profile_url_text, profile_url_text);
 
-		gaim_notify_formatted(info_data->gc, NULL, title, NULL,
-				buf, NULL, NULL);
+		gaim_notify_userinfo(info_data->gc, info_data->name, NULL, title, 
+				NULL, buf, NULL, NULL);
 
 		g_free(profile_url_text);
 		g_free(tooltip_text);
@@ -1180,8 +1180,8 @@
 	g_string_prepend(s, "<html><body>\n");
 
 	/* show it to the user */
-	gaim_notify_formatted(info_data->gc, NULL, title, NULL,
-						  s->str, NULL, NULL);
+	gaim_notify_userinfo(info_data->gc, info_data->name, NULL, title,
+						  NULL, s->str, NULL, NULL);
 
 	g_free(last_updated_utf8_string);
 	g_free(url_buffer);
--- a/src/protocols/zephyr/zephyr.c	Fri Aug 20 21:57:18 2004 +0000
+++ b/src/protocols/zephyr/zephyr.c	Fri Aug 20 22:05:18 2004 +0000
@@ -640,7 +640,8 @@
 					ZGetLocations(&locs, &one);
 					g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time);
 				}
-				gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, str->str, NULL, NULL);
+				gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, 
+									 str->str, NULL, NULL);
 				g_string_free(str, TRUE);
 			} else
 				serv_got_update(gc, b->name, nlocs, 0, 0, 0, 0);