source: protocols/msn/ns.c @ 4107fea

Last change on this file since 4107fea was 4107fea, checked in by dequis <dx@…>, at 2015-05-31T02:40:04Z

msn: start implementing basic MSNP24 login

Not working yet since it's missing the UIC

  • Property mode set to 100644
File size: 17.9 KB
Line 
1/********************************************************************\
2  * BitlBee -- An IRC to other IM-networks gateway                     *
3  *                                                                    *
4  * Copyright 2002-2012 Wilmer van der Gaast and others                *
5  \********************************************************************/
6
7/* MSN module - Notification server callbacks                           */
8
9/*
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License with
21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
22  if not, write to the Free Software Foundation, Inc., 51 Franklin St.,
23  Fifth Floor, Boston, MA  02110-1301  USA
24*/
25
26#include <ctype.h>
27#include <sys/utsname.h>
28#include "nogaim.h"
29#include "msn.h"
30#include "md5.h"
31#include "sha1.h"
32#include "soap.h"
33#include "xmltree.h"
34#include "ssl_client.h"
35
36static gboolean msn_ns_connected(gpointer data, int source, void *scd, b_input_condition cond);
37static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond);
38
39static void msn_ns_send_adl_start(struct im_connection *ic);
40static void msn_ns_send_adl(struct im_connection *ic);
41static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd);
42static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action);
43static void msn_ns_nfy(struct msn_data *md, char *who, char **parts, char *action, gboolean is_put);
44
45int msn_ns_write(struct im_connection *ic, const char *fmt, ...)
46{
47        struct msn_data *md = ic->proto_data;
48        va_list params;
49        char *out;
50        size_t len;
51        int st;
52
53        va_start(params, fmt);
54        out = g_strdup_vprintf(fmt, params);
55        va_end(params);
56
57        if (getenv("BITLBEE_DEBUG")) {
58                fprintf(stderr, "\n\x1b[91m>>>[NS] %s\n\x1b[97m", out);
59        }
60
61        len = strlen(out);
62
63        if (md->is_http) {
64                st = len;
65                msn_gw_write(md->gw, out, len);
66        } else {
67                st = ssl_write(md->ssl, out, len);
68        }
69
70        g_free(out);
71        if (st != len) {
72                imcb_error(ic, "Short write() to main server");
73                imc_logout(ic, TRUE);
74                return 0;
75        }
76
77        return 1;
78}
79
80int msn_ns_write_cmd(struct im_connection *ic, const char *cmd, const char *params, const char *payload)
81{
82        struct msn_data *md = ic->proto_data;
83        int trid = ++md->trId;
84        const char *headers = "\r\n"; /* not needed yet */
85        size_t len = strlen(headers) + strlen(payload);
86
87        if (params && *params) {
88                return msn_ns_write(ic, "%s %d %s %zd\r\n%s%s", cmd, trid, params, len, headers, payload);
89        } else {
90                return msn_ns_write(ic, "%s %d %zd\r\n%s%s", cmd, trid, len, headers, payload);
91        }
92}
93
94gboolean msn_ns_connect(struct im_connection *ic, const char *host, int port)
95{
96        struct msn_data *md = ic->proto_data;
97
98        if (md->fd >= 0) {
99                closesocket(md->fd);
100        }
101
102        if (md->is_http) {
103                md->gw = msn_gw_new(ic);
104                md->gw->callback = msn_ns_callback;
105                msn_ns_connected(md, 0, NULL, B_EV_IO_READ);
106        } else {
107                md->ssl = ssl_connect((char *) host, port, TRUE, msn_ns_connected, md);
108                md->fd = md->ssl ? ssl_getfd(md->ssl) : -1;
109                if (md->fd < 0) {
110                        imcb_error(ic, "Could not connect to server");
111                        imc_logout(ic, TRUE);
112                        return FALSE;
113                }
114        }
115
116        return TRUE;
117}
118
119static gboolean msn_ns_connected(gpointer data, int source, void *scd, b_input_condition cond)
120{
121        struct msn_data *md = data;
122        struct im_connection *ic = md->ic;
123
124        if (!scd && !md->is_http) {
125                md->ssl = NULL;
126                imcb_error(ic, "Could not connect to server");
127                imc_logout(ic, TRUE);
128                return FALSE;
129        }
130
131        g_free(md->rxq);
132        md->rxlen = 0;
133        md->rxq = g_new0(char, 1);
134
135        if (md->uuid == NULL) {
136                struct utsname name;
137                sha1_state_t sha[1];
138
139                /* UUID == SHA1("BitlBee" + my hostname + MSN username) */
140                sha1_init(sha);
141                sha1_append(sha, (void *) "BitlBee", 7);
142                if (uname(&name) == 0) {
143                        sha1_append(sha, (void *) name.nodename, strlen(name.nodename));
144                }
145                sha1_append(sha, (void *) ic->acc->user, strlen(ic->acc->user));
146                md->uuid = sha1_random_uuid(sha);
147                memcpy(md->uuid, "b171be3e", 8);   /* :-P */
148        }
149
150        if (msn_ns_write_cmd(ic, "CNT", "CON", "<connect><ver>2</ver><agent><os>winnt</os><osVer>5.2</osVer><proc>x86</proc><lcid>en-us</lcid></agent></connect>")) {
151                if (!md->is_http) {
152                        md->inpa = b_input_add(md->fd, B_EV_IO_READ, msn_ns_callback, md);
153                }
154                imcb_log(ic, "Connected to server, waiting for reply");
155        }
156
157        return FALSE;
158}
159
160void msn_ns_close(struct msn_data *md)
161{
162        if (md->gw) {
163                msn_gw_free(md->gw);
164        }
165
166        if (md->ssl) {
167                ssl_disconnect(md->ssl);
168                b_event_remove(md->inpa);
169        }
170
171        md->ssl = NULL;
172        md->fd = md->inpa = -1;
173
174        g_free(md->rxq);
175        g_free(md->cmd_text);
176
177        md->rxlen = 0;
178        md->rxq = NULL;
179        md->cmd_text = NULL;
180}
181
182static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond)
183{
184        struct msn_data *md = data;
185        struct im_connection *ic = md->ic;
186        char *bytes;
187        int st;
188
189        if (md->is_http) {
190                st = msn_gw_read(md->gw, &bytes);
191        } else {
192                bytes = g_malloc(1024);
193                st = ssl_read(md->ssl, bytes, 1024);
194        }
195
196        if (st == 0 || (st < 0 && (md->is_http || !ssl_sockerr_again(md->ssl)))) {
197                imcb_error(ic, "Error while reading from server");
198                imc_logout(ic, TRUE);
199                g_free(bytes);
200                return FALSE;
201        }
202
203        msn_queue_feed(md, bytes, st);
204
205        g_free(bytes);
206
207        if (!md->is_http && ssl_pending(md->ssl)) {
208                return msn_ns_callback(data, source, cond);
209        }
210
211        return msn_handler(md);
212}
213
214int msn_ns_command(struct msn_data *md, char **cmd, int num_parts, char *msg, int msglen)
215{
216        struct im_connection *ic = md->ic;
217        struct xt_node *xml;
218
219        if (strcmp(cmd[0], "XFR") == 0) {
220                struct xt_node *target;
221                char *server, *p;
222                int port, st;
223
224                if (!(xml = xt_from_string(msg + 2, msglen - 2)) ||
225                    !(target = xt_find_node(xml->children, "target")) ||
226                    !(server = target->text) ||
227                    !(p = strchr(server, ':'))) {
228                        return 1;
229                }
230               
231                server = target->text;
232                *p = 0;
233                port = atoi(p + 1);
234
235                b_event_remove(md->inpa);
236                md->inpa = -1;
237
238                imcb_log(ic, "Transferring to other server");
239
240                st = msn_ns_connect(ic, server, port);
241
242                xt_free_node(xml);
243
244                return st;
245
246        } else if (strcmp(cmd[0], "CNT") == 0) {
247                msn_soap_passport_sso_request(ic);
248
249                /* continues in msn_auth_got_passport_token */
250
251        } else if (strcmp(cmd[0], "ATH") == 0) {
252                char *payload;
253
254                payload = g_markup_printf_escaped(
255                        "<msgr><ver>1</ver><client><name>Skype</name><ver>2/4.3.0.37/174</ver></client>"
256                        "<epid>%s</epid></msgr>\r\n",
257                        md->uuid);
258
259                msn_ns_write_cmd(ic, "BND", "CON\\MSGR", payload);
260
261                g_free(payload);
262
263        } else if (strcmp(cmd[0], "BND") == 0) {
264                imcb_log(ic, "Authenticated, getting buddy list");
265                msn_soap_memlist_request(ic);
266
267        } else if (strcmp(cmd[0], "ADL") == 0) {
268                if (num_parts >= 3 && strcmp(cmd[2], "OK") == 0) {
269                        msn_ns_send_adl(ic);
270                        return msn_ns_finish_login(ic);
271                }
272        } else if (strcmp(cmd[0], "CHL") == 0) {
273                char *resp;
274                int st;
275
276                if (num_parts < 3) {
277                        imcb_error(ic, "Syntax error");
278                        imc_logout(ic, TRUE);
279                        return(0);
280                }
281
282                resp = msn_p11_challenge(cmd[2]);
283
284                st =  msn_ns_write(ic, "QRY %d %s %zd\r\n%s",
285                                   ++md->trId, MSNP11_PROD_ID,
286                                   strlen(resp), resp);
287                g_free(resp);
288                return st;
289        } else if (strcmp(cmd[0], "QRY") == 0) {
290                /* CONGRATULATIONS */
291        } else if (strcmp(cmd[0], "OUT") == 0) {
292                imcb_error(ic, "Session terminated by remote server (%s)", cmd[1] ? cmd[1] : "reason unknown");
293                imc_logout(ic, TRUE);
294                return(0);
295        } else if (strcmp(cmd[0], "QNG") == 0) {
296                ic->flags |= OPT_PONGED;
297        } else if (g_ascii_isdigit(cmd[0][0])) {
298                int num = atoi(cmd[0]);
299                const struct msn_status_code *err = msn_status_by_number(num);
300
301                imcb_error(ic, "Error reported by MSN server: %s", err->text);
302
303                if (err->flags & STATUS_FATAL) {
304                        imc_logout(ic, TRUE);
305                        return(0);
306                }
307        } else if ((strcmp(cmd[0], "SDG") == 0) || (strcmp(cmd[0], "NFY") == 0)) {
308                msn_ns_structured_message(md, msg, msglen, cmd);
309        } else {
310                imcb_error(ic, "Received unknown command from main server: %s", cmd[0]);
311        }
312
313        return(1);
314}
315
316int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts)
317{
318        struct im_connection *ic = md->ic;
319        char *body;
320        int blen = 0;
321
322        if ((body = strstr(msg, "\r\n\r\n"))) {
323                body += 4;
324                blen = msglen - (body - msg);
325        }
326
327        if (strcmp(cmd[0], "MSG") == 0) {
328                if (g_strcasecmp(cmd[1], "Hotmail") == 0) {
329                        char *ct = get_rfc822_header(msg, "Content-Type:", msglen);
330
331                        if (!ct) {
332                                return(1);
333                        }
334
335                        if (g_strncasecmp(ct, "application/x-msmsgssystemmessage", 33) == 0) {
336                                char *mtype;
337                                char *arg1;
338
339                                if (!body) {
340                                        return(1);
341                                }
342
343                                mtype = get_rfc822_header(body, "Type:", blen);
344                                arg1 = get_rfc822_header(body, "Arg1:", blen);
345
346                                if (mtype && strcmp(mtype, "1") == 0) {
347                                        if (arg1) {
348                                                imcb_log(ic, "The server is going down for maintenance in %s minutes.",
349                                                         arg1);
350                                        }
351                                }
352
353                                g_free(arg1);
354                                g_free(mtype);
355                        } else if (g_strncasecmp(ct, "text/x-msmsgsprofile", 20) == 0) {
356                                /* We don't care about this profile for now... */
357                        } else if (g_strncasecmp(ct, "text/x-msmsgsinitialemailnotification", 37) == 0) {
358                                if (set_getbool(&ic->acc->set, "mail_notifications")) {
359                                        char *inbox = get_rfc822_header(body, "Inbox-Unread:", blen);
360                                        char *folders = get_rfc822_header(body, "Folders-Unread:", blen);
361
362                                        if (inbox && folders) {
363                                                imcb_notify_email(ic,
364                                                        "INBOX contains %s new messages, plus %s messages in other folders.", inbox,
365                                                        folders);
366                                        }
367
368                                        g_free(inbox);
369                                        g_free(folders);
370                                }
371                        } else if (g_strncasecmp(ct, "text/x-msmsgsemailnotification", 30) == 0) {
372                                if (set_getbool(&ic->acc->set, "mail_notifications")) {
373                                        char *from = get_rfc822_header(body, "From-Addr:", blen);
374                                        char *fromname = get_rfc822_header(body, "From:", blen);
375
376                                        if (from && fromname) {
377                                                imcb_notify_email(ic, "Received an e-mail message from %s <%s>.", fromname, from);
378                                        }
379
380                                        g_free(from);
381                                        g_free(fromname);
382                                }
383                        } else if (g_strncasecmp(ct, "text/x-msmsgsactivemailnotification", 35) == 0) {
384                                /* Notification that a message has been read... Ignore it */
385                        }
386
387                        g_free(ct);
388                }
389        } else if (strcmp(cmd[0], "ADL") == 0) {
390                struct xt_node *adl, *d, *c;
391
392                if (!(adl = xt_from_string(msg, msglen))) {
393                        return 1;
394                }
395
396                for (d = adl->children; d; d = d->next) {
397                        char *dn;
398                        if (strcmp(d->name, "d") != 0 ||
399                            (dn = xt_find_attr(d, "n")) == NULL) {
400                                continue;
401                        }
402                        for (c = d->children; c; c = c->next) {
403                                bee_user_t *bu;
404                                struct msn_buddy_data *bd;
405                                char *cn, *handle, *f, *l;
406                                int flags;
407
408                                if (strcmp(c->name, "c") != 0 ||
409                                    (l = xt_find_attr(c, "l")) == NULL ||
410                                    (cn = xt_find_attr(c, "n")) == NULL) {
411                                        continue;
412                                }
413
414                                /* FIXME: Use "t" here, guess I should just add it
415                                   as a prefix like elsewhere in the protocol. */
416                                handle = g_strdup_printf("%s@%s", cn, dn);
417                                if (!((bu = bee_user_by_handle(ic->bee, ic, handle)) ||
418                                      (bu = bee_user_new(ic->bee, ic, handle, 0)))) {
419                                        g_free(handle);
420                                        continue;
421                                }
422                                g_free(handle);
423                                bd = bu->data;
424
425                                if ((f = xt_find_attr(c, "f"))) {
426                                        http_decode(f);
427                                        imcb_rename_buddy(ic, bu->handle, f);
428                                }
429
430                                flags = atoi(l) & 15;
431                                if (bd->flags != flags) {
432                                        bd->flags = flags;
433                                        msn_buddy_ask(bu);
434                                }
435                        }
436                }
437        }
438
439        return 1;
440}
441
442static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd)
443{
444        char **parts = NULL;
445        char *semicolon = NULL;
446        char *action = NULL;
447        char *from = NULL;
448        char *who = NULL;
449
450        parts = g_strsplit(msg, "\r\n\r\n", 4);
451
452        if (!(from = get_rfc822_header(parts[0], "From", 0))) {
453                goto cleanup;
454        }
455
456        /* either the semicolon or the end of the string */
457        semicolon = strchr(from, ';') ? : (from + strlen(from));
458
459        who = g_strndup(from + 2, semicolon - from - 2);
460
461        if ((strcmp(cmd[0], "SDG") == 0) && (action = get_rfc822_header(parts[2], "Message-Type", 0))) {
462                msn_ns_sdg(md, who, parts, action);
463
464        } else if ((strcmp(cmd[0], "NFY") == 0) && (action = get_rfc822_header(parts[2], "Uri", 0))) {
465                gboolean is_put = (strcmp(cmd[1], "PUT") == 0);
466                msn_ns_nfy(md, who, parts, action, is_put);
467        }
468
469cleanup:
470        g_strfreev(parts);
471        g_free(action);
472        g_free(from);
473        g_free(who);
474}
475
476static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action)
477{
478        struct im_connection *ic = md->ic;
479
480        if (strcmp(action, "Control/Typing") == 0) {
481                imcb_buddy_typing(ic, who, OPT_TYPING);
482        } else if (strcmp(action, "Text") == 0) {
483                imcb_buddy_msg(ic, who, parts[3], 0, 0);
484        }
485}
486
487static void msn_ns_nfy(struct msn_data *md, char *who, char **parts, char *action, gboolean is_put)
488{
489        struct im_connection *ic = md->ic;
490        struct xt_node *body = NULL;
491        struct xt_node *s = NULL;
492        const char *state = NULL;
493        char *nick = NULL;
494        char *psm = NULL;
495        int flags = OPT_LOGGED_IN;
496
497        if (strcmp(action, "/user") != 0) {
498                return;
499        }
500
501        if (!(body = xt_from_string(parts[3], 0))) {
502                goto cleanup;
503        }
504
505        s = body->children;
506        while ((s = xt_find_node(s, "s"))) {
507                struct xt_node *s2;
508                char *n = xt_find_attr(s, "n");  /* service name: IM, PE, etc */
509
510                if (strcmp(n, "IM") == 0) {
511                        /* IM has basic presence information */
512                        if (!is_put) {
513                                /* NFY DEL with a <s> usually means log out from the last endpoint */
514                                flags &= ~OPT_LOGGED_IN;
515                                break;
516                        }
517
518                        s2 = xt_find_node(s->children, "Status");
519                        if (s2 && s2->text_len) {
520                                const struct msn_away_state *msn_state = msn_away_state_by_code(s2->text);
521                                state = msn_state->name;
522                                if (msn_state != msn_away_state_list) {
523                                        flags |= OPT_AWAY;
524                                }
525                        }
526                } else if (strcmp(n, "PE") == 0) {
527                        if ((s2 = xt_find_node(s->children, "PSM")) && s2->text_len) {
528                                psm = s2->text;
529                        }
530                        if ((s2 = xt_find_node(s->children, "FriendlyName")) && s2->text_len) {
531                                nick = s2->text;
532                        }
533                }
534                s = s->next;
535        }
536
537        imcb_buddy_status(ic, who, flags, state, psm);
538
539        if (nick) {
540                imcb_rename_buddy(ic, who, nick);
541        }
542
543cleanup:
544        xt_free_node(body);
545}
546
547void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error)
548{
549        struct msn_data *md;
550        char *payload = NULL;
551
552        /* Dead connection? */
553        if (g_slist_find(msn_connections, ic) == NULL) {
554                return;
555        }
556
557        md = ic->proto_data;
558
559        if (!token) {
560                imcb_error(ic, "Error during Passport authentication: %s", error);
561                imc_logout(ic, TRUE);
562        }
563
564        // ATH
565        payload = g_markup_printf_escaped(
566                "<user><ssl-compact-ticket>%s</ssl-compact-ticket>"
567                "<ssl-site-name>chatservice.live.com</ssl-site-name></user>",
568                md->tokens[0]);
569
570        msn_ns_write_cmd(ic, "ATH", "CON\\USER", payload);
571
572        g_free(payload);
573
574        /* continues in msn_ns_command */
575}
576
577void msn_auth_got_contact_list(struct im_connection *ic)
578{
579        /* Dead connection? */
580        if (g_slist_find(msn_connections, ic) == NULL) {
581                return;
582        }
583
584        msn_ns_send_adl_start(ic);
585        msn_ns_finish_login(ic);
586}
587
588static gboolean msn_ns_send_adl_1(gpointer key, gpointer value, gpointer data)
589{
590        struct xt_node *adl = data, *d, *c, *s;
591        struct bee_user *bu = value;
592        struct msn_buddy_data *bd = bu->data;
593        struct msn_data *md = bu->ic->proto_data;
594        char handle[strlen(bu->handle) + 1];
595        char *domain;
596        char l[4];
597
598        if ((bd->flags & (MSN_BUDDY_FL | MSN_BUDDY_AL)) == 0 || (bd->flags & MSN_BUDDY_ADL_SYNCED)) {
599                return FALSE;
600        }
601
602        strcpy(handle, bu->handle);
603        if ((domain = strchr(handle, '@')) == NULL) {    /* WTF */
604                return FALSE;
605        }
606        *domain = '\0';
607        domain++;
608
609        if ((d = adl->children) == NULL ||
610            g_strcasecmp(xt_find_attr(d, "n"), domain) != 0) {
611                d = xt_new_node("d", NULL, NULL);
612                xt_add_attr(d, "n", domain);
613                xt_insert_child(adl, d);
614        }
615
616        g_snprintf(l, sizeof(l), "%d", bd->flags & (MSN_BUDDY_FL | MSN_BUDDY_AL));
617        c = xt_new_node("c", NULL, NULL);
618        xt_add_attr(c, "n", handle);
619        xt_add_attr(c, "t", "1");   /* FIXME: Network type, i.e. 32 for Y!MSG */
620        s = xt_new_node("s", NULL, NULL);
621        xt_add_attr(s, "n", "IM");
622        xt_add_attr(s, "l", l);
623        xt_insert_child(c, s);
624        xt_insert_child(d, c);
625
626        /* Do this in batches of 100. */
627        bd->flags |= MSN_BUDDY_ADL_SYNCED;
628        return (--md->adl_todo % 140) == 0;
629}
630
631static void msn_ns_send_adl(struct im_connection *ic)
632{
633        struct xt_node *adl;
634        struct msn_data *md = ic->proto_data;
635        char *adls;
636
637        adl = xt_new_node("ml", NULL, NULL);
638        xt_add_attr(adl, "l", "1");
639        g_tree_foreach(md->domaintree, msn_ns_send_adl_1, adl);
640        if (adl->children == NULL) {
641                /* This tells the caller that we're done now. */
642                md->adl_todo = -1;
643                xt_free_node(adl);
644                return;
645        }
646
647        adls = xt_to_string(adl);
648        xt_free_node(adl);
649        msn_ns_write(ic, "ADL %d %zd\r\n%s", ++md->trId, strlen(adls), adls);
650        g_free(adls);
651}
652
653static void msn_ns_send_adl_start(struct im_connection *ic)
654{
655        struct msn_data *md;
656        GSList *l;
657
658        /* Dead connection? */
659        if (g_slist_find(msn_connections, ic) == NULL) {
660                return;
661        }
662
663        md = ic->proto_data;
664        md->adl_todo = 0;
665        for (l = ic->bee->users; l; l = l->next) {
666                bee_user_t *bu = l->data;
667                struct msn_buddy_data *bd = bu->data;
668
669                if (bu->ic != ic || (bd->flags & (MSN_BUDDY_FL | MSN_BUDDY_AL)) == 0) {
670                        continue;
671                }
672
673                bd->flags &= ~MSN_BUDDY_ADL_SYNCED;
674                md->adl_todo++;
675        }
676
677        msn_ns_send_adl(ic);
678}
679
680int msn_ns_finish_login(struct im_connection *ic)
681{
682        struct msn_data *md = ic->proto_data;
683
684        if (ic->flags & OPT_LOGGED_IN) {
685                return 1;
686        }
687
688        if (md->adl_todo < 0) {
689                md->flags |= MSN_DONE_ADL;
690        }
691
692        if ((md->flags & MSN_DONE_ADL) && (md->flags & MSN_GOT_PROFILE)) {
693                imcb_connected(ic);
694        }
695
696        return 1;
697}
698
699static int msn_ns_send_sdg(struct im_connection *ic, bee_user_t *bu, const char *message_type, const char *text)
700{
701        struct msn_data *md = ic->proto_data;
702        int retval = 0;
703        char *buf;
704
705        buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, message_type, strlen(text), text);
706        retval = msn_ns_write(ic, "SDG %d %zd\r\n%s", ++md->trId, strlen(buf), buf);
707        g_free(buf);
708        return retval;
709}
710
711int msn_ns_send_typing(struct im_connection *ic, bee_user_t *bu)
712{
713        return msn_ns_send_sdg(ic, bu, "Control/Typing", "");
714}
715
716int msn_ns_send_message(struct im_connection *ic, bee_user_t *bu, const char *text)
717{
718        return msn_ns_send_sdg(ic, bu, "Text", text);
719}
720
Note: See TracBrowser for help on using the repository browser.