changeset 5369:a87818e9dc54

[gaim-migrate @ 5745] Pages can now be sent to MSN users that have MSN Mobile setup with a device capable of pages. Right-click and choose "Send to Mobile." Some of the stuff isn't complete. I'm working on it. Also, the interface sucks, but will have to be that way until I do the do_*_dialog() core/ui split. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 14 May 2003 05:53:05 +0000
parents c4e7a079cc04
children 058230cccebb
files src/protocols/msn/Makefile.am src/protocols/msn/msn.c
diffstat 2 files changed, 70 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/Makefile.am	Wed May 14 04:35:09 2003 +0000
+++ b/src/protocols/msn/Makefile.am	Wed May 14 05:53:05 2003 +0000
@@ -16,6 +16,8 @@
 	msn.h \
 	notification.c \
 	notification.h \
+	page.c \
+	page.h \
 	servconn.c \
 	servconn.h \
 	session.c \
--- a/src/protocols/msn/msn.c	Wed May 14 04:35:09 2003 +0000
+++ b/src/protocols/msn/msn.c	Wed May 14 05:53:05 2003 +0000
@@ -21,6 +21,7 @@
  */
 #include "msn.h"
 #include "msg.h"
+#include "page.h"
 #include "session.h"
 #include "state.h"
 #include "utils.h"
@@ -34,6 +35,13 @@
 
 static char *msn_normalize(const char *str);
 
+typedef struct
+{
+	struct gaim_connection *gc;
+	const char *passport;
+
+} MsnMobileData;
+
 static void
 msn_act_id(gpointer data, char *entry)
 {
@@ -116,6 +124,36 @@
 	msn_set_prp(gc, "MOB", "N");
 }
 
+static void
+__send_to_mobile_cb(MsnMobileData *data, const char *entry)
+{
+	MsnSession *session = data->gc->proto_data;
+	MsnServConn *servconn = session->notification_conn;
+	MsnUser *user;
+	MsnPage *page;
+	char *page_str;
+
+	user = msn_user_new(session, data->passport, NULL);
+
+	page = msn_page_new();
+	msn_page_set_receiver(page, user);
+	msn_page_set_transaction_id(page, ++session->trId);
+	msn_page_set_body(page, entry);
+
+	page_str = msn_page_build_string(page);
+
+	msn_user_destroy(user);
+	msn_page_destroy(page);
+
+	if (!msn_servconn_write(servconn, page_str, strlen(page_str))) {
+
+		hide_login_progress(data->gc, _("Write error"));
+		signoff(data->gc);
+	}
+
+	g_free(page_str);
+}
+
 /* -- */
 
 static void
@@ -185,6 +223,24 @@
 				  session->prpl->handle, FALSE);
 }
 
+static void
+__show_send_to_mobile_cb(struct gaim_connection *gc, const char *passport)
+{
+	MsnUser *user;
+	MsnSession *session = gc->proto_data;
+	MsnMobileData *data;
+
+	user = msn_users_find_with_passport(session->users, passport);
+
+	data = g_new0(MsnMobileData, 1);
+	data->gc = gc;
+	data->passport = passport;
+
+	do_prompt_dialog(_("Send message:"), NULL,
+					 data, __send_to_mobile_cb, g_free);
+}
+
+
 /**************************************************************************
  * Protocol Plugin ops
  **************************************************************************/
@@ -312,8 +368,20 @@
 static GList *
 msn_buddy_menu(struct gaim_connection *gc, const char *who)
 {
+	struct proto_buddy_menu *pbm;
+	struct buddy *b;
 	GList *m = NULL;
 
+	b = gaim_find_buddy(gc->account, who);
+
+	if (MSN_MOBILE(b->uc)) {
+		pbm = g_new0(struct proto_buddy_menu, 1);
+		pbm->label    = _("Send to Mobile");
+		pbm->callback = __show_send_to_mobile_cb;
+		pbm->gc       = gc;
+		m = g_list_append(m, pbm);
+	}
+
 	return m;
 }