changeset 1778:9bc21732ba79

[gaim-migrate @ 1788] i'm kinda tired committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 30 Apr 2001 11:45:49 +0000
parents c728b05731b8
children 0da2a831c0ae
files ChangeLog NEWS configure.in doc/gaim.1 plugins/jabber/jabber.c
diffstat 5 files changed, 120 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Apr 30 09:05:02 2001 +0000
+++ b/ChangeLog	Mon Apr 30 11:45:49 2001 +0000
@@ -20,6 +20,7 @@
 	* Redesigned Preferences pages (design by DennisR)
 	* Can select where tabs are for tabbed IM/Chat windows
 	* Option to queue away messages while away
+	* Jabber got good updates (from faceprint)
 	* Oh yes, and Oscar works, yet again. (gee... that's what, 4
 	  releases that have "fixed" it now?)
 
--- a/NEWS	Mon Apr 30 09:05:02 2001 +0000
+++ b/NEWS	Mon Apr 30 11:45:49 2001 +0000
@@ -6,6 +6,12 @@
         have a headache right now, though, so I won't say much.  I'll let
 	Eric talk :)
 
+	Eric: I uh. I bought 72 cans of soda yesterday. It only cost $15
+	or so. I figure I'll be through it in less than two weeks. A
+	dollar a day on soda isn't so bad. For the fourth release in a row,
+	Oscar is fixed. Isn't that exciting. Judging from history I'd say
+	that it won't stay fixed long; but judging from what I know has
+	changed, we shouldn't have any more troubles.
 
 0.11.0-pre10 (04/13/2001):
 	Rob: EEP! It's Friday the 13th!!!  I think I fixed a few buggies
--- a/configure.in	Mon Apr 30 09:05:02 2001 +0000
+++ b/configure.in	Mon Apr 30 11:45:49 2001 +0000
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(src/aim.c)
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE([gaim], [0.11.0pre10])
+AM_INIT_AUTOMAKE([gaim], [0.11.0pre11])
 
 dnl Checks for programs.
 AC_ENABLE_STATIC(no)
--- a/doc/gaim.1	Mon Apr 30 09:05:02 2001 +0000
+++ b/doc/gaim.1	Mon Apr 30 11:45:49 2001 +0000
@@ -21,7 +21,7 @@
 .\" USA.
 .TH GAIM 1
 .SH NAME
-gaim v0.11.0pre10 \- Instant Messaging client
+gaim v0.11.0pre11 \- Instant Messaging client
 .SH SYNOPSIS
 .TP 5
 \fBgaim\fR
--- a/plugins/jabber/jabber.c	Mon Apr 30 09:05:02 2001 +0000
+++ b/plugins/jabber/jabber.c	Mon Apr 30 11:45:49 2001 +0000
@@ -116,6 +116,7 @@
 	gboolean did_import;
 	GSList *pending_chats;
 	GSList *existing_chats;
+	GHashTable *hash;
 };
 
 static char *jabber_name()
@@ -717,10 +718,20 @@
 				serv_got_update(GJ_GC(j), buddy, 0, 0, 0, 0, 0, 0);
 			}
 		} else {
+			/* keep track of away msg same as yahoo plugin */
+			struct jabber_data *jd = GJ_GC(j)->proto_data;
+			gpointer val = g_hash_table_lookup(jd->hash, b->name);
+			if (val)
+			   	g_free(val);
+			g_hash_table_insert(jd->hash, g_strdup(b->name), g_strdup(xmlnode_get_tag_data(p->x, "status")));
+
+
 			if (!resources) {
 				b->proto_data = g_slist_append(b->proto_data, g_strdup(res));
 			}
+
 			serv_got_update(GJ_GC(j), buddy, 1, 0, 0, 0, state, 0);
+
 		}
 	} else {
 		if (who->resource) {
@@ -857,6 +868,42 @@
 	xmlnode_free(x);
 }
 
+static void jabber_handlevcard(gjconn j, xmlnode querynode, char *from) {
+	char buf[1024];
+	char *fn, *url, *email, *nickname, *status;
+	jid who;
+	char *buddy;
+	struct jabber_data *jd = GJ_GC(j)->proto_data;
+	int at = 0;
+
+	who = jid_new(j->p, from);
+	buddy = g_strdup_printf("%s@%s", who->user, who->server);
+	
+	fn = xmlnode_get_tag_data(querynode, "FN");
+	url = xmlnode_get_tag_data(querynode, "URL");
+	email = xmlnode_get_tag_data(querynode, "EMAIL");
+	nickname = xmlnode_get_tag_data(querynode, "NICKNAME");
+	status = g_hash_table_lookup(jd->hash, buddy);
+	if (!status)
+		status = "Online";
+
+	at = g_snprintf(buf, sizeof buf, "<B>Jabber ID:</B> %s<BR>", buddy);
+	if (fn)
+		at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Full Name:</B> %s<BR>", fn);
+	if (nickname)
+		at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Nickname:</B> %s<BR>", nickname);
+	if (url)
+		at += g_snprintf(buf + at, sizeof(buf) - at, "<B>URL:</B> <A HREF=\"%s\">%s</A><BR>",
+				url, url);
+	if (email)
+		at += g_snprintf(buf + at, sizeof(buf) - at,
+				"<B>Email:</B> <A HREF=\"mailto:%s\">%s</A><BR>", email, email);
+	at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Status:</B> %s\n", status);
+	
+	g_show_info_text(buf);
+	g_free(buddy);
+}
+
 static void jabber_handlepacket(gjconn j, jpacket p)
 {
 	switch (p->type) {
@@ -872,12 +919,13 @@
 		if (jpacket_subtype(p) == JPACKET__SET) {
 		} else if (jpacket_subtype(p) == JPACKET__GET) {
 		} else if (jpacket_subtype(p) == JPACKET__RESULT) {
-			xmlnode querynode;
+			xmlnode querynode, vcard;
 			char *xmlns, *from;
 
 			from = xmlnode_get_attrib(p->x, "from");
 			querynode = xmlnode_get_tag(p->x, "query");
 			xmlns = xmlnode_get_attrib(querynode, "xmlns");
+			vcard = xmlnode_get_tag(p->x, "vCard");
 
 			if ((!xmlns && !from) || NSCHECK(querynode, NS_AUTH)) {
 				debug_printf("auth success\n");
@@ -894,6 +942,10 @@
 
 			} else if (NSCHECK(querynode, NS_ROSTER)) {
 				jabber_handleroster(j, querynode);
+			} else if (NSCHECK(querynode, NS_VCARD)) {
+			   	jabber_handlevcard(j, querynode, from);
+			} else if(vcard) {
+				jabber_handlevcard(j, vcard, from);
 			} else {
 				/* debug_printf("jabber:iq:query: %s\n", xmlns); */
 			}
@@ -952,6 +1004,8 @@
 	struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1);
 	char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "GAIM");
 
+	jd->hash = g_hash_table_new(g_str_hash, g_str_equal);
+
 	set_login_progress(gc, 1, "Connecting");
 
 	if (!(jd->jc = gjab_new(loginname, user->password, gc))) {
@@ -974,9 +1028,17 @@
 	return;
 }
 
+static gboolean jabber_destroy_hash(gpointer key, gpointer val, gpointer data) {
+   	g_free(key);
+	g_free(val);
+	return TRUE;
+}
+
 static void jabber_close(struct gaim_connection *gc)
 {
 	struct jabber_data *jd = gc->proto_data;
+	g_hash_table_foreach_remove(jd->hash, jabber_destroy_hash, NULL);
+	g_hash_table_destroy(jd->hash);
 	gdk_input_remove(gc->inpa);
 	gjab_delete(jd->jc);
 	jd->jc = NULL;
@@ -1353,7 +1415,6 @@
 static void regpacket(jconn j, jpacket p)
 {
 	static int here = 0;
-	g_print("here\n");
 	switch (p->type) {
 		case JPACKET_MESSAGE:
 			break;
@@ -1380,7 +1441,6 @@
 					gtk_entry_set_text(GTK_ENTRY(newname), "");
 					gtk_entry_set_text(GTK_ENTRY(newpass1), "");
 					gtk_entry_set_text(GTK_ENTRY(newpass2), "");
-					g_print("reg\n");
 					return;
 				} else if (here == 1) {
 					x = jutil_iqnew(JPACKET__SET, NS_AUTH);
@@ -1508,6 +1568,52 @@
 	return buf;
 }
 
+static void jabber_get_info(struct gaim_connection *gc, char *who) {
+	xmlnode x;
+	char *id;
+	struct jabber_data *jd = gc->proto_data;
+	gjconn j = jd->jc;
+
+	x = jutil_iqnew(JPACKET__GET, NS_VCARD);
+	xmlnode_put_attrib(x, "to", who);
+	id = gjab_getid(j);
+	xmlnode_put_attrib(x, "id", id);
+
+	gjab_send(j, x);
+
+	xmlnode_free(x);
+	
+}
+
+static void jabber_info(GtkObject *obj, char *who) {
+   	serv_get_info(gtk_object_get_user_data(obj), who);
+}
+
+static void jabber_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) {
+	GtkWidget *button;
+	char buf[1024];
+	struct buddy *b = find_buddy(gc, who);
+	struct jabber_data *jd = gc->proto_data;
+	char *status;
+	
+	button = gtk_menu_item_new_with_label(_("Get Info"));
+	gtk_signal_connect(GTK_OBJECT(button), "activate",
+	      		   GTK_SIGNAL_FUNC(jabber_info), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+	
+	status = g_hash_table_lookup(jd->hash, b->name);
+	if (!status || !strcasecmp("Online", status))
+	   return;
+
+	g_snprintf(buf, sizeof buf, "Status: %s",status);
+
+	button = gtk_menu_item_new_with_label(buf);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+}
+
 static GList *jabber_away_states() {
 	GList *m = NULL;
 
@@ -1579,7 +1685,7 @@
 	ret->name = jabber_name;
 	ret->list_icon = jabber_list_icon;
 	ret->away_states = jabber_away_states;
-	ret->buddy_menu = NULL;
+	ret->buddy_menu = jabber_buddy_menu;
 	ret->user_opts = NULL;
 	ret->draw_new_user = jabber_draw_new_user;
 	ret->do_new_user = jabber_do_new_user;
@@ -1587,7 +1693,7 @@
 	ret->close = jabber_close;
 	ret->send_im = jabber_send_im;
 	ret->set_info = NULL;
-	ret->get_info = NULL;
+	ret->get_info = jabber_get_info;
 	ret->set_away = jabber_set_away;
 	ret->get_away_msg = NULL;
 	ret->set_dir = NULL;