annotate libpurple/protocols/msn/msg.c @ 30801:fd8abea40a0d

Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
author masca@cpw.pidgin.im
date Wed, 16 Jun 2010 22:12:07 +0000
parents 155db1253acf
children 623e38669111
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
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 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
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
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15822
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30737
diff changeset
24
30758
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 30742
diff changeset
25 #include "internal.h"
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30737
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30737
diff changeset
27
15373
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"
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
30 #include "msnutils.h"
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
31 #include "slpmsg.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 msn_message_new(MsnMsgType type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 msg = g_new0(MsnMessage, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 msg->type = type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
27432
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27431
diff changeset
41 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: 27431
diff changeset
42 purple_debug_info("msn", "message new (%p)(%d)\n", msg, type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
44 msg->header_table = g_hash_table_new_full(g_str_hash, g_str_equal,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 g_free, g_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 msn_message_ref(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 }
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 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 msn_message_destroy(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 if (msg->ref_count > 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 msn_message_unref(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 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
27432
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27431
diff changeset
64 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: 27431
diff changeset
65 purple_debug_info("msn", "message destroy (%p)\n", msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
20991
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->remote_user);
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->body);
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->content_type);
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
70 g_free(msg->charset);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
72 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: 27868
diff changeset
73 g_list_free(msg->header_list);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 }
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 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 msn_message_ref(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 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
82
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 msg->ref_count++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84
27432
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27431
diff changeset
85 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: 27431
diff changeset
86 purple_debug_info("msn", "message ref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 }
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 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 msn_message_unref(MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 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
95 g_return_val_if_fail(msg->ref_count > 0, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 msg->ref_count--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
27432
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27431
diff changeset
99 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: 27431
diff changeset
100 purple_debug_info("msn", "message unref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 if (msg->ref_count == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {
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 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 msn_message_new_plain(const char *message)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 char *message_cr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 msg = msn_message_new(MSN_MSG_TEXT);
24207
fb722b8b4c74 attempts to resend message on switchboard error once, tested by maually
Ka-Hing Cheung <khc@hxbc.us>
parents: 23095
diff changeset
119 msg->retries = 1;
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
120 msn_message_set_header(msg, "User-Agent", PACKAGE_NAME "/" VERSION);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 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
122 msn_message_set_charset(msg, "UTF-8");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 msn_message_set_flag(msg, 'A');
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
124 msn_message_set_header(msg, "X-MMS-IM-Format",
25309
b0e069922896 Fixes #7373, the new live messenger client now sends Segoe UI as the default
Ka-Hing Cheung <khc@hxbc.us>
parents: 24728
diff changeset
125 "FN=Segoe%20UI; EF=; CO=0; CS=1;PF=0");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
127 message_cr = purple_str_add_cr(message);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 msn_message_set_bin_data(msg, message_cr, strlen(message_cr));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 g_free(message_cr);
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 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 msn_message_new_msnslp(void)
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 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 msg = msn_message_new(MSN_MSG_SLP);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
141 msn_message_set_header(msg, "User-Agent", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 msg->msnslp_message = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 msn_message_set_flag(msg, 'D');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 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
147
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 return msg;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 msn_message_new_nudge(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 msg = msn_message_new(MSN_MSG_NUDGE);
23095
56d958e7b7d1 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <stu@nosnilmot.com>
parents: 23011
diff changeset
157 msn_message_set_content_type(msg, "text/x-msnmsgr-datacast");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 msn_message_set_flag(msg, 'N');
23095
56d958e7b7d1 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <stu@nosnilmot.com>
parents: 23011
diff changeset
159 msn_message_set_bin_data(msg, "ID: 1\r\n", 7);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 return msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 msn_message_parse_payload(MsnMessage *msg,
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
166 const char *payload, size_t payload_len,
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
167 const char *line_dem,const char *body_dem)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 char *tmp_base, *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 const char *content_type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 char *end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 char **elems, **cur, **tokens;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 g_return_if_fail(payload != NULL);
24388
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24207
diff changeset
175 tmp_base = tmp = g_malloc(payload_len + 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 memcpy(tmp_base, payload, payload_len);
24388
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24207
diff changeset
177 tmp_base[payload_len] = '\0';
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
179 /* Find the end of the headers */
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
180 end = strstr(tmp, body_dem);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 /* 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
182 * 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
183 * avoid crashing for now */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 if (end == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 g_free(tmp_base);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 g_return_if_reached();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 *end = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
190 /* Split the headers and parse each one */
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
191 elems = g_strsplit(tmp, line_dem, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 for (cur = elems; *cur != NULL; cur++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 const char *key, *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195
24728
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
196 /* 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: 24388
diff changeset
197 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: 24388
diff changeset
198 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: 24388
diff changeset
199 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: 24388
diff changeset
200 key = tokens[0];
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
201 value = tokens[1];
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
202
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
203 /* 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: 24388
diff changeset
204 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: 24388
diff changeset
205 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: 24388
diff changeset
206 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: 24388
diff changeset
207 *end = '\0';
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
208 msn_message_set_header(msg, key, value);
24728
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
209 }
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
210
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
211 g_strfreev(tokens);
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
212 continue;
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
213 }
c09a647fd538 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24388
diff changeset
214
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 tokens = g_strsplit(*cur, ": ", 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 key = tokens[0];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 value = tokens[1];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
220 /*if not MIME content ,then return*/
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 if (!strcmp(key, "MIME-Version"))
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 g_strfreev(tokens);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 }
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 (!strcmp(key, "Content-Type"))
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 char *charset, *c;
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 if ((c = strchr(value, ';')) != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 if ((charset = strchr(c, '=')) != NULL)
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 charset++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 msn_message_set_charset(msg, charset);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 *c = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 msn_message_set_content_type(msg, value);
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 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 {
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
246 msn_message_set_header(msg, key, value);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
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 g_strfreev(tokens);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 g_strfreev(elems);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 /* 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: 15822
diff changeset
254 tmp = end + strlen(body_dem);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 /* Now we *should* be at the body. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 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
258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 if (content_type != NULL &&
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
260 !strcmp(content_type, "application/x-msnmsgrp2p")) {
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
261 msg->msnslp_message = TRUE;
30801
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
262 msg->part = msn_slpmsgpart_new_from_data(tmp, payload_len - (tmp - tmp_base));
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
263 }
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
264
30787
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
265 if (payload_len - (tmp - tmp_base) > 0) {
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
266 msg->body_len = payload_len - (tmp - tmp_base);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
267 g_free(msg->body);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
268 msg->body = g_malloc(msg->body_len + 1);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
269 memcpy(msg->body, tmp, msg->body_len);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
270 msg->body[msg->body_len] = '\0';
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
271 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
30787
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
273 if ((!content_type || !strcmp(content_type, "text/plain"))
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
274 && msg->charset == NULL) {
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
275 char *body = g_convert(msg->body, msg->body_len, "UTF-8",
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
276 "ISO-8859-1", NULL, &msg->body_len, NULL);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
277 g_free(msg->body);
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
278 msg->body = body;
155db1253acf Remove replaced code.
masca@cpw.pidgin.im
parents: 30785
diff changeset
279 msg->charset = g_strdup("UTF-8");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 }
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 g_free(tmp_base);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 MsnMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 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
287 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 MsnMessage *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 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
291
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 msg = msn_message_new(MSN_MSG_UNKNOWN);
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 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
295 /* msg->size = atoi(cmd->params[2]); */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 msg->cmd = cmd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 return msg;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 {
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
304 char *tmp;
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
305
30801
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
306 tmp = msn_slpmsgpart_serialize(msg->part, ret_size);
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
307 return tmp;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 }
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 char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 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
312 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 char *n, *base, *end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 int len;
19732
97559afd70e4 Silence the warning that body_len might be used uninitialized in msn_message_gen_payload().
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
316 size_t body_len = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 const void *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 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
320
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 len = MSN_BUF_LEN;
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 base = n = end = g_malloc(len + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 end += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 /* Standard header. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 if (msg->charset == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 g_snprintf(n, len,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 "Content-Type: %s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 msg->content_type);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 else
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 g_snprintf(n, len,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 "Content-Type: %s; charset=%s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 msg->content_type, msg->charset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 n += strlen(n);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
344 for (l = msg->header_list; l != NULL; l = l->next)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 const char *key;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 const char *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 key = l->data;
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
350 value = msn_message_get_header_value(msg, key);
15373
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 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
353 n += strlen(n);
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 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
357
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 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
359
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 if (msg->msnslp_message)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 {
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
362 size_t siz;
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
363 char *body;
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
364
30801
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
365 body = msn_slpmsgpart_serialize(msg->part, &siz);
30785
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
366
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
367 memcpy(n, body, siz);
64e2fe53acc2 Use slp parse code that was just moved to SlpMessage since it belongs there
masca@cpw.pidgin.im
parents: 30773
diff changeset
368 n += siz;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 if (body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 memcpy(n, body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 n += body_len;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
376 *n = '\0';
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 }
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 if (ret_size != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 *ret_size = n - base;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 if (*ret_size > 1664)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 *ret_size = 1664;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 }
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 return base;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 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
393 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 g_return_if_fail(flag != 0);
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->flag = flag;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 }
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 char
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 msn_message_get_flag(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 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
404
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 return msg->flag;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 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
410 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 g_return_if_fail(msg != NULL);
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 /* 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
414 if (len > 1664)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 len = 1664;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 if (msg->body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 g_free(msg->body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 if (data != NULL && len > 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 {
24388
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24207
diff changeset
422 msg->body = g_malloc(len + 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 memcpy(msg->body, data, len);
24388
7e8175f9b009 It should be more efficient to just use g_mallc() and then manually
Mark Doliner <mark@kingant.net>
parents: 24207
diff changeset
424 msg->body[len] = '\0';
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 msg->body_len = len;
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 else
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 msg->body = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 msg->body_len = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 }
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 const void *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 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
436 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 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
438
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 if (len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 *len = msg->body_len;
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 return msg->body;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 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
447 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449
20991
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
450 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
451 msg->content_type = g_strdup(type);
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 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
456 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 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
458
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 return msg->content_type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 }
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 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 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
464 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466
20991
c8f99cb61dc9 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20989
diff changeset
467 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
468 msg->charset = g_strdup(charset);
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 msn_message_get_charset(const MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 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
475
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 return msg->charset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 }
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 void
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
480 msn_message_set_header(MsnMessage *msg, const char *name, const char *value)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 const char *temp;
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
483 char *new_name;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 g_return_if_fail(msg != NULL);
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
486 g_return_if_fail(name != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
488 temp = msn_message_get_header_value(msg, name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 if (value == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 if (temp != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
496 for (l = msg->header_list; l != NULL; l = l->next)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 {
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
498 if (!g_ascii_strcasecmp(l->data, name))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
500 msg->header_list = g_list_remove(msg->header_list, l->data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 }
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
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
506 g_hash_table_remove(msg->header_table, name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 }
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 return;
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
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
512 new_name = g_strdup(name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
514 g_hash_table_insert(msg->header_table, new_name, g_strdup(value));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 if (temp == NULL)
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
517 msg->header_list = g_list_append(msg->header_list, new_name);
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 const char *
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
521 msn_message_get_header_value(const MsnMessage *msg, const char *name)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 g_return_val_if_fail(msg != NULL, NULL);
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
524 g_return_val_if_fail(name != NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
526 return g_hash_table_lookup(msg->header_table, name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 GHashTable *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 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
531 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 GHashTable *table;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 char **elems, **cur, **tokens, *body_str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 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
538
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 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
540
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 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
542
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 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
544
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 body_str = g_strndup(body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 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
547 g_free(body_str);
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 for (cur = elems; *cur != NULL; cur++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 if (**cur == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 break;
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 tokens = g_strsplit(*cur, ": ", 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
20935
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
556 if (tokens[0] != NULL && tokens[1] != NULL) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 g_hash_table_insert(table, tokens[0], tokens[1]);
20935
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
558 g_free(tokens);
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
559 } else
1d9d5de48b9e Fix some leaks.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20517
diff changeset
560 g_strfreev(tokens);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 }
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 g_strfreev(elems);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 return table;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 msn_message_to_string(MsnMessage *msg)
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 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 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
575 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
576
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 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
578
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 return g_strndup(body, body_len);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 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
584 gboolean text_body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 GString *str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 size_t body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 const char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 g_return_if_fail(msg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 str = g_string_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 /* Standard header. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 if (msg->charset == NULL)
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_printf(str,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 "Content-Type: %s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 msg->content_type);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 g_string_append_printf(str,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 "MIME-Version: 1.0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 "Content-Type: %s; charset=%s\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 msg->content_type, msg->charset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
611 for (l = msg->header_list; l; l = l->next)
15373
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 char *key;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 const char *value;
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 key = l->data;
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
617 value = msn_message_get_header_value(msg, key);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 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
620 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 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
625
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 if (msg->msnslp_message)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 {
30801
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
628 g_string_append_printf(str, "Session ID: %u\r\n", msg->part->header->session_id);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
629 g_string_append_printf(str, "ID: %u\r\n", msg->part->header->id);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
630 g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", msg->part->header->offset);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
631 g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->part->header->total_size);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
632 g_string_append_printf(str, "Length: %u\r\n", msg->part->header->length);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
633 g_string_append_printf(str, "Flags: 0x%x\r\n", msg->part->header->flags);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
634 g_string_append_printf(str, "ACK ID: %u\r\n", msg->part->header->ack_id);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
635 g_string_append_printf(str, "SUB ID: %u\r\n", msg->part->header->ack_sub_id);
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
636 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->part->header->ack_size);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637
27483
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27432
diff changeset
638 if (purple_debug_is_verbose() && body != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 if (text_body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 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
643 if (body[body_len - 1] == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 str->len--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 g_string_append(str, " 0x00");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 for (i = 0; i < msg->body_len; i++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 g_string_append_printf(str, "%.2hhX ", body[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 if ((i % 16) == 15)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662
30801
fd8abea40a0d Migrate MsnMessage code to use Parts instead of the whole SlpMessage.
masca@cpw.pidgin.im
parents: 30787
diff changeset
663 g_string_append_printf(str, "Footer: %u\r\n", msg->part->footer->value);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 if (body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 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
670 g_string_append(str, "\r\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
674 purple_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 g_string_free(str, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 }
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
678
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
679 /**************************************************************************
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
680 * Message Handlers
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
681 **************************************************************************/
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
682 void
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
683 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: 25309
diff changeset
684 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
685 PurpleConnection *gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
686 const char *body;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
687 char *body_enc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
688 char *body_final;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
689 size_t body_len;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
690 const char *passport;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
691 const char *value;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
692
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
693 gc = cmdproc->session->account->gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
694
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
695 body = msn_message_get_bin_data(msg, &body_len);
30699
a786d893df2b I don't believe there's any reason to duplicate this string.
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
696 body_enc = g_markup_escape_text(body, body_len);
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
697
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
698 passport = msg->remote_user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
699
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
700 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: 25309
diff changeset
701 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: 25309
diff changeset
702 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
703 return;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
704 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
705
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
706 #if 0
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
707 if ((value = msn_message_get_header_value(msg, "User-Agent")) != NULL)
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
708 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
709 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: 25309
diff changeset
710 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
711 #endif
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
712
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
713 if ((value = msn_message_get_header_value(msg, "X-MMS-IM-Format")) != NULL)
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
714 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
715 char *pre, *post;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
716
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
717 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: 25309
diff changeset
718
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
719 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: 25309
diff changeset
720 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: 25309
diff changeset
721
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
722 g_free(pre);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
723 g_free(post);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
724 g_free(body_enc);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
725 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
726 else
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
727 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
728 body_final = body_enc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
729 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
730
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
731 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: 25398
diff changeset
732 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: 25398
diff changeset
733
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
734 swboard->flag |= MSN_SB_FLAG_IM;
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
735
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
736 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: 25398
diff changeset
737 ((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: 25398
diff changeset
738 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
739 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
740 /* 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: 25398
diff changeset
741 * 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: 25398
diff changeset
742 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: 25398
diff changeset
743 purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
744 swboard->current_users);
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
745
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
746 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
747 time(NULL));
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
748 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: 25398
diff changeset
749 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
750 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: 25398
diff changeset
751 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: 25398
diff changeset
752 }
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
753 }
30734
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: 30730
diff changeset
754 else if (!g_str_equal(passport, purple_account_get_username(gc->account)))
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
755 {
30734
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: 30730
diff changeset
756 /* Don't im ourselves ... */
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
757 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: 25398
diff changeset
758 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: 25398
diff changeset
759 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
760 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
761 passport, purple_connection_get_account(gc));
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
762 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: 25398
diff changeset
763 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
764 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
765
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
766 } else {
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
767 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: 25309
diff changeset
768 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
769
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
770 g_free(body_final);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
771 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
772
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
773 void
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
774 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: 25309
diff changeset
775 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
776 PurpleConnection *gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
777 char *passport;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
778
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
779 gc = cmdproc->session->account->gc;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
780 passport = msg->remote_user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
781
30694
33b4ae796648 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <mark@kingant.net>
parents: 27868
diff changeset
782 if (msn_message_get_header_value(msg, "TypingUser") == NULL)
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
783 return;
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
784
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
785 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: 25398
diff changeset
786 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: 25398
diff changeset
787
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
788 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: 25398
diff changeset
789 {
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
790 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: 25398
diff changeset
791 PURPLE_TYPING);
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
792 }
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
793
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
794 } else {
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
795 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: 25309
diff changeset
796 PURPLE_TYPING);
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
797 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
798 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
799
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
800 static void
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
801 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: 27292
diff changeset
802 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: 27292
diff changeset
803 {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
804 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: 27292
diff changeset
805 PurpleAccount *account;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
806 PurpleBuddy *b;
29898
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
807 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: 29780
diff changeset
808 gboolean chat;
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
809
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
810 account = swboard->session->account;
29898
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
811 pc = purple_account_get_connection(account);
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
812
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
813 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: 27292
diff changeset
814 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: 27292
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: 27292
diff changeset
816 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: 27292
diff changeset
817 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: 27292
diff changeset
818 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: 27292
diff changeset
819
29898
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
820 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: 29780
diff changeset
821 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: 29780
diff changeset
822 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: 29780
diff changeset
823 else
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
824 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: 29780
diff changeset
825
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
826 if (swboard->conv == NULL) {
29898
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
827 if (chat)
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
828 swboard->conv = purple_find_chat(account->gc, swboard->chat_id);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
829 else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
830 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: 27292
diff changeset
831 who, account);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
832 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: 27292
diff changeset
833 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: 27292
diff changeset
834 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
835 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
836
29898
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
837 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: 29780
diff changeset
838 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: 29780
diff changeset
839 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: 29780
diff changeset
840 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: 29780
diff changeset
841 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: 29780
diff changeset
842 else
71fe96932a8e Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29780
diff changeset
843 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: 29780
diff changeset
844 time(NULL));
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
845 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: 27292
diff changeset
846
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
847 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
848
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
849 /* TODO: Make these not be such duplicates of each other */
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
850 static void
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
851 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: 27292
diff changeset
852 {
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
853 FILE *f = NULL;
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
854 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: 27292
diff changeset
855 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: 27292
diff changeset
856 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: 27292
diff changeset
857
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
858 if ((f = purple_mkstemp(&path, TRUE)) &&
29780
0f1df8098d00 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29779
diff changeset
859 (fwrite(data, 1, size, f) == size)) {
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
860 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: 27292
diff changeset
861 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
862 _("%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: 27292
diff changeset
863 path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
864 } else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
865 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: 27292
diff changeset
866 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: 27292
diff changeset
867 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
868 _("%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: 27292
diff changeset
869 NULL);
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
870 }
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
871 if (f)
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
872 fclose(f);
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
873 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: 27292
diff changeset
874 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
875
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
876 static void
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
877 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: 27292
diff changeset
878 {
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
879 FILE *f = NULL;
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
880 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: 27292
diff changeset
881 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: 27292
diff changeset
882 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: 27292
diff changeset
883
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
884 if ((f = purple_mkstemp(&path, TRUE)) &&
29780
0f1df8098d00 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29779
diff changeset
885 (fwrite(data, 1, size, f) == size)) {
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
886 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: 27292
diff changeset
887 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
888 _("%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: 27292
diff changeset
889 path);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
890 } else {
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
891 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: 27292
diff changeset
892 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: 27292
diff changeset
893 who,
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
894 _("%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: 27292
diff changeset
895 NULL);
29779
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
896 }
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
897 if (f)
1c3ee8378e2e I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29310
diff changeset
898 fclose(f);
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
899 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: 27292
diff changeset
900 }
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
901
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
902 void
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
903 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: 25309
diff changeset
904 {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
905 GHashTable *body;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
906 const char *id;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
907 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: 25309
diff changeset
908
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
909 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: 25309
diff changeset
910
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
911 if (!strcmp(id, "1")) {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
912 /* Nudge */
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
913 PurpleAccount *account;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
914 const char *user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
915
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
916 account = cmdproc->session->account;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
917 user = msg->remote_user;
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
918
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
919 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: 25398
diff changeset
920 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: 25398
diff changeset
921 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: 25398
diff changeset
922 ((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: 25398
diff changeset
923 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
924 purple_prpl_got_attention_in_chat(account->gc, swboard->chat_id, user, MSN_NUDGE);
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
925
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
926 else
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
927 purple_prpl_got_attention(account->gc, user, MSN_NUDGE);
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
928 } else {
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
929 purple_prpl_got_attention(account->gc, user, MSN_NUDGE);
25399
8ee34225cfd9 Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25398
diff changeset
930 }
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
931
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
932 } 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: 25309
diff changeset
933 /* Wink */
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
934 MsnSession *session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
935 MsnSlpLink *slplink;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
936 MsnObject *obj;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
937 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: 27292
diff changeset
938 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: 27292
diff changeset
939
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
940 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: 27292
diff changeset
941
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
942 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: 27292
diff changeset
943 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: 27292
diff changeset
944 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: 27292
diff changeset
945
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
946 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: 27292
diff changeset
947 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: 27292
diff changeset
948
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
949 msn_object_destroy(obj);
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
950
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
951
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
952 } 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: 25309
diff changeset
953 /* Voiceclip */
27431
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
954 MsnSession *session;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
955 MsnSlpLink *slplink;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
956 MsnObject *obj;
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
957 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: 27292
diff changeset
958 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: 27292
diff changeset
959
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
960 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: 27292
diff changeset
961
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
962 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: 27292
diff changeset
963 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: 27292
diff changeset
964 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: 27292
diff changeset
965
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
966 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: 27292
diff changeset
967 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: 27292
diff changeset
968
9c413bda20be Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27292
diff changeset
969 msn_object_destroy(obj);
25398
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
970
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
971 } 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: 25309
diff changeset
972 /* Action */
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
973
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
974 } else {
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
975 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: 25309
diff changeset
976 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
977
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
978 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: 25309
diff changeset
979 }
ea98810d89c5 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25309
diff changeset
980
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
981 void
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
982 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: 25461
diff changeset
983 {
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
984 GHashTable *body;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
985 const gchar *command;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
986 const gchar *cookie;
27868
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
987 gboolean accepted = FALSE;
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
988
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
989 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: 25461
diff changeset
990 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: 25461
diff changeset
991
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
992 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: 25461
diff changeset
993
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
994 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: 25461
diff changeset
995 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: 25461
diff changeset
996 "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: 25461
diff changeset
997 return;
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
998 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
999
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1000 /*
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1001 * 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: 29310
diff changeset
1002 * are mandatory.
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1003 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1004 command = g_hash_table_lookup(body, "Invitation-Command");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1005 cookie = g_hash_table_lookup(body, "Invitation-Cookie");
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1006
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1007 if (command == NULL || cookie == NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1008 purple_debug_warning("msn",
30026
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
1009 "Invalid invitation message: either Invitation-Command "
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
1010 "or Invitation-Cookie is missing or invalid.\n"
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1011 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1012 return;
27868
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1013
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1014 } else if (!strcmp(command, "INVITE")) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1015 const gchar *guid = g_hash_table_lookup(body, "Application-GUID");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1016
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1017 if (guid == NULL) {
30069
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30060
diff changeset
1018 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: 30060
diff changeset
1019 "Invite msg missing Application-GUID.\n");
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1020
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1021 accepted = TRUE;
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1022
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1023 } else if (!strcmp(guid, MSN_FT_GUID)) {
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1024
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1025 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1026 purple_debug_info("msn", "Computer call\n");
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1027
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1028 if (cmdproc->session) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1029 PurpleConversation *conv = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1030 gchar *from = msg->remote_user;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1031 gchar *buf = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1032
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1033 if (from)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1034 conv = purple_find_conversation_with_account(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1035 PURPLE_CONV_TYPE_IM, from,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1036 cmdproc->session->account);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1037 if (conv)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1038 buf = g_strdup_printf(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1039 _("%s sent you a voice chat "
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1040 "invite, which is not yet "
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1041 "supported."), from);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1042 if (buf) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1043 purple_conversation_write(conv, NULL, buf,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1044 PURPLE_MESSAGE_SYSTEM |
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1045 PURPLE_MESSAGE_NOTIFY,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1046 time(NULL));
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1047 g_free(buf);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1048 }
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1049 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1050 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1051 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: 29310
diff changeset
1052 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n",
30026
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
1053 guid, application ? application : "(null)");
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1054 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1055
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1056 if (!accepted) {
27868
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1057 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: 27867
diff changeset
1058 char *text;
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1059 MsnMessage *cancel;
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1060
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1061 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: 27867
diff changeset
1062 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: 27867
diff changeset
1063 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: 27867
diff changeset
1064 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: 27867
diff changeset
1065
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1066 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: 27867
diff changeset
1067 "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: 27867
diff changeset
1068 "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: 27867
diff changeset
1069 cookie);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1070 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: 27867
diff changeset
1071 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: 27867
diff changeset
1072
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1073 msn_switchboard_send_msg(swboard, cancel, TRUE);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1074 msn_message_destroy(cancel);
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1075 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1076
30069
5044315e81e1 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30060
diff changeset
1077 } 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: 30060
diff changeset
1078 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: 30060
diff changeset
1079 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: 30060
diff changeset
1080 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: 30060
diff changeset
1081
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1082 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1083 /*
30026
538ca314c5f8 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
1084 * Some other already established invitation session.
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1085 * Can be retrieved by Invitation-Cookie.
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29310
diff changeset
1086 */
27868
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1087 }
9262c8f306a6 Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27867
diff changeset
1088
26518
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1089 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: 25461
diff changeset
1090 }
79e043347bbe Notify the user if a contact invites them to a voice call over MSN.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25461
diff changeset
1091
27292
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1092 /* 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: 26518
diff changeset
1093 void
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1094 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: 26518
diff changeset
1095 {
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1096 const char *body;
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1097 size_t body_len;
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1098
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1099 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: 26518
diff changeset
1100 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: 26518
diff changeset
1101 }
a6d84d9de605 Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26518
diff changeset
1102