annotate libpurple/protocols/msn/msg.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 0f94ec89f0bc 2ec94166be43
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file msg.c Message functions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15823
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31175
diff changeset
24
31196
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 31180
diff changeset
25 #include "internal.h"
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31175
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31175
diff changeset
27
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "msn.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "msg.h"
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
30 #include "msnutils.h"
31223
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 31211
diff changeset
31 #include "slpmsg.h"
31259
721653babbbe Destroy Part when the Message is destroyed.
masca@cpw.pidgin.im
parents: 31258
diff changeset
32 #include "slpmsg_part.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 msn_message_new(MsnMsgType type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 msg = g_new0(MsnMessage, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 msg->type = type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
42 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
43 purple_debug_info("msn", "message new (%p)(%d)\n", msg, type);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
45 msg->header_table = g_hash_table_new_full(g_str_hash, g_str_equal,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 g_free, g_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 msn_message_ref(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
31393
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
53 /**
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
54 * Destroys a message.
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
55 *
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
56 * @param msg The message to destroy.
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
57 */
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
58 static void
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 msn_message_destroy(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
63 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
64 purple_debug_info("msn", "message destroy (%p)\n", msg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
20991
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
66 g_free(msg->remote_user);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
67 g_free(msg->body);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
68 g_free(msg->content_type);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
69 g_free(msg->charset);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
71 g_hash_table_destroy(msg->header_table);
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
72 g_list_free(msg->header_list);
31483
05e05d96ba75 Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31481
diff changeset
73 if (msg->part)
05e05d96ba75 Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31481
diff changeset
74 msn_slpmsgpart_unref(msg->part);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 msn_message_ref(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 msg->ref_count++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
86 if (purple_debug_is_verbose())
31478
61db10475bed As Mark did before, we probably don't need a return value from these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31394
diff changeset
87 purple_debug_info("msn", "message ref (%p)[%u]\n", msg, msg->ref_count);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
31394
5eb2ea662d8c Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <mark@kingant.net>
parents: 31393
diff changeset
92 void
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 msn_message_unref(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 {
31394
5eb2ea662d8c Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <mark@kingant.net>
parents: 31393
diff changeset
95 g_return_if_fail(msg != NULL);
5eb2ea662d8c Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <mark@kingant.net>
parents: 31393
diff changeset
96 g_return_if_fail(msg->ref_count > 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 msg->ref_count--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27508
diff changeset
100 if (purple_debug_is_verbose())
31478
61db10475bed As Mark did before, we probably don't need a return value from these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31394
diff changeset
101 purple_debug_info("msn", "message unref (%p)[%u]\n", msg, msg->ref_count);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 if (msg->ref_count == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 msn_message_destroy(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 msn_message_new_plain(const char *message)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 MsnMessage *msg;
27896
d515f6c5e6f2 fix for msn file transfer breakage.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27842
diff changeset
111 char *message_cr, *message_cr2;
d515f6c5e6f2 fix for msn file transfer breakage.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27842
diff changeset
112 gsize len;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 msg = msn_message_new(MSN_MSG_TEXT);
24142
fb722b8b4c74 attempts to resend message on switchboard error once, tested by maually
Ka-Hing Cheung <khc@hxbc.us>
parents: 23097
diff changeset
115 msg->retries = 1;
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
116 msn_message_set_header(msg, "User-Agent", PACKAGE_NAME "/" VERSION);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 msn_message_set_content_type(msg, "text/plain");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 msn_message_set_charset(msg, "UTF-8");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 msn_message_set_flag(msg, 'A');
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
120 msn_message_set_header(msg, "X-MMS-IM-Format",
24945
b0e069922896 Fixes #7373, the new live messenger client now sends Segoe UI as the default
Ka-Hing Cheung <khc@hxbc.us>
parents: 24679
diff changeset
121 "FN=Segoe%20UI; EF=; CO=0; CS=1;PF=0");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
123 message_cr = purple_str_add_cr(message);
27896
d515f6c5e6f2 fix for msn file transfer breakage.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27842
diff changeset
124 message_cr2 = botch_utf((gchar *)message_cr, -1, &len);
d515f6c5e6f2 fix for msn file transfer breakage.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27842
diff changeset
125 msn_message_set_bin_data(msg, message_cr2, len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 g_free(message_cr);
27896
d515f6c5e6f2 fix for msn file transfer breakage.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27842
diff changeset
127 g_free(message_cr2);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 msn_message_new_msnslp(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 msg = msn_message_new(MSN_MSG_SLP);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
139 msn_message_set_header(msg, "User-Agent", NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 msn_message_set_flag(msg, 'D');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 msn_message_set_content_type(msg, "application/x-msnmsgrp2p");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 msn_message_new_nudge(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 msg = msn_message_new(MSN_MSG_NUDGE);
23097
56d958e7b7d1 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <stu@nosnilmot.com>
parents: 23013
diff changeset
153 msn_message_set_content_type(msg, "text/x-msnmsgr-datacast");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 msn_message_set_flag(msg, 'N');
23097
56d958e7b7d1 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <stu@nosnilmot.com>
parents: 23013
diff changeset
155 msn_message_set_bin_data(msg, "ID: 1\r\n", 7);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 msn_message_parse_payload(MsnMessage *msg,
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
162 const char *payload, size_t payload_len,
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
163 const char *line_dem,const char *body_dem)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 char *tmp_base, *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 const char *content_type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 char *end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 char **elems, **cur, **tokens;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 g_return_if_fail(payload != NULL);
24331
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24142
diff changeset
171 tmp_base = tmp = g_malloc(payload_len + 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 memcpy(tmp_base, payload, payload_len);
24331
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24142
diff changeset
173 tmp_base[payload_len] = '\0';
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
175 /* Find the end of the headers */
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
176 end = strstr(tmp, body_dem);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 /* TODO? some clients use \r delimiters instead of \r\n, the official client
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 * doesn't send such messages, but does handle receiving them. We'll just
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 * avoid crashing for now */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 if (end == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 g_free(tmp_base);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 g_return_if_reached();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 *end = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
186 /* Split the headers and parse each one */
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
187 elems = g_strsplit(tmp, line_dem, 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 for (cur = elems; *cur != NULL; cur++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 const char *key, *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
24679
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
192 /* If this line starts with whitespace, it's been folded from the
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
193 previous line and won't have ':'. */
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
194 if ((**cur == ' ') || (**cur == '\t')) {
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
195 tokens = g_strsplit(g_strchug(*cur), "=\"", 2);
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
196 key = tokens[0];
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
197 value = tokens[1];
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
198
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
199 /* The only one I care about is 'boundary' (which is folded from
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
200 the key 'Content-Type'), so only process that. */
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
201 if (!strcmp(key, "boundary")) {
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
202 char *end = strchr(value, '\"');
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
203 *end = '\0';
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
204 msn_message_set_header(msg, key, value);
24679
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
205 }
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
206
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
207 g_strfreev(tokens);
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
208 continue;
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
209 }
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24331
diff changeset
210
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 tokens = g_strsplit(*cur, ": ", 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 key = tokens[0];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 value = tokens[1];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
216 /*if not MIME content ,then return*/
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 if (!strcmp(key, "MIME-Version"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 g_strfreev(tokens);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 if (!strcmp(key, "Content-Type"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 char *charset, *c;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 if ((c = strchr(value, ';')) != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 if ((charset = strchr(c, '=')) != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 charset++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 msn_message_set_charset(msg, charset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 *c = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 msn_message_set_content_type(msg, value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 {
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
242 msn_message_set_header(msg, key, value);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_strfreev(tokens);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 g_strfreev(elems);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 /* Proceed to the end of the "\r\n\r\n" */
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
250 tmp = end + strlen(body_dem);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 /* Now we *should* be at the body. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 content_type = msn_message_get_content_type(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
31225
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
255 if (payload_len - (tmp - tmp_base) > 0) {
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
256 msg->body_len = payload_len - (tmp - tmp_base);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
257 g_free(msg->body);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
258 msg->body = g_malloc(msg->body_len + 1);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
259 memcpy(msg->body, tmp, msg->body_len);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
260 msg->body[msg->body_len] = '\0';
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
261 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262
31225
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
263 if ((!content_type || !strcmp(content_type, "text/plain"))
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
264 && msg->charset == NULL) {
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
265 char *body = g_convert(msg->body, msg->body_len, "UTF-8",
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
266 "ISO-8859-1", NULL, &msg->body_len, NULL);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
267 g_free(msg->body);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
268 msg->body = body;
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 31223
diff changeset
269 msg->charset = g_strdup("UTF-8");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 g_free(tmp_base);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 msn_message_new_from_cmd(MsnSession *session, MsnCommand *cmd)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 g_return_val_if_fail(cmd != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 msg = msn_message_new(MSN_MSG_UNKNOWN);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 msg->remote_user = g_strdup(cmd->params[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 /* msg->size = atoi(cmd->params[2]); */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 msg->cmd = cmd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 msn_message_gen_payload(MsnMessage *msg, size_t *ret_size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 char *n, *base, *end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 int len;
19731
97559afd70e4 Silence the warning that body_len might be used uninitialized in msn_message_gen_payload().
Evan Schoenberg <evan.s@dreskin.net>
parents: 19680
diff changeset
297 size_t body_len = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 const void *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 len = MSN_BUF_LEN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 base = n = end = g_malloc(len + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 end += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 /* Standard header. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 if (msg->charset == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 g_snprintf(n, len,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 "Content-Type: %s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 msg->content_type);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 g_snprintf(n, len,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 "Content-Type: %s; charset=%s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 msg->content_type, msg->charset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 n += strlen(n);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
325 for (l = msg->header_list; l != NULL; l = l->next)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 const char *key;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 const char *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 key = l->data;
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
331 value = msn_message_get_header_value(msg, key);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 g_snprintf(n, end - n, "%s: %s\r\n", key, value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 n += strlen(n);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 n += g_strlcpy(n, "\r\n", end - n);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 body = msn_message_get_bin_data(msg, &body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
341 if (body != NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 {
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
343 memcpy(n, body, body_len);
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
344 n += body_len;
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
345 *n = '\0';
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 if (ret_size != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 *ret_size = n - base;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 if (*ret_size > 1664)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 *ret_size = 1664;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 return base;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 msn_message_set_flag(MsnMessage *msg, char flag)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 g_return_if_fail(flag != 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 msg->flag = flag;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 char
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 msn_message_get_flag(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 g_return_val_if_fail(msg != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 return msg->flag;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 msn_message_set_bin_data(MsnMessage *msg, const void *data, size_t len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 /* There is no need to waste memory on data we cannot send anyway */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 if (len > 1664)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 len = 1664;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 if (msg->body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 g_free(msg->body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 if (data != NULL && len > 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 {
24331
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24142
diff changeset
390 msg->body = g_malloc(len + 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 memcpy(msg->body, data, len);
24331
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24142
diff changeset
392 msg->body[len] = '\0';
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 msg->body_len = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 msg->body = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 msg->body_len = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 const void *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 if (len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 *len = msg->body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 return msg->body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 msn_message_set_content_type(MsnMessage *msg, const char *type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417
20991
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
418 g_free(msg->content_type);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
419 msg->content_type = g_strdup(type);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 msn_message_get_content_type(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 return msg->content_type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 msn_message_set_charset(MsnMessage *msg, const char *charset)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
20991
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
435 g_free(msg->charset);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
436 msg->charset = g_strdup(charset);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 msn_message_get_charset(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 return msg->charset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 void
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
448 msn_message_set_header(MsnMessage *msg, const char *name, const char *value)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 const char *temp;
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
451 char *new_name;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 g_return_if_fail(msg != NULL);
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
454 g_return_if_fail(name != NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
456 temp = msn_message_get_header_value(msg, name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 if (value == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 if (temp != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
464 for (l = msg->header_list; l != NULL; l = l->next)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 {
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
466 if (!g_ascii_strcasecmp(l->data, name))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 {
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
468 msg->header_list = g_list_remove(msg->header_list, l->data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
474 g_hash_table_remove(msg->header_table, name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
480 new_name = g_strdup(name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
482 g_hash_table_insert(msg->header_table, new_name, g_strdup(value));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 if (temp == NULL)
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
485 msg->header_list = g_list_append(msg->header_list, new_name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 const char *
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
489 msn_message_get_header_value(const MsnMessage *msg, const char *name)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 g_return_val_if_fail(msg != NULL, NULL);
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
492 g_return_val_if_fail(name != NULL, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
494 return g_hash_table_lookup(msg->header_table, name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 GHashTable *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 msn_message_get_hashtable_from_body(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 GHashTable *table;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 char **elems, **cur, **tokens, *body_str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 body = msn_message_get_bin_data(msg, &body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 g_return_val_if_fail(body != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 body_str = g_strndup(body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 elems = g_strsplit(body_str, "\r\n", 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 g_free(body_str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 for (cur = elems; *cur != NULL; cur++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 if (**cur == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 tokens = g_strsplit(*cur, ": ", 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523
20935
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
524 if (tokens[0] != NULL && tokens[1] != NULL) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 g_hash_table_insert(table, tokens[0], tokens[1]);
20935
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
526 g_free(tokens);
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
527 } else
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
528 g_strfreev(tokens);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 g_strfreev(elems);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 return table;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 msn_message_to_string(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 g_return_val_if_fail(msg != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 g_return_val_if_fail(msg->type == MSN_MSG_TEXT, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 body = msn_message_get_bin_data(msg, &body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 return g_strndup(body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 msn_message_show_readable(MsnMessage *msg, const char *info,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 gboolean text_body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 GString *str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 str = g_string_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 /* Standard header. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 if (msg->charset == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 g_string_append_printf(str,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 "Content-Type: %s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 msg->content_type);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 g_string_append_printf(str,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 "Content-Type: %s; charset=%s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 msg->content_type, msg->charset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
579 for (l = msg->header_list; l; l = l->next)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 char *key;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 const char *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 key = l->data;
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
585 value = msn_message_get_header_value(msg, key);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 g_string_append_printf(str, "%s: %s\r\n", key, value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 body = msn_message_get_bin_data(msg, &body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
594 if (body != NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 {
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
596 if (msg->type == MSN_MSG_TEXT)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 g_string_append_len(str, body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 }
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
601 else
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
602 {
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
603 size_t i;
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
604 for (i = 0; i < body_len; i++, body++)
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
605 {
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
606 g_string_append_printf(str, "%02x ", (unsigned char)*body);
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
607 if (i % 16 == 0 && i != 0)
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
608 g_string_append_c(str, '\n');
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
609 }
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
610 g_string_append_c(str, '\n');
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
611 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
614 purple_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 g_string_free(str, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
618
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
619 /**************************************************************************
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
620 * Message Handlers
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
621 **************************************************************************/
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
622 void
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
623 msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
624 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
625 PurpleConnection *gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
626 const char *body;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
627 char *body_str;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
628 char *body_enc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
629 char *body_final;
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
630 char *yaz_body_final;
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
631 size_t body_len, new_len;
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
632 const char *passport;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
633 const char *value;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
634
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
635 gc = purple_account_get_connection(cmdproc->session->account);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
636
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
637 body = msn_message_get_bin_data(msg, &body_len);
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
638 body_str = sanitize_utf(body, body_len, &new_len);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
639 body_enc = g_markup_escape_text(body_str, -1);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
640 g_free(body_str);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
641
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
642 passport = msg->remote_user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
643
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
644 if (!strcmp(passport, "messenger@microsoft.com") &&
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
645 strstr(body, "immediate security update"))
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
646 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
647 return;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
648 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
649
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
650 #if 0
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
651 if ((value = msn_message_get_header_value(msg, "User-Agent")) != NULL)
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
652 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
653 purple_debug_misc("msn", "User-Agent = '%s'\n", value);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
654 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
655 #endif
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
656
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
657 if ((value = msn_message_get_header_value(msg, "X-MMS-IM-Format")) != NULL)
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
658 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
659 char *pre, *post;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
660
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
661 msn_parse_format(value, &pre, &post);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
662
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
663 body_final = g_strdup_printf("%s%s%s", pre ? pre : "",
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
664 body_enc ? body_enc : "", post ? post : "");
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
665
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
666 g_free(pre);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
667 g_free(post);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
668 g_free(body_enc);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
669 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
670 else
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
671 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
672 body_final = body_enc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
673 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
674
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
675 /* yaz */
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
676 /* replace 0D 0A with <br> */
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
677 yaz_body_final = purple_strreplace(body_final, "\r\n", "<br>");
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
678 // purple_debug_info("yaz msn", "yaz_body_final=%s\n", yaz_body_final);
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
679 g_free(body_final);
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
680 body_final = yaz_body_final;
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
681
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
682 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
683 MsnSwitchBoard *swboard = cmdproc->data;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
684
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
685 swboard->flag |= MSN_SB_FLAG_IM;
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
686
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
687 if (swboard->current_users > 1 ||
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
688 ((swboard->conv != NULL) &&
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
689 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
690 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
691 /* If current_users is always ok as it should then there is no need to
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
692 * check if this is a chat. */
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
693 if (swboard->current_users <= 1)
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
694 purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
695 swboard->current_users);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
696
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
697 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
698 time(NULL));
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
699 if (swboard->conv == NULL)
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
700 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
701 swboard->conv = purple_find_chat(gc, swboard->chat_id);
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
702 swboard->flag |= MSN_SB_FLAG_IM;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
703 }
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
704 }
32767
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32708
diff changeset
705 else if (!g_str_equal(passport, purple_account_get_username(purple_connection_get_account(gc))))
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
706 {
31172
7fa07adbe482 Don't treat messages got from ourself from a switchboard like a new message. This fixes the multiple conversation open with ourself.
masca@cpw.pidgin.im
parents: 31168
diff changeset
707 /* Don't im ourselves ... */
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
708 serv_got_im(gc, passport, body_final, 0, time(NULL));
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
709 if (swboard->conv == NULL)
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
710 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
711 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
27928
13c2fb2da4eb - moved msn_plain_msg() and msn_control_msg() as upstream.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27927
diff changeset
712 passport, purple_connection_get_account(gc));
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
713 swboard->flag |= MSN_SB_FLAG_IM;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
714 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
715 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
716
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
717 } else {
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
718 serv_got_im(gc, passport, body_final, 0, time(NULL));
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
719 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
720
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
721 g_free(body_final);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
722 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
723
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
724 void
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
725 msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
726 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
727 PurpleConnection *gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
728 char *passport;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
729
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
730 gc = purple_account_get_connection(cmdproc->session->account);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
731 passport = msg->remote_user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
732
31132
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 28211
diff changeset
733 if (msn_message_get_header_value(msg, "TypingUser") == NULL)
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
734 return;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
735
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
736 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
737 MsnSwitchBoard *swboard = cmdproc->data;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
738
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
739 if (swboard->current_users == 1)
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
740 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
741 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
742 PURPLE_TYPING);
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
743 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
744
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
745 } else {
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
746 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
747 PURPLE_TYPING);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
748 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
749 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
750
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
751 static void
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
752 datacast_inform_user(MsnSwitchBoard *swboard, const char *who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
753 const char *msg, const char *filename)
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
754 {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
755 char *username, *str;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
756 PurpleAccount *account;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
757 PurpleBuddy *b;
30316
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
758 PurpleConnection *pc;
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
759 gboolean chat;
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
760
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
761 account = swboard->session->account;
30316
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
762 pc = purple_account_get_connection(account);
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
763
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
764 if ((b = purple_find_buddy(account, who)) != NULL)
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
765 username = g_markup_escape_text(purple_buddy_get_alias(b), -1);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
766 else
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
767 username = g_markup_escape_text(who, -1);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
768 str = g_strdup_printf(msg, username, filename);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
769 g_free(username);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
770
30316
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
771 swboard->flag |= MSN_SB_FLAG_IM;
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
772 if (swboard->current_users > 1)
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
773 chat = TRUE;
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
774 else
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
775 chat = FALSE;
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
776
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
777 if (swboard->conv == NULL) {
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
778 if (chat)
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
779 swboard->conv = purple_find_chat(purple_account_get_connection(account), swboard->chat_id);
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
780 else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
781 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
782 who, account);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
783 if (swboard->conv == NULL)
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
784 swboard->conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
785 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
786 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
787
30316
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
788 if (chat)
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
789 serv_got_chat_in(pc,
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
790 purple_conv_chat_get_id(PURPLE_CONV_CHAT(swboard->conv)),
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
791 who, PURPLE_MESSAGE_RECV|PURPLE_MESSAGE_SYSTEM, str,
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
792 time(NULL));
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
793 else
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
794 serv_got_im(pc, who, str, PURPLE_MESSAGE_RECV|PURPLE_MESSAGE_SYSTEM,
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30194
diff changeset
795 time(NULL));
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
796 g_free(str);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
797
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
798 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
799
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
800 /* TODO: Make these not be such duplicates of each other */
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
801 static void
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
802 got_wink_cb(MsnSlpCall *slpcall, const guchar *data, gsize size)
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
803 {
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
804 FILE *f = NULL;
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
805 char *path = NULL;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
806 const char *who = slpcall->slplink->remote_user;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
807 purple_debug_info("msn", "Received wink from %s\n", who);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
808
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
809 if ((f = purple_mkstemp(&path, TRUE)) &&
30194
0f1df8098d00 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30193
diff changeset
810 (fwrite(data, 1, size, f) == size)) {
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
811 datacast_inform_user(slpcall->slplink->swboard,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
812 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
813 _("%s sent a wink. <a href='msn-wink://%s'>Click here to play it</a>"),
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
814 path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
815 } else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
816 purple_debug_error("msn", "Couldn\'t create temp file to store wink\n");
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
817 datacast_inform_user(slpcall->slplink->swboard,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
818 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
819 _("%s sent a wink, but it could not be saved"),
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
820 NULL);
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
821 }
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
822 if (f)
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
823 fclose(f);
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
824 g_free(path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
825 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
826
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
827 static void
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
828 got_voiceclip_cb(MsnSlpCall *slpcall, const guchar *data, gsize size)
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
829 {
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
830 FILE *f = NULL;
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
831 char *path = NULL;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
832 const char *who = slpcall->slplink->remote_user;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
833 purple_debug_info("msn", "Received voice clip from %s\n", who);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
834
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
835 if ((f = purple_mkstemp(&path, TRUE)) &&
30194
0f1df8098d00 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30193
diff changeset
836 (fwrite(data, 1, size, f) == size)) {
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
837 datacast_inform_user(slpcall->slplink->swboard,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
838 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
839 _("%s sent a voice clip. <a href='audio://%s'>Click here to play it</a>"),
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
840 path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
841 } else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
842 purple_debug_error("msn", "Couldn\'t create temp file to store sound\n");
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
843 datacast_inform_user(slpcall->slplink->swboard,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
844 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
845 _("%s sent a voice clip, but it could not be saved"),
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
846 NULL);
30193
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
847 }
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
848 if (f)
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29704
diff changeset
849 fclose(f);
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
850 g_free(path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
851 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
852
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
853 void
31250
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
854 msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
855 {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
856 MsnSession *session;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
857 MsnSlpLink *slplink;
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
858 MsnP2PVersion p2p;
31250
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
859
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
860 session = cmdproc->servconn->session;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
861 slplink = msn_session_get_slplink(session, msg->remote_user);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
862
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
863 if (slplink->swboard == NULL)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
864 {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
865 /*
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
866 * We will need swboard in order to change its flags. If its
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
867 * NULL, something has probably gone wrong earlier on. I
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
868 * didn't want to do this, but MSN 7 is somehow causing us
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
869 * to crash here, I couldn't reproduce it to debug more,
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
870 * and people are reporting bugs. Hopefully this doesn't
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
871 * cause more crashes. Stu.
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
872 */
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
873 if (cmdproc->data == NULL)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
874 g_warning("msn_p2p_msg cmdproc->data was NULL\n");
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
875 else {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
876 slplink->swboard = (MsnSwitchBoard *)cmdproc->data;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
877 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
878 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
879 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
880
32036
cf702c6ab9e7 Getting the P2P version is probably the slplink's job, since it has
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32033
diff changeset
881 p2p = msn_slplink_get_p2p_version(slplink);
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
882 msg->part = msn_slpmsgpart_new_from_data(p2p, msg->body, msg->body_len);
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
883
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
884 if (msg->part)
31296
2d00d29a45fd Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
masca@cpw.pidgin.im
parents: 31288
diff changeset
885 msn_slplink_process_msg(slplink, msg->part);
32033
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
886 else
a406398412ee I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
887 purple_debug_warning("msn", "P2P message failed to parse.\n");
31250
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
888 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
889
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
890 static void
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
891 got_emoticon(MsnSlpCall *slpcall,
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
892 const guchar *data, gsize size)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
893 {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
894 PurpleConversation *conv;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
895 MsnSwitchBoard *swboard;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
896
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
897 swboard = slpcall->slplink->swboard;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
898 conv = swboard->conv;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
899
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
900 if (conv) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
901 /* FIXME: it would be better if we wrote the data as we received it
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
902 instead of all at once, calling write multiple times and
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
903 close once at the very end
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
904 */
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
905 purple_conv_custom_smiley_write(conv, slpcall->data_info, data, size);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
906 purple_conv_custom_smiley_close(conv, slpcall->data_info );
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
907 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
908 if (purple_debug_is_verbose())
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
909 purple_debug_info("msn", "Got smiley: %s\n", slpcall->data_info);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
910 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
911
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
912 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
913 {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
914 MsnSession *session;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
915 MsnSlpLink *slplink;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
916 MsnSwitchBoard *swboard;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
917 MsnObject *obj;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
918 char **tokens;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
919 char *smile, *body_str;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
920 const char *body, *who, *sha1;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
921 guint tok;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
922 size_t body_len;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
923
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
924 PurpleConversation *conv;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
925
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
926 session = cmdproc->servconn->session;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
927
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
928 if (!purple_account_get_bool(session->account, "custom_smileys", TRUE))
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
929 return;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
930
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
931 swboard = cmdproc->data;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
932 conv = swboard->conv;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
933
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
934 body = msn_message_get_bin_data(msg, &body_len);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
935 if (!body || !body_len)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
936 return;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
937 body_str = g_strndup(body, body_len);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
938
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
939 /* MSN Messenger 7 may send more than one MSNObject in a single message...
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
940 * Maybe 10 tokens is a reasonable max value. */
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
941 tokens = g_strsplit(body_str, "\t", 10);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
942
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
943 g_free(body_str);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
944
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
945 for (tok = 0; tok < 9; tok += 2) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
946 if (tokens[tok] == NULL || tokens[tok + 1] == NULL) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
947 break;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
948 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
949
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
950 smile = tokens[tok];
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
951 obj = msn_object_new_from_string(purple_url_decode(tokens[tok + 1]));
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
952
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
953 if (obj == NULL)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
954 break;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
955
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
956 who = msn_object_get_creator(obj);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
957 sha1 = msn_object_get_sha1(obj);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
958
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
959 slplink = msn_session_get_slplink(session, who);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
960 if (slplink->swboard != swboard) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
961 if (slplink->swboard != NULL)
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
962 /*
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
963 * Apparently we're using a different switchboard now or
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
964 * something? I don't know if this is normal, but it
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
965 * definitely happens. So make sure the old switchboard
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
966 * doesn't still have a reference to us.
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
967 */
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
968 slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
969 slplink->swboard = swboard;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
970 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
971 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
972
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
973 /* If the conversation doesn't exist then this is a custom smiley
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
974 * used in the first message in a MSN conversation: we need to create
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
975 * the conversation now, otherwise the custom smiley won't be shown.
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
976 * This happens because every GtkIMHtml has its own smiley tree: if
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
977 * the conversation doesn't exist then we cannot associate the new
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
978 * smiley with its GtkIMHtml widget. */
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
979 if (!conv) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
980 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, session->account, who);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
981 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
982
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
983 if (purple_conv_custom_smiley_add(conv, smile, "sha1", sha1, TRUE)) {
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
984 msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
985 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
986
32489
60d879806964 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32036
diff changeset
987 msn_object_destroy(obj, FALSE);
31250
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
988 obj = NULL;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
989 who = NULL;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
990 sha1 = NULL;
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
991 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
992 g_strfreev(tokens);
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
993 }
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
994
623e38669111 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
masca@cpw.pidgin.im
parents: 31239
diff changeset
995 void
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
996 msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
997 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
998 GHashTable *body;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
999 const char *id;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1000 body = msn_message_get_hashtable_from_body(msg);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1001
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1002 id = g_hash_table_lookup(body, "ID");
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1003
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1004 if (!strcmp(id, "1")) {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1005 /* Nudge */
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1006 PurpleAccount *account;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1007 const char *user;
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
1008 PurpleConnection *gc;
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1009
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1010 account = cmdproc->session->account;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1011 user = msg->remote_user;
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
1012 gc = purple_account_get_connection(account);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1013
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1014 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1015 MsnSwitchBoard *swboard = cmdproc->data;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1016 if (swboard->current_users > 1 ||
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1017 ((swboard->conv != NULL) &&
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1018 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
1019 purple_prpl_got_attention_in_chat(gc, swboard->chat_id, user, MSN_NUDGE);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1020
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1021 else
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
1022 purple_prpl_got_attention(gc, user, MSN_NUDGE);
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1023 } else {
32708
10e5000326a5 Convert code to use the purple_account accessor functions.
andrew.victor@mxit.com
parents: 32489
diff changeset
1024 purple_prpl_got_attention(gc, user, MSN_NUDGE);
25039
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25038
diff changeset
1025 }
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1026
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1027 } else if (!strcmp(id, "2")) {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1028 /* Wink */
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1029 MsnSession *session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1030 MsnSlpLink *slplink;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1031 MsnObject *obj;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1032 const char *who;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1033 const char *data;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1034
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1035 session = cmdproc->session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1036
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1037 data = g_hash_table_lookup(body, "Data");
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1038 obj = msn_object_new_from_string(data);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1039 who = msn_object_get_creator(obj);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1040
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1041 slplink = msn_session_get_slplink(session, who);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1042 msn_slplink_request_object(slplink, data, got_wink_cb, NULL, obj);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1043
32489
60d879806964 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32036
diff changeset
1044 msn_object_destroy(obj, FALSE);
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1045
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1046
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1047 } else if (!strcmp(id, "3")) {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1048 /* Voiceclip */
27508
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1049 MsnSession *session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1050 MsnSlpLink *slplink;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1051 MsnObject *obj;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1052 const char *who;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1053 const char *data;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1054
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1055 session = cmdproc->session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1056
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1057 data = g_hash_table_lookup(body, "Data");
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1058 obj = msn_object_new_from_string(data);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1059 who = msn_object_get_creator(obj);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1060
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1061 slplink = msn_session_get_slplink(session, who);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1062 msn_slplink_request_object(slplink, data, got_voiceclip_cb, NULL, obj);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27374
diff changeset
1063
32489
60d879806964 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32036
diff changeset
1064 msn_object_destroy(obj, FALSE);
25038
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1065
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1066 } else if (!strcmp(id, "4")) {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1067 /* Action */
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1068
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1069 } else {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1070 purple_debug_warning("msn", "Got unknown datacast with ID %s.\n", id);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1071 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1072
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1073 g_hash_table_destroy(body);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1074 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24945
diff changeset
1075
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1076 void
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1077 msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1078 {
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1079 GHashTable *body;
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1080 const gchar *command;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1081 const gchar *cookie;
28211
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1082 gboolean accepted = FALSE;
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1083
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1084 g_return_if_fail(cmdproc != NULL);
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1085 g_return_if_fail(msg != NULL);
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1086
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1087 body = msn_message_get_hashtable_from_body(msg);
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1088
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1089 if (body == NULL) {
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1090 purple_debug_warning("msn",
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1091 "Unable to parse invite msg body.\n");
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1092 return;
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1093 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
1094
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1095 /*
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1096 * GUID is NOT always present but Invitation-Command and Invitation-Cookie
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1097 * are mandatory.
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1098 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1099 command = g_hash_table_lookup(body, "Invitation-Command");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1100 cookie = g_hash_table_lookup(body, "Invitation-Cookie");
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1101
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1102 if (command == NULL || cookie == NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1103 purple_debug_warning("msn",
30446
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30433
diff changeset
1104 "Invalid invitation message: either Invitation-Command "
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30433
diff changeset
1105 "or Invitation-Cookie is missing or invalid.\n"
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1106 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1107 return;
28211
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1108
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1109 } else if (!strcmp(command, "INVITE")) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1110 const gchar *guid = g_hash_table_lookup(body, "Application-GUID");
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
1111
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1112 if (guid == NULL) {
30489
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1113 purple_debug_warning("msn",
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1114 "Invite msg missing Application-GUID.\n");
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1115
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1116 accepted = TRUE;
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1117
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1118 } else if (!strcmp(guid, MSN_FT_GUID)) {
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1119
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1120 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1121 purple_debug_info("msn", "Computer call\n");
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1122
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1123 if (cmdproc->session) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1124 PurpleConversation *conv = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1125 gchar *from = msg->remote_user;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1126 gchar *buf = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1127
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1128 if (from)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1129 conv = purple_find_conversation_with_account(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1130 PURPLE_CONV_TYPE_IM, from,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1131 cmdproc->session->account);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1132 if (conv)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1133 buf = g_strdup_printf(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1134 _("%s sent you a voice chat "
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1135 "invite, which is not yet "
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1136 "supported."), from);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1137 if (buf) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1138 purple_conversation_write(conv, NULL, buf,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1139 PURPLE_MESSAGE_SYSTEM |
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1140 PURPLE_MESSAGE_NOTIFY,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1141 time(NULL));
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1142 g_free(buf);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1143 }
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1144 }
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1145 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1146 const gchar *application = g_hash_table_lookup(body, "Application-Name");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1147 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n",
30446
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30433
diff changeset
1148 guid, application ? application : "(null)");
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1149 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 31483
diff changeset
1150
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1151 if (!accepted) {
28211
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1152 MsnSwitchBoard *swboard = cmdproc->data;
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1153 char *text;
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1154 MsnMessage *cancel;
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1155
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1156 cancel = msn_message_new(MSN_MSG_TEXT);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1157 msn_message_set_content_type(cancel, "text/x-msmsgsinvite");
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1158 msn_message_set_charset(cancel, "UTF-8");
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1159 msn_message_set_flag(cancel, 'U');
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1160
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1161 text = g_strdup_printf("Invitation-Command: CANCEL\r\n"
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1162 "Invitation-Cookie: %s\r\n"
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1163 "Cancel-Code: REJECT_NOT_INSTALLED\r\n",
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1164 cookie);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1165 msn_message_set_bin_data(cancel, text, strlen(text));
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1166 g_free(text);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1167
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1168 msn_switchboard_send_msg(swboard, cancel, TRUE);
31393
b4285ea42b6e msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <mark@kingant.net>
parents: 31376
diff changeset
1169 msn_message_unref(cancel);
28211
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1170 }
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1171
30489
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1172 } else if (!strcmp(command, "CANCEL")) {
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1173 const gchar *code = g_hash_table_lookup(body, "Cancel-Code");
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1174 purple_debug_info("msn", "MSMSGS invitation cancelled: %s.\n",
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1175 code ? code : "no reason given");
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30480
diff changeset
1176
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1177 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1178 /*
30446
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30433
diff changeset
1179 * Some other already established invitation session.
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1180 * Can be retrieved by Invitation-Cookie.
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29704
diff changeset
1181 */
28211
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1182 }
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28210
diff changeset
1183
26600
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1184 g_hash_table_destroy(body);
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1185 }
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25095
diff changeset
1186
27374
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1187 /* Only called from chats. Handwritten messages for IMs come as a SLP message */
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1188 void
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1189 msn_handwritten_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1190 {
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1191 const char *body;
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1192 size_t body_len;
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1193
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1194 body = msn_message_get_bin_data(msg, &body_len);
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1195 msn_switchboard_show_ink(cmdproc->data, msg->remote_user, body);
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1196 }
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26600
diff changeset
1197