diff src/protocols/msn/msn.c @ 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 d8cd876e613e
children 6f4979d8cc3c
line wrap: on
line diff
--- 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;
 }