libpurple/protocols/msn/msg.c

Sun, 09 Aug 2009 07:29:01 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sun, 09 Aug 2009 07:29:01 +0000
changeset 28145
95c36b80165a
parent 27828
d08692294a8f
child 28146
796c252c735e
permissions
-rw-r--r--

Print name of application in the invite to the debug log if it's available.

4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file msg.c Message functions
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
4 * purple
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
9 *
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * (at your option) any later version.
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 *
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * GNU General Public License for more details.
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15884
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 */
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
25 #include "msg.h"
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
26 #include "msnutils.h"
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
28 MsnMessage *
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
29 msn_message_new(MsnMsgType type)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
30 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
31 MsnMessage *msg;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
32
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
33 msg = g_new0(MsnMessage, 1);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
34 msg->type = type;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
35
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
36 if (purple_debug_is_verbose())
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
37 purple_debug_info("msn", "message new (%p)(%d)\n", msg, type);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
38
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
39 msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal,
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
40 g_free, g_free);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
41
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
42 msn_message_ref(msg);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
43
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
44 return msg;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
45 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
46
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
47 void
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
48 msn_message_destroy(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
49 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
50 g_return_if_fail(msg != NULL);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
51
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
52 if (msg->ref_count > 0)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
53 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
54 msn_message_unref(msg);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
55
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
56 return;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
57 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
58
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
59 if (purple_debug_is_verbose())
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
60 purple_debug_info("msn", "message destroy (%p)\n", msg);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
61
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
62 g_free(msg->remote_user);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
63 g_free(msg->body);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
64 g_free(msg->content_type);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
65 g_free(msg->charset);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
66
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
67 g_hash_table_destroy(msg->attr_table);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
68 g_list_free(msg->attr_list);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
69
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
70 g_free(msg);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
71 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
72
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
73 MsnMessage *
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
74 msn_message_ref(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
75 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
76 g_return_val_if_fail(msg != NULL, NULL);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
77
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
78 msg->ref_count++;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
79
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
80 if (purple_debug_is_verbose())
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
81 purple_debug_info("msn", "message ref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
82
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
83 return msg;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
84 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
85
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
86 MsnMessage *
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
87 msn_message_unref(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
88 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
89 g_return_val_if_fail(msg != NULL, NULL);
12250
5b14301dd1ec [gaim-migrate @ 14552]
Richard Laager <rlaager@pidgin.im>
parents: 11322
diff changeset
90 g_return_val_if_fail(msg->ref_count > 0, NULL);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
91
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
92 msg->ref_count--;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
93
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
94 if (purple_debug_is_verbose())
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27690
diff changeset
95 purple_debug_info("msn", "message unref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
96
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
97 if (msg->ref_count == 0)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
98 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
99 msn_message_destroy(msg);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
100
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
101 return NULL;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
102 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
103
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
104 return msg;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
105 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
106
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
107 MsnMessage *
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
108 msn_message_new_plain(const char *message)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
109 {
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
110 MsnMessage *msg;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
111 char *message_cr;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
112
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
113 msg = msn_message_new(MSN_MSG_TEXT);
24420
e83317602b22 attempts to resend message on switchboard error once, tested by maually
Ka-Hing Cheung <khc@pidgin.im>
parents: 23262
diff changeset
114 msg->retries = 1;
14932
d2b3faf48b39 [gaim-migrate @ 17639]
Evan Schoenberg <evands@pidgin.im>
parents: 14254
diff changeset
115 msn_message_set_attr(msg, "User-Agent", PACKAGE_NAME "/" VERSION);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
116 msn_message_set_content_type(msg, "text/plain");
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
117 msn_message_set_charset(msg, "UTF-8");
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
118 msn_message_set_flag(msg, 'A');
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
119 msn_message_set_attr(msg, "X-MMS-IM-Format",
25417
81b343445003 Fixes #7373, the new live messenger client now sends Segoe UI as the default
Ka-Hing Cheung <khc@pidgin.im>
parents: 25161
diff changeset
120 "FN=Segoe%20UI; EF=; CO=0; CS=1;PF=0");
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
121
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
122 message_cr = purple_str_add_cr(message);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
123 msn_message_set_bin_data(msg, message_cr, strlen(message_cr));
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
124 g_free(message_cr);
5506
b53a1acacefe [gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents: 5478
diff changeset
125
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
126 return msg;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
127 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
128
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
129 MsnMessage *
6800
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
130 msn_message_new_msnslp(void)
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
131 {
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
132 MsnMessage *msg;
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
133
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
134 msg = msn_message_new(MSN_MSG_SLP);
6800
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
135
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
136 msn_message_set_attr(msg, "User-Agent", NULL);
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
137
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
138 msg->msnslp_message = TRUE;
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
139
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
140 msn_message_set_flag(msg, 'D');
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
141 msn_message_set_content_type(msg, "application/x-msnmsgrp2p");
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
142
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
143 return msg;
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
144 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
145
11321
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
146 MsnMessage *
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
147 msn_message_new_nudge(void)
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
148 {
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
149 MsnMessage *msg;
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
150
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
151 msg = msn_message_new(MSN_MSG_NUDGE);
23262
642669494d17 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23235
diff changeset
152 msn_message_set_content_type(msg, "text/x-msnmsgr-datacast");
11321
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
153 msn_message_set_flag(msg, 'N');
23262
642669494d17 Fix a TODO uncovered by Mark the other day. Instead of using a hacky
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23235
diff changeset
154 msn_message_set_bin_data(msg, "ID: 1\r\n", 7);
11321
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
155
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
156 return msg;
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
157 }
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
158
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
159 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
160 msn_message_parse_slp_body(MsnMessage *msg, const char *body, size_t len)
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
161 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
162 MsnSlpHeader header;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
163 const char *tmp;
11001
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
164 int body_len;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
165
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
166 tmp = body;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
167
11001
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
168 if (len < sizeof(header)) {
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
169 g_return_if_reached();
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
170 }
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
171
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
172 /* Import the header. */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
173 memcpy(&header, tmp, sizeof(header));
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
174 tmp += sizeof(header);
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
175
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
176 msg->msnslp_header.session_id = GUINT32_FROM_LE(header.session_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
177 msg->msnslp_header.id = GUINT32_FROM_LE(header.id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
178 msg->msnslp_header.offset = GUINT64_FROM_LE(header.offset);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
179 msg->msnslp_header.total_size = GUINT64_FROM_LE(header.total_size);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
180 msg->msnslp_header.length = GUINT32_FROM_LE(header.length);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
181 msg->msnslp_header.flags = GUINT32_FROM_LE(header.flags);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
182 msg->msnslp_header.ack_id = GUINT32_FROM_LE(header.ack_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
183 msg->msnslp_header.ack_sub_id = GUINT32_FROM_LE(header.ack_sub_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
184 msg->msnslp_header.ack_size = GUINT64_FROM_LE(header.ack_size);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
185
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
186 /* Import the body. */
11001
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
187 body_len = len - (tmp - body);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
188 /* msg->body_len = msg->msnslp_header.length; */
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
189
11001
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
190 if (body_len > 0) {
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
191 msg->body_len = len - (tmp - body);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
192 msg->body = g_malloc(msg->body_len + 1);
11235
7e1cd737137b [gaim-migrate @ 13380]
Federico G. Schwindt <fgsch@lodoss.net>
parents: 11001
diff changeset
193 memcpy(msg->body, tmp, msg->body_len);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
194 msg->body[msg->body_len] = '\0';
11001
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
195 tmp += body_len;
a026aa937d97 [gaim-migrate @ 12851]
Daniel Atallah <datallah@pidgin.im>
parents: 10981
diff changeset
196 }
6800
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
197 }
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
198
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
199 void
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
200 msn_message_parse_payload(MsnMessage *msg,
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
201 const char *payload, size_t payload_len,
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
202 const char *line_dem,const char *body_dem)
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
204 char *tmp_base, *tmp;
7845
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
205 const char *content_type;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
206 char *end;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
207 char **elems, **cur, **tokens;
5454
5263b77f0ad9 [gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents: 5315
diff changeset
208
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
209 g_return_if_fail(payload != NULL);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
210 tmp_base = tmp = g_malloc(payload_len + 1);
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10345
diff changeset
211 memcpy(tmp_base, payload, payload_len);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
212 tmp_base[payload_len] = '\0';
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
213
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
214 /* Parse the attributes. */
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
215 end = strstr(tmp, body_dem);
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
216 /* TODO? some clients use \r delimiters instead of \r\n, the official client
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
217 * doesn't send such messages, but does handle receiving them. We'll just
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
218 * avoid crashing for now */
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
219 if (end == NULL) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
220 g_free(tmp_base);
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
221 g_return_if_reached();
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
222 }
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
223 *end = '\0';
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
224
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
225 elems = g_strsplit(tmp, line_dem, 0);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
226
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
227 for (cur = elems; *cur != NULL; cur++)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
228 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
229 const char *key, *value;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
230
25161
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
231 /* If this line starts with whitespace, it's been folded from the
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
232 previous line and won't have ':'. */
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
233 if ((**cur == ' ') || (**cur == '\t')) {
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
234 tokens = g_strsplit(g_strchug(*cur), "=\"", 2);
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
235 key = tokens[0];
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
236 value = tokens[1];
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
237
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
238 /* The only one I care about is 'boundary' (which is folded from
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
239 the key 'Content-Type'), so only process that. */
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
240 if (!strcmp(key, "boundary")) {
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
241 char *end = strchr(value, '\"');
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
242 *end = '\0';
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
243 msn_message_set_attr(msg, key, value);
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
244 }
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
245
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
246 g_strfreev(tokens);
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
247 continue;
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
248 }
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
249
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
250 tokens = g_strsplit(*cur, ": ", 2);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
251
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
252 key = tokens[0];
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
253 value = tokens[1];
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
254
13854
ab947cf0c2bb [gaim-migrate @ 16473]
Ma Yuan <mayuan2006@gmail.com>
parents: 12250
diff changeset
255 /*if not MIME content ,then return*/
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
256 if (!strcmp(key, "MIME-Version"))
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
257 {
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
258 g_strfreev(tokens);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
259 continue;
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
260 }
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
261
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
262 if (!strcmp(key, "Content-Type"))
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
263 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
264 char *charset, *c;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
265
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
266 if ((c = strchr(value, ';')) != NULL)
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
267 {
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
268 if ((charset = strchr(c, '=')) != NULL)
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
269 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
270 charset++;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
271 msn_message_set_charset(msg, charset);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
272 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
273
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
274 *c = '\0';
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
275 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
276
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
277 msn_message_set_content_type(msg, value);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
278 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
279 else
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
280 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
281 msn_message_set_attr(msg, key, value);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
282 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
283
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
284 g_strfreev(tokens);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
285 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
286
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
287 g_strfreev(elems);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
288
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
289 /* Proceed to the end of the "\r\n\r\n" */
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
290 tmp = end + strlen(body_dem);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
291
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
292 /* Now we *should* be at the body. */
7845
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
293 content_type = msn_message_get_content_type(msg);
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
294
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
295 if (content_type != NULL &&
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
296 !strcmp(content_type, "application/x-msnmsgrp2p"))
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
297 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
298 MsnSlpHeader header;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
299 MsnSlpFooter footer;
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
300 int body_len;
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
301
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
302 if (payload_len - (tmp - tmp_base) < sizeof(header)) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
303 g_free(tmp_base);
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
304 g_return_if_reached();
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
305 }
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
306
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
307 msg->msnslp_message = TRUE;
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
308
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
309 /* Import the header. */
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
310 memcpy(&header, tmp, sizeof(header));
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
311 tmp += sizeof(header);
7604
0800df4e5045 [gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents: 7592
diff changeset
312
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
313 msg->msnslp_header.session_id = GUINT32_FROM_LE(header.session_id);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
314 msg->msnslp_header.id = GUINT32_FROM_LE(header.id);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
315 msg->msnslp_header.offset = GUINT64_FROM_LE(header.offset);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
316 msg->msnslp_header.total_size = GUINT64_FROM_LE(header.total_size);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
317 msg->msnslp_header.length = GUINT32_FROM_LE(header.length);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
318 msg->msnslp_header.flags = GUINT32_FROM_LE(header.flags);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
319 msg->msnslp_header.ack_id = GUINT32_FROM_LE(header.ack_id);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
320 msg->msnslp_header.ack_sub_id = GUINT32_FROM_LE(header.ack_sub_id);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
321 msg->msnslp_header.ack_size = GUINT64_FROM_LE(header.ack_size);
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
322
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
323 body_len = payload_len - (tmp - tmp_base) - sizeof(footer);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
324
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
325 /* Import the body. */
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
326 if (body_len > 0) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
327 msg->body_len = body_len;
21065
8bbf0f6700ed Fix some leaks and prevent some unnecessary allocations and frees.
Daniel Atallah <datallah@pidgin.im>
parents: 21010
diff changeset
328 g_free(msg->body);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
329 msg->body = g_malloc(msg->body_len + 1);
11235
7e1cd737137b [gaim-migrate @ 13380]
Federico G. Schwindt <fgsch@lodoss.net>
parents: 11001
diff changeset
330 memcpy(msg->body, tmp, msg->body_len);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
331 msg->body[msg->body_len] = '\0';
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
332 tmp += body_len;
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
333 }
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
334
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
335 /* Import the footer. */
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
336 if (body_len >= 0) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
337 memcpy(&footer, tmp, sizeof(footer));
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
338 tmp += sizeof(footer);
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
339 msg->msnslp_footer.value = GUINT32_FROM_BE(footer.value);
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
340 }
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
341 }
6705
e9dfe71c40df [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
342 else
e9dfe71c40df [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
343 {
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
344 if (payload_len - (tmp - tmp_base) > 0) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
345 msg->body_len = payload_len - (tmp - tmp_base);
21065
8bbf0f6700ed Fix some leaks and prevent some unnecessary allocations and frees.
Daniel Atallah <datallah@pidgin.im>
parents: 21010
diff changeset
346 g_free(msg->body);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
347 msg->body = g_malloc(msg->body_len + 1);
11235
7e1cd737137b [gaim-migrate @ 13380]
Federico G. Schwindt <fgsch@lodoss.net>
parents: 11001
diff changeset
348 memcpy(msg->body, tmp, msg->body_len);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
349 msg->body[msg->body_len] = '\0';
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
350 }
25617
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
351
27828
d08692294a8f Only fall back to ISO-8859-1 for text/plain messages. This fixes some wrong
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27770
diff changeset
352 if ((!content_type || !strcmp(content_type, "text/plain"))
d08692294a8f Only fall back to ISO-8859-1 for text/plain messages. This fixes some wrong
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27770
diff changeset
353 && msg->charset == NULL) {
25617
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
354 char *body = g_convert(msg->body, msg->body_len, "UTF-8",
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
355 "ISO-8859-1", NULL, &msg->body_len, NULL);
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
356 g_free(msg->body);
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
357 msg->body = body;
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
358 msg->charset = g_strdup("UTF-8");
6f2a9b36416c Convert from ISO-8859-1 to UTF-8 if no charset is supplied. This should fix
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25564
diff changeset
359 }
6705
e9dfe71c40df [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
360 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
361
6011
a7fd3284655c [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
362 g_free(tmp_base);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
363 }
6011
a7fd3284655c [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
364
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
365 MsnMessage *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
366 msn_message_new_from_cmd(MsnSession *session, MsnCommand *cmd)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
367 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
368 MsnMessage *msg;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
369
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
370 g_return_val_if_fail(cmd != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
371
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
372 msg = msn_message_new(MSN_MSG_UNKNOWN);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
373
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
374 msg->remote_user = g_strdup(cmd->params[0]);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
375 /* msg->size = atoi(cmd->params[2]); */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
376 msg->cmd = cmd;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
377
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
378 return msg;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
379 }
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
381 char *
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
382 msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
383 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
384 MsnSlpHeader header;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
385
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
386 char *tmp, *base;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
387 const void *body;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
388 size_t len, body_len;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
389
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
390 g_return_val_if_fail(msg != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
391
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
392 len = MSN_BUF_LEN;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
393
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
394 base = tmp = g_malloc(len + 1);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
395
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
396 body = msn_message_get_bin_data(msg, &body_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
397
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
398 header.session_id = GUINT32_TO_LE(msg->msnslp_header.session_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
399 header.id = GUINT32_TO_LE(msg->msnslp_header.id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
400 header.offset = GUINT64_TO_LE(msg->msnslp_header.offset);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
401 header.total_size = GUINT64_TO_LE(msg->msnslp_header.total_size);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
402 header.length = GUINT32_TO_LE(msg->msnslp_header.length);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
403 header.flags = GUINT32_TO_LE(msg->msnslp_header.flags);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
404 header.ack_id = GUINT32_TO_LE(msg->msnslp_header.ack_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
405 header.ack_sub_id = GUINT32_TO_LE(msg->msnslp_header.ack_sub_id);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
406 header.ack_size = GUINT64_TO_LE(msg->msnslp_header.ack_size);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
407
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
408 memcpy(tmp, &header, 48);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
409 tmp += 48;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
410
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
411 if (body != NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
412 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
413 memcpy(tmp, body, body_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
414 tmp += body_len;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
415 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
416
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
417 if (ret_size != NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
418 *ret_size = tmp - base;
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
419
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
420 return base;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
421 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
422
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
423 char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
424 msn_message_gen_payload(MsnMessage *msg, size_t *ret_size)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
425 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
426 GList *l;
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
427 char *n, *base, *end;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
428 int len;
19936
4e02485ca561 Silence the warning that body_len might be used uninitialized in msn_message_gen_payload().
Evan Schoenberg <evands@pidgin.im>
parents: 19859
diff changeset
429 size_t body_len = 0;
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
430 const void *body;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
431
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
432 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
433
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
434 len = MSN_BUF_LEN;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
435
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
436 base = n = end = g_malloc(len + 1);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
437 end += len;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
438
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
439 /* Standard header. */
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
440 if (msg->charset == NULL)
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
441 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
442 g_snprintf(n, len,
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
443 "MIME-Version: 1.0\r\n"
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
444 "Content-Type: %s\r\n",
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
445 msg->content_type);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
446 }
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
447 else
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
448 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
449 g_snprintf(n, len,
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
450 "MIME-Version: 1.0\r\n"
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
451 "Content-Type: %s; charset=%s\r\n",
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
452 msg->content_type, msg->charset);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
453 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
454
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
455 n += strlen(n);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
456
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
457 for (l = msg->attr_list; l != NULL; l = l->next)
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
458 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
459 const char *key;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
460 const char *value;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
461
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
462 key = l->data;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
463 value = msn_message_get_attr(msg, key);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
464
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
465 g_snprintf(n, end - n, "%s: %s\r\n", key, value);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
466 n += strlen(n);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
467 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
468
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
469 n += g_strlcpy(n, "\r\n", end - n);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
470
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
471 body = msn_message_get_bin_data(msg, &body_len);
6827
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
472
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
473 if (msg->msnslp_message)
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
474 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
475 MsnSlpHeader header;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
476 MsnSlpFooter footer;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
477
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
478 header.session_id = GUINT32_TO_LE(msg->msnslp_header.session_id);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
479 header.id = GUINT32_TO_LE(msg->msnslp_header.id);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
480 header.offset = GUINT64_TO_LE(msg->msnslp_header.offset);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
481 header.total_size = GUINT64_TO_LE(msg->msnslp_header.total_size);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
482 header.length = GUINT32_TO_LE(msg->msnslp_header.length);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
483 header.flags = GUINT32_TO_LE(msg->msnslp_header.flags);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
484 header.ack_id = GUINT32_TO_LE(msg->msnslp_header.ack_id);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
485 header.ack_sub_id = GUINT32_TO_LE(msg->msnslp_header.ack_sub_id);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
486 header.ack_size = GUINT64_TO_LE(msg->msnslp_header.ack_size);
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
487
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
488 memcpy(n, &header, 48);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
489 n += 48;
6827
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
490
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
491 if (body != NULL)
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
492 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
493 memcpy(n, body, body_len);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
494
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
495 n += body_len;
6827
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
496 }
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
497
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
498 footer.value = GUINT32_TO_BE(msg->msnslp_footer.value);
6827
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
499
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
500 memcpy(n, &footer, 4);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
501 n += 4;
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
502 }
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
503 else
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
504 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
505 if (body != NULL)
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
506 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
507 memcpy(n, body, body_len);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
508 n += body_len;
13890
a3fa24a63d1b [gaim-migrate @ 17006]
Ma Yuan <mayuan2006@gmail.com>
parents: 13886
diff changeset
509 *n = '\0';
6800
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
510 }
5310
ac2ee6a1f846 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
511 }
ac2ee6a1f846 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
512
6826
986589449e69 [gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
513 if (ret_size != NULL)
9092
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
514 {
10274
f329b1d7fd43 [gaim-migrate @ 11424]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10225
diff changeset
515 *ret_size = n - base;
f329b1d7fd43 [gaim-migrate @ 11424]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10225
diff changeset
516
9092
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
517 if (*ret_size > 1664)
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
518 *ret_size = 1664;
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
519 }
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
520
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
521 return base;
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 }
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
524 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
525 msn_message_set_flag(MsnMessage *msg, char flag)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
526 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
527 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
528 g_return_if_fail(flag != 0);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
529
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
530 msg->flag = flag;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
531 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
532
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
533 char
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
534 msn_message_get_flag(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
535 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
536 g_return_val_if_fail(msg != NULL, 0);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
537
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
538 return msg->flag;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
539 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
540
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
541 void
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
542 msn_message_set_bin_data(MsnMessage *msg, const void *data, size_t len)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
543 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
544 g_return_if_fail(msg != NULL);
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
545
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
546 /* There is no need to waste memory on data we cannot send anyway */
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
547 if (len > 1664)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
548 len = 1664;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
549
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
550 if (msg->body != NULL)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
551 g_free(msg->body);
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
552
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
553 if (data != NULL && len > 0)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
554 {
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
555 msg->body = g_malloc(len + 1);
11235
7e1cd737137b [gaim-migrate @ 13380]
Federico G. Schwindt <fgsch@lodoss.net>
parents: 11001
diff changeset
556 memcpy(msg->body, data, len);
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
557 msg->body[len] = '\0';
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
558 msg->body_len = len;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
559 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
560 else
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
561 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
562 msg->body = NULL;
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
563 msg->body_len = 0;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
564 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
565 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
566
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
567 const void *
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
568 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
569 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
570 g_return_val_if_fail(msg != NULL, NULL);
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
571
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
572 if (len)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
573 *len = msg->body_len;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
574
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
575 return msg->body;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
576 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
577
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
578 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
579 msn_message_set_content_type(MsnMessage *msg, const char *type)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
580 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
581 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
582
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
583 g_free(msg->content_type);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
584 msg->content_type = g_strdup(type);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
585 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
586
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
587 const char *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
588 msn_message_get_content_type(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
589 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
590 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
591
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
592 return msg->content_type;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
593 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
594
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
595 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
596 msn_message_set_charset(MsnMessage *msg, const char *charset)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
597 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
598 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
599
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
600 g_free(msg->charset);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
601 msg->charset = g_strdup(charset);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
602 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
603
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
604 const char *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
605 msn_message_get_charset(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
606 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
607 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
608
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
609 return msg->charset;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
610 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
611
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
612 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
613 msn_message_set_attr(MsnMessage *msg, const char *attr, const char *value)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
614 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
615 const char *temp;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
616 char *new_attr;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
617
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
618 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
619 g_return_if_fail(attr != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
620
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
621 temp = msn_message_get_attr(msg, attr);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
622
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
623 if (value == NULL)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
624 {
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
625 if (temp != NULL)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
626 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
627 GList *l;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
628
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
629 for (l = msg->attr_list; l != NULL; l = l->next)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
630 {
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
631 if (!g_ascii_strcasecmp(l->data, attr))
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
632 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
633 msg->attr_list = g_list_remove(msg->attr_list, l->data);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
634
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
635 break;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
636 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
637 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
638
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
639 g_hash_table_remove(msg->attr_table, attr);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
640 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
641
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
642 return;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
643 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
644
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
645 new_attr = g_strdup(attr);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
646
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
647 g_hash_table_insert(msg->attr_table, new_attr, g_strdup(value));
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
648
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
649 if (temp == NULL)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
650 msg->attr_list = g_list_append(msg->attr_list, new_attr);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
651 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
652
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
653 const char *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
654 msn_message_get_attr(const MsnMessage *msg, const char *attr)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
655 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
656 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
657 g_return_val_if_fail(attr != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
658
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
659 return g_hash_table_lookup(msg->attr_table, attr);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
660 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
661
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
662 GHashTable *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
663 msn_message_get_hashtable_from_body(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
664 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
665 GHashTable *table;
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
666 size_t body_len;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
667 const char *body;
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
668 char **elems, **cur, **tokens, *body_str;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
669
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
670 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
671
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
672 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
673
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
674 body = msn_message_get_bin_data(msg, &body_len);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
675
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
676 g_return_val_if_fail(body != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
677
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
678 body_str = g_strndup(body, body_len);
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
679 elems = g_strsplit(body_str, "\r\n", 0);
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
680 g_free(body_str);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
681
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
682 for (cur = elems; *cur != NULL; cur++)
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
683 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
684 if (**cur == '\0')
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
685 break;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
686
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
687 tokens = g_strsplit(*cur, ": ", 2);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
688
21010
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
689 if (tokens[0] != NULL && tokens[1] != NULL) {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
690 g_hash_table_insert(table, tokens[0], tokens[1]);
21010
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
691 g_free(tokens);
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
692 } else
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
693 g_strfreev(tokens);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
694 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
695
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
696 g_strfreev(elems);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
697
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
698 return table;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
699 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
700
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
701 char *
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
702 msn_message_to_string(MsnMessage *msg)
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
703 {
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
704 size_t body_len;
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
705 const char *body;
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
706
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
707 g_return_val_if_fail(msg != NULL, NULL);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
708 g_return_val_if_fail(msg->type == MSN_MSG_TEXT, NULL);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
709
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
710 body = msn_message_get_bin_data(msg, &body_len);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
711
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
712 return g_strndup(body, body_len);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
713 }
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
714
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
715 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
716 msn_message_show_readable(MsnMessage *msg, const char *info,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
717 gboolean text_body)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
718 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
719 GString *str;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
720 size_t body_len;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
721 const char *body;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
722 GList *l;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
723
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
724 g_return_if_fail(msg != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
725
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
726 str = g_string_new(NULL);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
727
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
728 /* Standard header. */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
729 if (msg->charset == NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
730 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
731 g_string_append_printf(str,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
732 "MIME-Version: 1.0\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
733 "Content-Type: %s\r\n",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
734 msg->content_type);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
735 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
736 else
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
737 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
738 g_string_append_printf(str,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
739 "MIME-Version: 1.0\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
740 "Content-Type: %s; charset=%s\r\n",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
741 msg->content_type, msg->charset);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
742 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
743
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
744 for (l = msg->attr_list; l; l = l->next)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
745 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
746 char *key;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
747 const char *value;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
748
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
749 key = l->data;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
750 value = msn_message_get_attr(msg, key);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
751
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
752 g_string_append_printf(str, "%s: %s\r\n", key, value);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
753 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
754
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
755 g_string_append(str, "\r\n");
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
756
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
757 body = msn_message_get_bin_data(msg, &body_len);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
758
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
759 if (msg->msnslp_message)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
760 {
10092
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
761 g_string_append_printf(str, "Session ID: %u\r\n", msg->msnslp_header.session_id);
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
762 g_string_append_printf(str, "ID: %u\r\n", msg->msnslp_header.id);
10112
3133c5f8eb10 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
763 g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.offset);
3133c5f8eb10 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
764 g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.total_size);
10092
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
765 g_string_append_printf(str, "Length: %u\r\n", msg->msnslp_header.length);
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
766 g_string_append_printf(str, "Flags: 0x%x\r\n", msg->msnslp_header.flags);
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
767 g_string_append_printf(str, "ACK ID: %u\r\n", msg->msnslp_header.ack_id);
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
768 g_string_append_printf(str, "SUB ID: %u\r\n", msg->msnslp_header.ack_sub_id);
10112
3133c5f8eb10 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
769 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
770
27770
9d4cc577fe26 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
771 if (purple_debug_is_verbose() && body != NULL)
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
772 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
773 if (text_body)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
774 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
775 g_string_append_len(str, body, body_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
776 if (body[body_len - 1] == '\0')
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
777 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
778 str->len--;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
779 g_string_append(str, " 0x00");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
780 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
781 g_string_append(str, "\r\n");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
782 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
783 else
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
784 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
785 int i;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
786 for (i = 0; i < msg->body_len; i++)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
787 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
788 g_string_append_printf(str, "%.2hhX ", body[i]);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
789 if ((i % 16) == 15)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
790 g_string_append(str, "\r\n");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
791 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
792 g_string_append(str, "\r\n");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
793 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
794 }
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
795
10092
48f870a068a1 [gaim-migrate @ 11109]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9198
diff changeset
796 g_string_append_printf(str, "Footer: %u\r\n", msg->msnslp_footer.value);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
797 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
798 else
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
799 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
800 if (body != NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
801 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
802 g_string_append_len(str, body, body_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
803 g_string_append(str, "\r\n");
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
804 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
805 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
806
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
807 purple_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
808
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
809 g_string_free(str, TRUE);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
810 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
811
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
812 /**************************************************************************
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
813 * Message Handlers
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
814 **************************************************************************/
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
815 void
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
816 msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
817 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
818 PurpleConnection *gc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
819 const char *body;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
820 char *body_str;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
821 char *body_enc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
822 char *body_final;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
823 size_t body_len;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
824 const char *passport;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
825 const char *value;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
826
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
827 gc = cmdproc->session->account->gc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
828
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
829 body = msn_message_get_bin_data(msg, &body_len);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
830 body_str = g_strndup(body, body_len);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
831 body_enc = g_markup_escape_text(body_str, -1);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
832 g_free(body_str);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
833
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
834 passport = msg->remote_user;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
835
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
836 if (!strcmp(passport, "messenger@microsoft.com") &&
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
837 strstr(body, "immediate security update"))
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
838 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
839 return;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
840 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
841
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
842 #if 0
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
843 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL)
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
844 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
845 purple_debug_misc("msn", "User-Agent = '%s'\n", value);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
846 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
847 #endif
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
848
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
849 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL)
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
850 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
851 char *pre, *post;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
852
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
853 msn_parse_format(value, &pre, &post);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
854
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
855 body_final = g_strdup_printf("%s%s%s", pre ? pre : "",
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
856 body_enc ? body_enc : "", post ? post : "");
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
857
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
858 g_free(pre);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
859 g_free(post);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
860 g_free(body_enc);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
861 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
862 else
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
863 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
864 body_final = body_enc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
865 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
866
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
867 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
868 MsnSwitchBoard *swboard = cmdproc->data;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
869
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
870 swboard->flag |= MSN_SB_FLAG_IM;
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
871
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
872 if (swboard->current_users > 1 ||
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
873 ((swboard->conv != NULL) &&
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
874 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
875 {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
876 /* If current_users is always ok as it should then there is no need to
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
877 * check if this is a chat. */
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
878 if (swboard->current_users <= 1)
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
879 purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
880 swboard->current_users);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
881
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
882 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
883 time(NULL));
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
884 if (swboard->conv == NULL)
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
885 {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
886 swboard->conv = purple_find_chat(gc, swboard->chat_id);
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
887 swboard->flag |= MSN_SB_FLAG_IM;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
888 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
889 }
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
890 else
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
891 {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
892 serv_got_im(gc, passport, body_final, 0, time(NULL));
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
893 if (swboard->conv == NULL)
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
894 {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
895 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
896 passport, purple_connection_get_account(gc));
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
897 swboard->flag |= MSN_SB_FLAG_IM;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
898 }
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
899 }
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
900
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
901 } else {
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
902 serv_got_im(gc, passport, body_final, 0, time(NULL));
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
903 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
904
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
905 g_free(body_final);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
906 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
907
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
908 void
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
909 msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
910 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
911 PurpleConnection *gc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
912 char *passport;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
913
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
914 gc = cmdproc->session->account->gc;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
915 passport = msg->remote_user;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
916
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
917 if (msn_message_get_attr(msg, "TypingUser") == NULL)
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
918 return;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
919
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
920 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
921 MsnSwitchBoard *swboard = cmdproc->data;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
922
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
923 if (swboard->current_users == 1)
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
924 {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
925 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
926 PURPLE_TYPING);
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
927 }
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
928
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
929 } else {
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
930 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
931 PURPLE_TYPING);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
932 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
933 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
934
27690
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
935 static void
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
936 datacast_inform_user(MsnSwitchBoard *swboard, const char *who,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
937 const char *msg, const char *filename)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
938 {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
939 char *username, *str;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
940 PurpleAccount *account;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
941 PurpleBuddy *b;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
942
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
943 account = swboard->session->account;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
944
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
945 if ((b = purple_find_buddy(account, who)) != NULL)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
946 username = g_markup_escape_text(purple_buddy_get_alias(b), -1);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
947 else
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
948 username = g_markup_escape_text(who, -1);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
949 str = g_strdup_printf(msg, username, filename);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
950 g_free(username);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
951
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
952 if (swboard->conv == NULL) {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
953 if (swboard->current_users > 1)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
954 swboard->conv = purple_find_chat(account->gc, swboard->chat_id);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
955 else {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
956 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
957 who, account);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
958 if (swboard->conv == NULL)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
959 swboard->conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
960 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
961 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
962 swboard->flag |= MSN_SB_FLAG_IM;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
963
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
964 purple_conversation_write(swboard->conv, NULL, str, PURPLE_MESSAGE_SYSTEM, time(NULL));
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
965 g_free(str);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
966
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
967 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
968
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
969 /* TODO: Make these not be such duplicates of each other */
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
970 static void
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
971 got_wink_cb(MsnSlpCall *slpcall, const guchar *data, gsize size)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
972 {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
973 FILE *f;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
974 char *path = NULL;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
975 const char *who = slpcall->slplink->remote_user;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
976 purple_debug_info("msn", "Received wink from %s\n", who);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
977
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
978 if ((f = purple_mkstemp(&path, TRUE))) {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
979 fwrite(data, size, 1, f);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
980 fclose(f);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
981 datacast_inform_user(slpcall->slplink->swboard,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
982 who,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
983 _("%s sent a wink. <a href='msn-wink://%s'>Click here to play it</a>"),
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
984 path);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
985 } else {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
986 purple_debug_error("msn", "Couldn\'t create temp file to store wink\n");
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
987 datacast_inform_user(slpcall->slplink->swboard,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
988 who,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
989 _("%s sent a wink, but it could not be saved"),
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
990 NULL);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
991 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
992 g_free(path);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
993 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
994
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
995 static void
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
996 got_voiceclip_cb(MsnSlpCall *slpcall, const guchar *data, gsize size)
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
997 {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
998 FILE *f;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
999 char *path = NULL;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1000 const char *who = slpcall->slplink->remote_user;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1001 purple_debug_info("msn", "Received voice clip from %s\n", who);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1002
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1003 if ((f = purple_mkstemp(&path, TRUE))) {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1004 fwrite(data, size, 1, f);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1005 fclose(f);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1006 datacast_inform_user(slpcall->slplink->swboard,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1007 who,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1008 _("%s sent a voice clip. <a href='audio://%s'>Click here to play it</a>"),
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1009 path);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1010 } else {
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1011 purple_debug_error("msn", "Couldn\'t create temp file to store sound\n");
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1012 datacast_inform_user(slpcall->slplink->swboard,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1013 who,
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1014 _("%s sent a voice clip, but it could not be saved"),
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1015 NULL);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1016 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1017 g_free(path);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1018 }
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1019
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1020 void
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1021 msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1022 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1023 GHashTable *body;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1024 const char *id;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1025 body = msn_message_get_hashtable_from_body(msg);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1026
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1027 id = g_hash_table_lookup(body, "ID");
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1028
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1029 if (!strcmp(id, "1")) {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1030 /* Nudge */
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1031 PurpleAccount *account;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1032 const char *user;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1033
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1034 account = cmdproc->session->account;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1035 user = msg->remote_user;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1036
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1037 if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1038 MsnSwitchBoard *swboard = cmdproc->data;
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1039 if (swboard->current_users > 1 ||
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1040 ((swboard->conv != NULL) &&
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1041 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1042 purple_prpl_got_attention_in_chat(account->gc, swboard->chat_id, user, MSN_NUDGE);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1043
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1044 else
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1045 purple_prpl_got_attention(account->gc, user, MSN_NUDGE);
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1046
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1047 } else {
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1048 purple_prpl_got_attention(account->gc, user, MSN_NUDGE);
25539
855cf59c9b6f Make message handlers more generic and able to work when used by the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25538
diff changeset
1049 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1050
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1051 } else if (!strcmp(id, "2")) {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1052 /* Wink */
27690
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1053 MsnSession *session;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1054 MsnSlpLink *slplink;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1055 MsnObject *obj;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1056 const char *who;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1057 const char *data;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1058
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1059 session = cmdproc->session;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1060
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1061 data = g_hash_table_lookup(body, "Data");
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1062 obj = msn_object_new_from_string(data);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1063 who = msn_object_get_creator(obj);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1064
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1065 slplink = msn_session_get_slplink(session, who);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1066 msn_slplink_request_object(slplink, data, got_wink_cb, NULL, obj);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1067
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1068 msn_object_destroy(obj);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1069
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1070
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1071 } else if (!strcmp(id, "3")) {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1072 /* Voiceclip */
27690
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1073 MsnSession *session;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1074 MsnSlpLink *slplink;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1075 MsnObject *obj;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1076 const char *who;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1077 const char *data;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1078
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1079 session = cmdproc->session;
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1080
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1081 data = g_hash_table_lookup(body, "Data");
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1082 obj = msn_object_new_from_string(data);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1083 who = msn_object_get_creator(obj);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1084
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1085 slplink = msn_session_get_slplink(session, who);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1086 msn_slplink_request_object(slplink, data, got_voiceclip_cb, NULL, obj);
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1087
c84c192f7a9e Add support for receiving winks and audio clips on MSN. The resulting file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
1088 msn_object_destroy(obj);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1089
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1090 } else if (!strcmp(id, "4")) {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1091 /* Action */
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1092
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1093 } else {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1094 purple_debug_warning("msn", "Got unknown datacast with ID %s.\n", id);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1095 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1096
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1097 g_hash_table_destroy(body);
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1098 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1099
26739
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1100 void
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1101 msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1102 {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1103 GHashTable *body;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1104 const gchar *guid;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1105
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1106 g_return_if_fail(cmdproc != NULL);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1107 g_return_if_fail(msg != NULL);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1108
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1109 body = msn_message_get_hashtable_from_body(msg);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1110
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1111 if (body == NULL) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1112 purple_debug_warning("msn",
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1113 "Unable to parse invite msg body.\n");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1114 return;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1115 }
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1116
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1117 guid = g_hash_table_lookup(body, "Application-GUID");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1118
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1119 if (guid == NULL) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1120 const gchar *cmd = g_hash_table_lookup(
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1121 body, "Invitation-Command");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1122
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1123 if (cmd && !strcmp(cmd, "CANCEL")) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1124 const gchar *code = g_hash_table_lookup(
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1125 body, "Cancel-Code");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1126 purple_debug_info("msn",
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1127 "MSMSGS invitation cancelled: %s.\n",
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1128 code ? code : "no reason given");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1129 } else
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1130 purple_debug_warning("msn", "Invite msg missing "
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1131 "Application-GUID.\n");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1132 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1133 purple_debug_info("msn", "Computer call\n");
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1134
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1135 if (cmdproc->session) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1136 PurpleConversation *conv = NULL;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1137 gchar *from = msg->remote_user;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1138 gchar *buf = NULL;
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1139
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1140 if (from)
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1141 conv = purple_find_conversation_with_account(
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1142 PURPLE_CONV_TYPE_IM, from,
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1143 cmdproc->session->account);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1144 if (conv)
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1145 buf = g_strdup_printf(
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1146 _("%s sent you a voice chat "
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1147 "invite, which is not yet "
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1148 "supported."), from);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1149 if (buf) {
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1150 purple_conversation_write(conv, NULL, buf,
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1151 PURPLE_MESSAGE_SYSTEM |
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1152 PURPLE_MESSAGE_NOTIFY,
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1153 time(NULL));
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1154 g_free(buf);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1155 }
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1156 }
28145
95c36b80165a Print name of application in the invite to the debug log if it's available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27828
diff changeset
1157 } else {
95c36b80165a Print name of application in the invite to the debug log if it's available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27828
diff changeset
1158 const gchar *application = g_hash_table_lookup(body, "Application-Name");
95c36b80165a Print name of application in the invite to the debug log if it's available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27828
diff changeset
1159 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n",
95c36b80165a Print name of application in the invite to the debug log if it's available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27828
diff changeset
1160 guid, application ? application : "(null)");
95c36b80165a Print name of application in the invite to the debug log if it's available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27828
diff changeset
1161 }
26739
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1162
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1163 g_hash_table_destroy(body);
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1164 }
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1165
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1166 /* Only called from chats. Handwritten messages for IMs come as a SLP message */
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1167 void
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1168 msn_handwritten_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1169 {
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1170 const char *body;
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1171 size_t body_len;
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1172
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1173 body = msn_message_get_bin_data(msg, &body_len);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1174 msn_switchboard_show_ink(cmdproc->data, msg->remote_user, body);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1175 }
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1176

mercurial