changeset 7398:d60e1629ffde

[gaim-migrate @ 7994] now when you try to IM someone in a jabber chat, it'll actually get there committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 31 Oct 2003 05:14:27 +0000
parents 8a3b768f8472
children 9ab1987e5d8b
files src/gtkconv.c src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/jabber.c src/prpl.h
diffstat 5 files changed, 49 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Fri Oct 31 03:02:48 2003 +0000
+++ b/src/gtkconv.c	Fri Oct 31 05:14:27 2003 +0000
@@ -1043,22 +1043,43 @@
 }
 
 static void
-menu_chat_im_cb(GtkWidget *w, GaimConversation *conv)
+chat_do_im(GaimConversation *conv, const char *who)
 {
-	const char *who;
+	GaimPluginProtocolInfo *prpl_info = NULL;
+	char *real_who;
 	GaimConversation *conv2;
 	GaimAccount *account;
 
-	who = g_object_get_data(G_OBJECT(w), "user_data");
-
 	account = gaim_conversation_get_account(conv);
 
-	conv2 = gaim_find_conversation_with_account(who, account);
+	if(account && account->gc)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
+
+	if(prpl_info && prpl_info->get_cb_real_name)
+		real_who = prpl_info->get_cb_real_name(account->gc,
+				gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who);
+	else
+		real_who = g_strdup(who);
+
+	if(!real_who)
+		return;
+
+	conv2 = gaim_find_conversation_with_account(real_who, account);
 
 	if (conv2 != NULL)
 		gaim_conv_window_show(gaim_conversation_get_window(conv2));
 	else
-		conv2 = gaim_conversation_new(GAIM_CONV_IM, account, who);
+		conv2 = gaim_conversation_new(GAIM_CONV_IM, account, real_who);
+
+	g_free(real_who);
+}
+
+static void
+menu_chat_im_cb(GtkWidget *w, GaimConversation *conv)
+{
+	const char *who = g_object_get_data(G_OBJECT(w), "user_data");
+
+	chat_do_im(conv, who);
 }
 
 static void
@@ -1169,14 +1190,8 @@
 	if (*who == '+') who++;
 
 	if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
-		GaimConversation *c;
-
-		if ((c = gaim_find_conversation_with_account(who, account)) == NULL)
-			c = gaim_conversation_new(GAIM_CONV_IM, account, who);
-		else
-			gaim_conversation_set_account(c, account);
-	}
-	else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+		chat_do_im(conv, who);
+	} else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
 		static GtkWidget *menu = NULL;
 		GtkWidget *button;
 
--- a/src/protocols/jabber/chat.c	Fri Oct 31 03:02:48 2003 +0000
+++ b/src/protocols/jabber/chat.c	Fri Oct 31 05:14:27 2003 +0000
@@ -268,3 +268,15 @@
 	return FALSE;
 }
 
+char *jabber_chat_buddy_real_name(GaimConnection *gc, int id, const char *who)
+{
+	JabberStream *js = gc->proto_data;
+	JabberChat *chat;
+
+	chat = jabber_chat_find_by_id(js, id);
+
+	if(!chat)
+		return NULL;
+
+	return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who);
+}
--- a/src/protocols/jabber/chat.h	Fri Oct 31 03:02:48 2003 +0000
+++ b/src/protocols/jabber/chat.h	Fri Oct 31 05:14:27 2003 +0000
@@ -52,5 +52,7 @@
 void jabber_chat_invite(GaimConnection *gc, int id, const char *message,
 		const char *name);
 void jabber_chat_leave(GaimConnection *gc, int id);
+char *jabber_chat_buddy_real_name(GaimConnection *gc, int id, const char *who);
+
 
 #endif /* _GAIM_JABBER_CHAT_H_ */
--- a/src/protocols/jabber/jabber.c	Fri Oct 31 03:02:48 2003 +0000
+++ b/src/protocols/jabber/jabber.c	Fri Oct 31 05:14:27 2003 +0000
@@ -1086,7 +1086,10 @@
 	jabber_roster_group_rename,
 	NULL,
 	NULL, /* convo_closed */ /* XXX: thread_ids */
-	jabber_normalize /* normalize */
+	jabber_normalize,
+	NULL, /* set_buddy_icon */
+	NULL, /* remove_group */
+	jabber_chat_buddy_real_name
 };
 
 static GaimPluginInfo info =
--- a/src/prpl.h	Fri Oct 31 03:02:48 2003 +0000
+++ b/src/prpl.h	Fri Oct 31 05:14:27 2003 +0000
@@ -311,6 +311,8 @@
 	void (*set_buddy_icon)(GaimConnection *, const char *filename);
 
 	void (*remove_group)(GaimConnection *gc, const char *group);
+
+	char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who);
 };
 
 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \