[gaim-migrate @ 6447]

Thu, 03 Jul 2003 03:09:08 +0000

author
Christian Hammond <chipx86@chipx86.com>
date
Thu, 03 Jul 2003 03:09:08 +0000
changeset 5999
a3f0c3938abc
parent 5998
e833f6baf102
child 6000
520136935f31

[gaim-migrate @ 6447]
Added the Homepage field to the Trepia tooltip, and added a Visit Homepage
link to those buddies that have a homepage set. Credit goes to SimGuy.
Also, fixed a bug where empty fields in the XML packets weren't causing the
values to be set NULL. Rather, they were just empty strings. This caused
blank entries in the tooltips and other such annoyances.

src/protocols/trepia/trepia.c file | annotate | diff | comparison | revisions
--- a/src/protocols/trepia/trepia.c	Thu Jul 03 03:06:18 2003 +0000
+++ b/src/protocols/trepia/trepia.c	Thu Jul 03 03:09:08 2003 +0000
@@ -35,6 +35,7 @@
 /* XXX */
 #include "gaim.h"
 #include "multi.h"
+#include "ui.h" /* XXX for open_url */
 
 #ifndef _WIN32
 # include <sys/socket.h>
@@ -485,6 +486,15 @@
 		text = tmp2;
 	}
 
+	if ((value = trepia_profile_get_homepage(profile)) != NULL) {
+		tmp = g_strdup_printf("<b>Homepage:</b> %s\n", value);
+
+		tmp2 = g_strconcat(text, tmp, NULL);
+		g_free(tmp);
+		g_free(text);
+		text = tmp2;
+	}
+
 	if ((value = trepia_profile_get_profile(profile)) != NULL) {
 		char *escaped_val = g_markup_escape_text(value, -1);
 
@@ -519,6 +529,43 @@
 }
 
 static void
+trepia_visit_homepage(GaimConnection *gc, const char *who)
+{
+	TrepiaProfile *profile;
+	struct buddy *b;
+	const char *value;
+
+	b = gaim_find_buddy(gaim_connection_get_account(gc), who);
+	profile = b->proto_data;
+
+	if ((value = trepia_profile_get_homepage(profile)) != NULL)
+		open_url(NULL, value);
+}
+
+static GList *
+trepia_buddy_menu(GaimConnection *gc, const char *who)
+{
+	TrepiaProfile *profile;
+	struct buddy *b;
+	const char *value = NULL;
+	GList *m = NULL;
+	struct proto_buddy_menu *pbm;
+
+	b = gaim_find_buddy(gaim_connection_get_account(gc), who);
+	profile = b->proto_data;
+
+	if ((value = trepia_profile_get_homepage(profile)) != NULL) {
+		pbm = g_new0(struct proto_buddy_menu, 1);
+		pbm->label = _("Visit Homepage");
+		pbm->callback = trepia_visit_homepage;
+		pbm->gc = gc;
+		m = g_list_append(m, pbm);
+	}
+
+	return m;
+}
+
+static void
 __free_parser_data(gpointer user_data)
 {
 #if 0
@@ -574,7 +621,12 @@
 	buffer = g_string_free(data->buffer, FALSE);
 	data->buffer = NULL;
 
-	g_hash_table_insert(data->keys, data->tag, buffer);
+	if (buffer != NULL) {
+		if (*buffer != '\0')
+			g_hash_table_insert(data->keys, data->tag, buffer);
+		else
+			free(buffer);
+	}
 
 	data->tag = NULL;
 }
@@ -1242,7 +1294,7 @@
 	trepia_tooltip_text,
 	NULL,
 	trepia_actions,
-	NULL,
+	trepia_buddy_menu,
 	NULL,
 	trepia_login,
 	trepia_close,

mercurial