changeset 6148:82e7eaa67406

[gaim-migrate @ 6622] A last-minute surprise to all of gaim's MSN users who wanted this feature. Chats can now be initiated by right-clicking an MSN user and choosing Initiate Chat. Note that chats in MSN don't work like chats elsewhere, because IMs and Chats in MSN are the exact same things, and we can't detect the number of users before connecting to the switchboard. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 16 Jul 2003 06:15:19 +0000
parents 084f6c031783
children 6f4979d8cc3c
files ChangeLog src/protocols/msn/msn.c src/protocols/msn/switchboard.c
diffstat 3 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 16 04:53:09 2003 +0000
+++ b/ChangeLog	Wed Jul 16 06:15:19 2003 +0000
@@ -27,6 +27,8 @@
 	* Fixed all known MSN chat bugs
 	* Fixed HTTP redirect handling in smiley retrieval. This fixes the
 	  problems with some smiley themes.
+	* Chats in MSN can now be initiated by right-clicking a buddy and
+	  choosing Initiate Chat.
 	* MSN Alerts and incoming MSN pages no longer pop up several error dialogs
 	* Ability to view iChat "Available" messages for AIM
 	* Stores your buddy icon on the server for AIM
--- a/src/protocols/msn/msn.c	Wed Jul 16 04:53:09 2003 +0000
+++ b/src/protocols/msn/msn.c	Wed Jul 16 06:15:19 2003 +0000
@@ -237,6 +237,31 @@
 					   data);
 }
 
+static void
+initiate_chat_cb(GaimConnection *gc, const char *passport)
+{
+	GaimAccount *account = gaim_connection_get_account(gc);
+	MsnSession *session = gc->proto_data;
+	MsnSwitchBoard *swboard;
+	MsnUser *user;
+
+	if ((swboard = msn_session_open_switchboard(session)) == NULL) {
+		gaim_connection_error(gc, _("Write error"));
+
+		return;
+	}
+
+	user = msn_user_new(session, passport, NULL);
+
+	msn_switchboard_set_user(swboard, user);
+
+	swboard->total_users = 1;
+
+	swboard->chat = serv_got_joined_chat(gc, ++swboard->chat_id, "MSN Chat");
+
+	gaim_chat_add_user(GAIM_CHAT(swboard->chat),
+					   gaim_account_get_username(account), NULL);
+}
 
 /**************************************************************************
  * Protocol Plugin ops
@@ -373,6 +398,7 @@
 static GList *
 msn_buddy_menu(GaimConnection *gc, const char *who)
 {
+	GaimAccount *account = gaim_connection_get_account(gc);
 	MsnUser *user;
 	struct proto_buddy_menu *pbm;
 	struct buddy *b;
@@ -391,6 +417,14 @@
 		}
 	}
 
+	if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) {
+		pbm = g_new0(struct proto_buddy_menu, 1);
+		pbm->label    = _("Initiate Chat");
+		pbm->callback = initiate_chat_cb;
+		pbm->gc       = gc;
+		m = g_list_append(m, pbm);
+	}
+
 	return m;
 }
 
--- a/src/protocols/msn/switchboard.c	Wed Jul 16 04:53:09 2003 +0000
+++ b/src/protocols/msn/switchboard.c	Wed Jul 16 06:15:19 2003 +0000
@@ -151,9 +151,9 @@
 	GaimConnection *gc = account->gc;
 	MsnSwitchBoard *swboard = servconn->data;
 
-	swboard->total_users = atoi(params[2]);
+	swboard->total_users = atoi(params[2]) + 1;
 
-	if (swboard->total_users > 1) {
+	if (swboard->total_users > 2) {
 		if (swboard->chat == NULL) {
 			GaimConversation *conv;
 
@@ -185,7 +185,7 @@
 
 	passport = params[0];
 
-	if (swboard->total_users == 1) {
+	if (swboard->total_users == 2 && swboard->chat == NULL) {
 		GaimConversation *conv;
 
 		conv = gaim_find_conversation(msn_user_get_passport(swboard->user));