libpurple/protocols/msn/msg.c

Sat, 11 Jul 2015 14:45:46 -0400

author
James Geboski <jgeboski@gmail.com>
date
Sat, 11 Jul 2015 14:45:46 -0400
branch
facebook
changeset 37293
dc35ba3e7fac
parent 37158
96b5ab42da00
child 38284
363082ee4eec
permissions
-rw-r--r--

facebook: fixed all errors being marked as fatal

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 */
30945
b875cf477e19 Remove unnecesary includes from msn.h.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30940
diff changeset
24
30961
885064b16c54 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30945
diff changeset
25 #include "internal.h"
30945
b875cf477e19 Remove unnecesary includes from msn.h.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30940
diff changeset
26 #include "debug.h"
b875cf477e19 Remove unnecesary includes from msn.h.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30940
diff changeset
27
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "msn.h"
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
29 #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
30 #include "msnutils.h"
30987
5d18cc98412b Use slp parse code that was just moved to SlpMessage since it belongs there
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30977
diff changeset
31 #include "slpmsg.h"
31023
fbf4d4d3aaad Destroy Part when the Message is destroyed.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31022
diff changeset
32 #include "slpmsg_part.h"
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
34 MsnMessage *
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
35 msn_message_new(MsnMsgType type)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
36 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
37 MsnMessage *msg;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
38
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
39 msg = g_new0(MsnMessage, 1);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
40 msg->type = type;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
41
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
42 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
43 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
44
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
45 msg->header_table = g_hash_table_new_full(g_str_hash, g_str_equal,
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
46 g_free, g_free);
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
47
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
48 msn_message_ref(msg);
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
49
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
50 return msg;
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
51 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
52
31162
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
53 /**
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
54 * Destroys a message.
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
55 *
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
56 * @param msg The message to destroy.
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
57 */
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
58 static void
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
59 msn_message_destroy(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
60 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
61 g_return_if_fail(msg != NULL);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
62
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
63 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
64 purple_debug_info("msn", "message destroy (%p)\n", msg);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
65
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
66 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
67 g_free(msg->body);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
68 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
69 g_free(msg->charset);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
70
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
71 g_hash_table_destroy(msg->header_table);
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
72 g_list_free(msg->header_list);
31240
db0cb3d72bc9 Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31238
diff changeset
73 if (msg->part)
db0cb3d72bc9 Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31238
diff changeset
74 msn_slpmsgpart_unref(msg->part);
10345
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_free(msg);
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
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
79 MsnMessage *
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
80 msn_message_ref(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
81 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
82 g_return_val_if_fail(msg != NULL, NULL);
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
83
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
84 msg->ref_count++;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
85
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
86 if (purple_debug_is_verbose())
31235
d347d296b0e6 As Mark did before, we probably don't need a return value from these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31163
diff changeset
87 purple_debug_info("msn", "message ref (%p)[%u]\n", msg, msg->ref_count);
10345
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 return msg;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
90 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
91
31163
871af3e6f338 Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <markdoliner@pidgin.im>
parents: 31162
diff changeset
92 void
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
93 msn_message_unref(MsnMessage *msg)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
94 {
31163
871af3e6f338 Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <markdoliner@pidgin.im>
parents: 31162
diff changeset
95 g_return_if_fail(msg != NULL);
871af3e6f338 Nothing uses this return value, so stop returning it. I think it's weird
Mark Doliner <markdoliner@pidgin.im>
parents: 31162
diff changeset
96 g_return_if_fail(msg->ref_count > 0);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
97
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
98 msg->ref_count--;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
99
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
100 if (purple_debug_is_verbose())
31235
d347d296b0e6 As Mark did before, we probably don't need a return value from these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31163
diff changeset
101 purple_debug_info("msn", "message unref (%p)[%u]\n", msg, msg->ref_count);
10345
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 if (msg->ref_count == 0)
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10284
diff changeset
104 msn_message_destroy(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;
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
115 msn_message_set_header(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');
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
119 msn_message_set_header(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
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
136 msn_message_set_header(msg, "User-Agent", NULL);
6800
8f99c220b503 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
137
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
138 msn_message_set_flag(msg, 'D');
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
139 msn_message_set_content_type(msg, "application/x-msnmsgrp2p");
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
140
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
141 return msg;
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
11321
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
144 MsnMessage *
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
145 msn_message_new_nudge(void)
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
146 {
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
147 MsnMessage *msg;
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 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
150 msn_message_set_content_type(msg, "text/x-msnmsgr-datacast");
11321
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
151 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
152 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
153
a93121c0ea16 [gaim-migrate @ 13525]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11235
diff changeset
154 return msg;
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
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
157 void
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
158 msn_message_parse_payload(MsnMessage *msg,
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
159 const char *payload, size_t payload_len,
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
160 const char *line_dem,const char *body_dem)
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
162 char *tmp_base, *tmp;
7845
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
163 const char *content_type;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
164 char *end;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
165 char **elems, **cur, **tokens;
5454
5263b77f0ad9 [gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents: 5315
diff changeset
166
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
167 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
168 tmp_base = tmp = g_malloc(payload_len + 1);
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10345
diff changeset
169 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
170 tmp_base[payload_len] = '\0';
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
171
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
172 /* Find the end of the headers */
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
173 end = strstr(tmp, body_dem);
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
174 /* 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
175 * 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
176 * avoid crashing for now */
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
177 if (end == NULL) {
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
178 g_free(tmp_base);
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
179 g_return_if_reached();
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
180 }
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
181
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
182 /* NUL-terminate the end of the headers - it'll get skipped over below */
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
183 *end = '\0';
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
184
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
185 /* Split the headers and parse each one */
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
186 elems = g_strsplit(tmp, line_dem, 0);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
187 for (cur = elems; *cur != NULL; cur++)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
188 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
189 const char *key, *value;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
190
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
191 /* 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
192 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
193 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
194 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
195 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
196 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
197
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
198 /* 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
199 the key 'Content-Type'), so only process that. */
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
200 if (!strcmp(key, "boundary") && value) {
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
201 char *end = strchr(value, '\"');
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
202 if (end) {
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
203 *end = '\0';
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
204 msn_message_set_header(msg, key, value);
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
205 }
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
206 }
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
207
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
208 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
209 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
210 }
4dacf7e20b77 When parsing MSN message payload headers, check for folded lines. The only
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24608
diff changeset
211
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
212 tokens = g_strsplit(*cur, ": ", 2);
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 key = tokens[0];
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
215 value = tokens[1];
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
216
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
217 if (!strcmp(key, "MIME-Version"))
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
218 {
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
219 /* Ignore MIME-Version header */
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
220 }
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
221 else if (!strcmp(key, "Content-Type"))
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
222 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
223 char *charset, *c;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
224
35201
23cbfff68a0c msn: Fix NUL-pointer deref issue parsing Message Headers
Daniel Atallah <datallah@pidgin.im>
parents: 32130
diff changeset
225 if (value && (c = strchr(value, ';')) != NULL)
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
226 {
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
227 if ((charset = strchr(c, '=')) != NULL)
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
228 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
229 charset++;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
230 msn_message_set_charset(msg, charset);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
231 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
232
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
233 *c = '\0';
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
234 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
235
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
236 msn_message_set_content_type(msg, value);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
237 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
238 else
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
239 {
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
240 msn_message_set_header(msg, key, value);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
241 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
242
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
243 g_strfreev(tokens);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
244 }
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
245 g_strfreev(elems);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
246
10981
11def8085a30 [gaim-migrate @ 12812]
Daniel Atallah <datallah@pidgin.im>
parents: 10481
diff changeset
247 /* Proceed to the end of the "\r\n\r\n" */
13886
e1d21534ecff [gaim-migrate @ 16973]
Ma Yuan <mayuan2006@gmail.com>
parents: 13880
diff changeset
248 tmp = end + strlen(body_dem);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
249
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
250 /* Now we *should* be at the body. */
7845
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
251 content_type = msn_message_get_content_type(msg);
edeb70aa2413 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
252
30989
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
253 if (payload_len - (tmp - tmp_base) > 0) {
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
254 msg->body_len = payload_len - (tmp - tmp_base);
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
255 g_free(msg->body);
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
256 msg->body = g_malloc(msg->body_len + 1);
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
257 memcpy(msg->body, tmp, msg->body_len);
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
258 msg->body[msg->body_len] = '\0';
e826f32521d6 Remove replaced code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30987
diff changeset
259 }
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
260
32130
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
261 if (msg->body && content_type && purple_str_has_prefix(content_type, "text/")) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
262 char *body = NULL;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
263
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
264 if (msg->charset == NULL || g_str_equal(msg->charset, "UTF-8")) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
265 /* Charset is UTF-8 */
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
266 if (!g_utf8_validate(msg->body, msg->body_len, NULL)) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
267 purple_debug_warning("msn", "Message contains invalid "
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
268 "UTF-8. Attempting to salvage.\n");
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
269 body = purple_utf8_salvage(msg->body);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
270 payload_len = strlen(body);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
271 }
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
272 } else {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
273 /* Charset is something other than UTF-8 */
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
274 GError *err = NULL;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
275 body = g_convert(msg->body, msg->body_len, "UTF-8",
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
276 msg->charset, NULL, &payload_len, &err);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
277 if (!body || err) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
278 purple_debug_warning("msn", "Unable to convert message from "
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
279 "%s to UTF-8: %s\n", msg->charset,
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
280 err ? err->message : "Unknown error");
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
281 if (err)
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
282 g_error_free(err);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
283
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
284 /* Fallback to ISO-8859-1 */
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
285 g_free(body);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
286 body = g_convert(msg->body, msg->body_len, "UTF-8",
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
287 "ISO-8859-1", NULL, &payload_len, NULL);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
288 if (!body) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
289 g_free(msg->body);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
290 msg->body = NULL;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
291 msg->body_len = 0;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
292 }
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
293 }
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
294 }
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
295
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
296 if (body) {
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
297 g_free(msg->body);
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
298 msg->body = body;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
299 msg->body_len = payload_len;
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
300 msn_message_set_charset(msg, "UTF-8");
4d6bcb4f4ea4 Fix a possible MSN remote crash
Mark Doliner <markdoliner@pidgin.im>
parents: 31790
diff changeset
301 }
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
302 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
303
6011
a7fd3284655c [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
304 g_free(tmp_base);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
305 }
6011
a7fd3284655c [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
306
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
307 MsnMessage *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
308 msn_message_new_from_cmd(MsnSession *session, MsnCommand *cmd)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
309 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
310 MsnMessage *msg;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
311
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
312 g_return_val_if_fail(cmd != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
313
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
314 msg = msn_message_new(MSN_MSG_UNKNOWN);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
315
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
316 msg->remote_user = g_strdup(cmd->params[0]);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
317 /* msg->size = atoi(cmd->params[2]); */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
318 msg->cmd = cmd;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
319
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
320 return msg;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
321 }
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
323 char *
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
324 msn_message_gen_payload(MsnMessage *msg, size_t *ret_size)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
325 {
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
326 GString *payload;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
327 GList *l;
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
328 size_t body_len;
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
329 const void *body;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
330
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
331 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
332
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
333 /* 8192 is a reasonable guess at a large enough buffer to avoid realloc */
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
334 payload = g_string_sized_new(8192);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
335
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
336 /* Standard header */
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
337 if (msg->charset == NULL) {
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
338 g_string_append_printf(payload,
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
339 "MIME-Version: 1.0\r\n"
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
340 "Content-Type: %s\r\n",
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
341 msg->content_type);
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
342 } else {
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
343 g_string_append_printf(payload,
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
344 "MIME-Version: 1.0\r\n"
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
345 "Content-Type: %s; charset=%s\r\n",
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
346 msg->content_type, msg->charset);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
347 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
348
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
349 /* Headers */
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
350 for (l = msg->header_list; l != NULL; l = l->next)
8646
74d0e7406e3b [gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8475
diff changeset
351 {
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
352 const char *key;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
353 const char *value;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
354
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
355 key = l->data;
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
356 value = msn_message_get_header_value(msg, key);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
357
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
358 g_string_append_printf(payload, "%s: %s\r\n", key, value);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
359 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
360
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
361 /* End of headers */
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
362 g_string_append(payload, "\r\n");
6827
df4411142ece [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
363
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
364 /* Body */
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
365 body = msn_message_get_bin_data(msg, &body_len);
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
366 if (body != NULL) {
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
367 g_string_append_len(payload, body, body_len);
5310
ac2ee6a1f846 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
368 }
ac2ee6a1f846 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
369
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
370 if (ret_size != NULL) {
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
371 /* Use MIN to truncate the payload to 1664 bytes? Why do we do this?
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
372 It seems like it will lead to brokenness. */
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
373 *ret_size = MIN(payload->len, 1664);
9092
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
374 }
34b9e78827f6 [gaim-migrate @ 9869]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 8647
diff changeset
375
35371
16ad7fd07d76 Use safer string building in msn_message_gen_payload
Mark Doliner <mark@kingant.net>
parents: 35265
diff changeset
376 return g_string_free(payload, FALSE);
4542
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 }
05a476dec582 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
379 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
380 msn_message_set_flag(MsnMessage *msg, char flag)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
381 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
382 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
383 g_return_if_fail(flag != 0);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
384
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
385 msg->flag = flag;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
386 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
387
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
388 char
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
389 msn_message_get_flag(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
390 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
391 g_return_val_if_fail(msg != NULL, 0);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
392
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
393 return msg->flag;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
394 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
395
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
396 void
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
397 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
398 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
399 g_return_if_fail(msg != NULL);
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
400
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
401 /* 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
402 if (len > 1664)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
403 len = 1664;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
404
32979
e891b5995bf7 Remove redundant check (g_free does this for us)
Mark Doliner <markdoliner@pidgin.im>
parents: 32678
diff changeset
405 g_free(msg->body);
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
406
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
407 if (data != NULL && len > 0)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
408 {
24608
9f21d921daaf It should be more efficient to just use g_mallc() and then manually
Mark Doliner <markdoliner@pidgin.im>
parents: 24420
diff changeset
409 msg->body = g_malloc(len + 1);
11235
7e1cd737137b [gaim-migrate @ 13380]
Federico G. Schwindt <fgsch@lodoss.net>
parents: 11001
diff changeset
410 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
411 msg->body[len] = '\0';
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
412 msg->body_len = len;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
413 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
414 else
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
415 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
416 msg->body = NULL;
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
417 msg->body_len = 0;
6868
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
418 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
419 }
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
420
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
421 const void *
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
422 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
423 {
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
424 g_return_val_if_fail(msg != NULL, NULL);
b9cc0730e11c [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
425
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
426 if (len)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
427 *len = msg->body_len;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
428
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
429 return msg->body;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
430 }
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 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
433 msn_message_set_content_type(MsnMessage *msg, const char *type)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
434 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
435 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
436
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
437 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
438 msg->content_type = g_strdup(type);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
439 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
440
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
441 const char *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
442 msn_message_get_content_type(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
443 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
444 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
445
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
446 return msg->content_type;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
447 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
448
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
449 void
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
450 msn_message_set_charset(MsnMessage *msg, const char *charset)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
451 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
452 g_return_if_fail(msg != NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
453
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
454 g_free(msg->charset);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 21065
diff changeset
455 msg->charset = g_strdup(charset);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
456 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
457
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
458 const char *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
459 msn_message_get_charset(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
460 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
461 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
462
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
463 return msg->charset;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
464 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
465
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
466 void
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
467 msn_message_set_header(MsnMessage *msg, const char *name, const char *value)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
468 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
469 const char *temp;
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
470 char *new_name;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
471
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
472 g_return_if_fail(msg != NULL);
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
473 g_return_if_fail(name != NULL);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
474
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
475 temp = msn_message_get_header_value(msg, name);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
476
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
477 if (value == NULL)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
478 {
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
479 if (temp != NULL)
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
480 {
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
481 GList *l;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
482
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
483 for (l = msg->header_list; l != NULL; l = l->next)
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
484 {
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
485 if (!g_ascii_strcasecmp(l->data, name))
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
486 {
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
487 msg->header_list = g_list_remove(msg->header_list, l->data);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
488
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
489 break;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
490 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
491 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
492
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
493 g_hash_table_remove(msg->header_table, name);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
494 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
495
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
496 return;
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
497 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
498
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
499 new_name = g_strdup(name);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
500
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
501 g_hash_table_insert(msg->header_table, new_name, g_strdup(value));
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
502
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
503 if (temp == NULL)
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
504 msg->header_list = g_list_append(msg->header_list, new_name);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
505 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
506
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
507 const char *
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
508 msn_message_get_header_value(const MsnMessage *msg, const char *name)
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
509 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
510 g_return_val_if_fail(msg != NULL, NULL);
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
511 g_return_val_if_fail(name != NULL, NULL);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
512
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
513 return g_hash_table_lookup(msg->header_table, name);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
514 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
515
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
516 GHashTable *
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
517 msn_message_get_hashtable_from_body(const MsnMessage *msg)
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
518 {
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
519 GHashTable *table;
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
520 size_t body_len;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
521 const char *body;
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
522 char **elems, **cur, **tokens, *body_str;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
523
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
524 g_return_val_if_fail(msg != NULL, NULL);
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
525
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
526 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
527
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
528 body = msn_message_get_bin_data(msg, &body_len);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
529
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
530 g_return_val_if_fail(body != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
531
10284
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
532 body_str = g_strndup(body, body_len);
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
533 elems = g_strsplit(body_str, "\r\n", 0);
257978b5df5b [gaim-migrate @ 11454]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10275
diff changeset
534 g_free(body_str);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
535
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
536 for (cur = elems; *cur != NULL; cur++)
9158
f8dab42adeaf [gaim-migrate @ 9942]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9092
diff changeset
537 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
538 if (**cur == '\0')
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
539 break;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
540
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
541 tokens = g_strsplit(*cur, ": ", 2);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
542
21010
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
543 if (tokens[0] != NULL && tokens[1] != NULL) {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
544 g_hash_table_insert(table, tokens[0], tokens[1]);
21010
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
545 g_free(tokens);
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
546 } else
2bd8577a08e5 Fix some leaks.
Daniel Atallah <datallah@pidgin.im>
parents: 20600
diff changeset
547 g_strfreev(tokens);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
548 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
549
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
550 g_strfreev(elems);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
551
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
552 return table;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
553 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
554
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
555 char *
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
556 msn_message_to_string(MsnMessage *msg)
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
557 {
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
558 size_t body_len;
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
559 const char *body;
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
560
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
561 g_return_val_if_fail(msg != NULL, NULL);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
562 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
563
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
564 body = msn_message_get_bin_data(msg, &body_len);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
565
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
566 return g_strndup(body, body_len);
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
567 }
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10112
diff changeset
568
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
569 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
570 msn_message_show_readable(MsnMessage *msg, const char *info,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
571 gboolean text_body)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
572 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
573 GString *str;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
574 size_t body_len;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
575 const char *body;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
576 GList *l;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
577
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
578 g_return_if_fail(msg != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
579
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
580 str = g_string_new(NULL);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
581
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
582 /* Standard header. */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
583 if (msg->charset == NULL)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
584 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
585 g_string_append_printf(str,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
586 "MIME-Version: 1.0\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
587 "Content-Type: %s\r\n",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
588 msg->content_type);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
589 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
590 else
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
591 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
592 g_string_append_printf(str,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
593 "MIME-Version: 1.0\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
594 "Content-Type: %s; charset=%s\r\n",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
595 msg->content_type, msg->charset);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
596 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
597
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
598 for (l = msg->header_list; l; l = l->next)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
599 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
600 char *key;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
601 const char *value;
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
602
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
603 key = l->data;
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
604 value = msn_message_get_header_value(msg, key);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
605
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
606 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
607 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
608
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
609 g_string_append(str, "\r\n");
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
610
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
611 body = msn_message_get_bin_data(msg, &body_len);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
612
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
613 if (body != NULL)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
614 {
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
615 if (msg->type == MSN_MSG_TEXT)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
616 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
617 g_string_append_len(str, body, body_len);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
618 g_string_append(str, "\r\n");
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
619 }
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
620 else
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
621 {
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
622 size_t i;
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
623 for (i = 0; i < body_len; i++, body++)
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
624 {
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
625 g_string_append_printf(str, "%02x ", (unsigned char)*body);
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
626 if (i % 16 == 0 && i != 0)
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
627 g_string_append_c(str, '\n');
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
628 }
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
629 g_string_append_c(str, '\n');
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
630 }
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
631 }
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
632
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
633 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
634
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 9158
diff changeset
635 g_string_free(str, TRUE);
5309
3178acad1449 [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
636 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
637
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
638 /**************************************************************************
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
639 * 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
640 **************************************************************************/
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
641 void
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
642 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
643 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
644 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
645 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
646 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
647 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
648 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
649 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
650 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
651
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
652 gc = purple_account_get_connection(cmdproc->session->account);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
653
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
654 body = msn_message_get_bin_data(msg, &body_len);
29462
49853c4082d3 I don't believe there's any reason to duplicate this string.
Mark Doliner <markdoliner@pidgin.im>
parents: 29457
diff changeset
655 body_enc = g_markup_escape_text(body, body_len);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
656
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
657 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
658
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
659 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
660 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
661 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
662 return;
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
663 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
664
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
665 #if 0
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
666 if ((value = msn_message_get_header_value(msg, "User-Agent")) != NULL)
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
667 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
668 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
669 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
670 #endif
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
671
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
672 if ((value = msn_message_get_header_value(msg, "X-MMS-IM-Format")) != NULL)
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
673 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
674 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
675
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
676 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
677
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
678 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
679 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
680
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
681 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
682 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
683 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
684 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
685 else
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
686 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
687 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
688 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
689
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
690 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
691 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
692
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
693 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
694
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
695 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
696 ((swboard->conv != NULL) &&
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
697 PURPLE_IS_CHAT_CONVERSATION(swboard->conv)))
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
698 {
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
699 /* 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
700 * 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
701 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
702 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
703 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
704
36092
cf0a11121049 Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36089
diff changeset
705 purple_serv_got_chat_in(gc, swboard->chat_id, passport,
cf0a11121049 Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36089
diff changeset
706 PURPLE_MESSAGE_RECV, body_final, time(NULL));
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
707 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
708 {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
709 swboard->conv = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, swboard->chat_id));
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
710 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
711 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
712 }
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32624
diff changeset
713 else if (!g_str_equal(passport, purple_account_get_username(purple_connection_get_account(gc))))
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
714 {
30939
f3f4e9b1b6cc Don't treat messages got from ourself from a switchboard like a new message. This fixes the multiple conversation open with ourself.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30929
diff changeset
715 /* Don't im ourselves ... */
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
716 purple_serv_got_im(gc, passport, body_final, 0, time(NULL));
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
717 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
718 {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
719 swboard->conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
720 passport, purple_connection_get_account(gc)));
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
721 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
722 }
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
723 }
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
724
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
725 } else {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
726 purple_serv_got_im(gc, passport, body_final, 0, time(NULL));
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
727 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
728
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
729 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
730 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
731
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
732 void
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
733 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
734 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
735 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
736 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
737
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
738 gc = purple_account_get_connection(cmdproc->session->account);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
739 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
740
29457
15f977c9ac76 Rename "attribute" to "header" in a bunch of places. The SLP protocol
Mark Doliner <markdoliner@pidgin.im>
parents: 28146
diff changeset
741 if (msn_message_get_header_value(msg, "TypingUser") == NULL)
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
742 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
743
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
744 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
745 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
746
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
747 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
748 {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
749 purple_serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34638
diff changeset
750 PURPLE_IM_TYPING);
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
751 }
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
752
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
753 } else {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
754 purple_serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34638
diff changeset
755 PURPLE_IM_TYPING);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
756 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
757 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
758
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
759 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
760 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
761 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
762 {
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
763 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
764 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
765 PurpleBuddy *b;
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
766 PurpleConnection *pc;
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
767 gboolean chat;
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
768
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
769 account = swboard->session->account;
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
770 pc = purple_account_get_connection(account);
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
771
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
772 if ((b = purple_blist_find_buddy(account, who)) != NULL)
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
773 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
774 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
775 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
776 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
777 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
778
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
779 swboard->flag |= MSN_SB_FLAG_IM;
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
780 if (swboard->current_users > 1)
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
781 chat = TRUE;
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
782 else
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
783 chat = FALSE;
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
784
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
785 if (swboard->conv == NULL) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
786 if (chat)
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
787 swboard->conv = PURPLE_CONVERSATION(purple_conversations_find_chat(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
788 purple_account_get_connection(account), swboard->chat_id));
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
789 else {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
790 swboard->conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
791 who, account));
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
792 if (swboard->conv == NULL)
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
793 swboard->conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, who));
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
794 }
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
795 }
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
796
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
797 if (chat)
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
798 purple_serv_got_chat_in(pc,
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
799 purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(swboard->conv)),
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
800 who, PURPLE_MESSAGE_RECV|PURPLE_MESSAGE_SYSTEM, str,
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
801 time(NULL));
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
802 else
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35371
diff changeset
803 purple_serv_got_im(pc, who, str, PURPLE_MESSAGE_RECV|PURPLE_MESSAGE_SYSTEM,
30200
50c2380f3607 Use serv_got_im/serv_got_chat_in instead of purple_conversation_write so
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
804 time(NULL));
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
805 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
806
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
807 }
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
808
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
809 /* TODO: Make these not be such duplicates of each other */
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
810 static void
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
811 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
812 {
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
813 FILE *f = NULL;
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
814 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
815 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
816 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
817
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
818 if ((f = purple_mkstemp(&path, TRUE)) &&
30064
9e6f32b8ced9 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30063
diff changeset
819 (fwrite(data, 1, size, f) == size)) {
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
820 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
821 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
822 _("%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
823 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
824 } 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
825 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
826 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
827 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
828 _("%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
829 NULL);
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
830 }
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
831 if (f)
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
832 fclose(f);
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
833 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
834 }
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
835
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
836 static void
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
837 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
838 {
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
839 FILE *f = NULL;
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
840 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
841 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
842 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
843
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
844 if ((f = purple_mkstemp(&path, TRUE)) &&
30064
9e6f32b8ced9 Oops, make sure that check actually succeeds when it's supposed to.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30063
diff changeset
845 (fwrite(data, 1, size, f) == size)) {
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
846 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
847 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
848 _("%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
849 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
850 } 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
851 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
852 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
853 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
854 _("%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
855 NULL);
30063
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
856 }
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
857 if (f)
a42ac7c244c8 I'm tired of seeing this warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29485
diff changeset
858 fclose(f);
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
859 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
860 }
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
861
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
862 void
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
863 msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
864 {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
865 MsnSession *session;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
866 MsnSlpLink *slplink;
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
867 MsnP2PVersion p2p;
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
868
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
869 session = cmdproc->servconn->session;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
870 slplink = msn_session_get_slplink(session, msg->remote_user);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
871
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
872 if (slplink->swboard == NULL)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
873 {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
874 /*
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
875 * We will need swboard in order to change its flags. If its
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
876 * NULL, something has probably gone wrong earlier on. I
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
877 * didn't want to do this, but MSN 7 is somehow causing us
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
878 * to crash here, I couldn't reproduce it to debug more,
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
879 * and people are reporting bugs. Hopefully this doesn't
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
880 * cause more crashes. Stu.
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
881 */
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
882 if (cmdproc->data == NULL)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
883 g_warning("msn_p2p_msg cmdproc->data was NULL\n");
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
884 else {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
885 slplink->swboard = (MsnSwitchBoard *)cmdproc->data;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
886 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
887 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
888 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
889
31790
fd6e676248f8 Getting the P2P version is probably the slplink's job, since it has
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31787
diff changeset
890 p2p = msn_slplink_get_p2p_version(slplink);
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
891 msg->part = msn_slpmsgpart_new_from_data(p2p, msg->body, msg->body_len);
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
892
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
893 if (msg->part)
31060
67d11dfa6338 Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31052
diff changeset
894 msn_slplink_process_msg(slplink, msg->part);
31787
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
895 else
5ce831243797 I've always wondered why the SB layer was parsing the P2P stuff, when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31781
diff changeset
896 purple_debug_warning("msn", "P2P message failed to parse.\n");
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
897 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
898
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
899 static void
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
900 got_emoticon(MsnSlpCall *slpcall, const guchar *data, gsize size)
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
901 {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
902 PurpleConversation *conv;
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
903 PurpleSmiley *smiley;
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
904 PurpleImage *image;
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
905 MsnSwitchBoard *swboard;
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
906 const gchar *shortcut;
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
907
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
908 swboard = slpcall->slplink->swboard;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
909 conv = swboard->conv;
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
910 shortcut = slpcall->data_info;
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
911
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
912 purple_debug_info("msn", "got smiley: %s", shortcut);
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
913
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
914 if (!conv)
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
915 return;
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
916
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
917 smiley = purple_conversation_get_remote_smiley(conv, shortcut);
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
918 g_return_if_fail(smiley);
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
919 image = purple_smiley_get_image(smiley);
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
920
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
921 /* FIXME: it would be better if we wrote the data as we received it
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
922 * instead of all at once, calling write multiple times and close once
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
923 * at the very end.
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
924 */
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
925 purple_image_transfer_write(image, (gpointer)data, size);
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
926 purple_image_transfer_close(image);
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
927 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
928
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
929 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
930 {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
931 MsnSession *session;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
932 MsnSlpLink *slplink;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
933 MsnSwitchBoard *swboard;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
934 MsnObject *obj;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
935 char **tokens;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
936 char *smile, *body_str;
35769
00e61752e21c Fix build and warnings after merge
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
937 const char *body, *who; /*, *sha1;*/
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
938 guint tok;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
939 size_t body_len;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
940
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
941 PurpleConversation *conv;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
942
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
943 session = cmdproc->servconn->session;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
944
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
945 if (!purple_account_get_bool(session->account, "custom_smileys", TRUE))
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
946 return;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
947
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
948 swboard = cmdproc->data;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
949 conv = swboard->conv;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
950
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
951 body = msn_message_get_bin_data(msg, &body_len);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
952 if (!body || !body_len)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
953 return;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
954 body_str = g_strndup(body, body_len);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
955
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
956 /* MSN Messenger 7 may send more than one MSNObject in a single message...
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
957 * Maybe 10 tokens is a reasonable max value. */
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
958 tokens = g_strsplit(body_str, "\t", 10);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
959
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
960 g_free(body_str);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
961
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
962 for (tok = 0; tok < 9; tok += 2) {
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35769
diff changeset
963 PurpleSmiley *smiley;
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
964
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
965 if (tokens[tok] == NULL || tokens[tok + 1] == NULL) {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
966 break;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
967 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
968
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
969 smile = tokens[tok];
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
970 obj = msn_object_new_from_string(purple_url_decode(tokens[tok + 1]));
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
971
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
972 if (obj == NULL)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
973 break;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
974
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
975 who = msn_object_get_creator(obj);
35769
00e61752e21c Fix build and warnings after merge
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
976 #if 0
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
977 sha1 = msn_object_get_sha1(obj);
35769
00e61752e21c Fix build and warnings after merge
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
978 #endif
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
979
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
980 slplink = msn_session_get_slplink(session, who);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
981 if (slplink->swboard != swboard) {
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
982 if (slplink->swboard != NULL)
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
983 /*
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
984 * Apparently we're using a different switchboard now or
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
985 * something? I don't know if this is normal, but it
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
986 * definitely happens. So make sure the old switchboard
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
987 * doesn't still have a reference to us.
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
988 */
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
989 slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
990 slplink->swboard = swboard;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
991 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
992 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
993
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
994 /* If the conversation doesn't exist then this is a custom smiley
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
995 * used in the first message in a MSN conversation: we need to create
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
996 * the conversation now, otherwise the custom smiley won't be shown.
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
997 * This happens because every PurpleConversation has its own smiley
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
998 * tree: if the conversation doesn't exist then we cannot associate
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
999 * the new smiley with its PurpleConversation. */
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1000 if (!conv) {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1001 conv = PURPLE_CONVERSATION(purple_im_conversation_new(session->account, who));
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1002 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1003
35762
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1004 smiley = purple_conversation_add_remote_smiley(conv, smile);
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1005 if (smiley) { /* if not - it was already present */
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1006 /* TODO: cache lookup by "sha1" */
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1007
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1008 /* XXX: maybe handle end_cb and smiley download failures? */
a062d17b15e7 Remote smileys: receive them with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
1009 purple_debug_info("msn", "requesting smiley: %s", smile);
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1010 msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1011 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1012
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
1013 msn_object_destroy(obj, FALSE);
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1014 obj = NULL;
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1015 who = NULL;
35769
00e61752e21c Fix build and warnings after merge
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
1016 #if 0
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1017 sha1 = NULL;
35769
00e61752e21c Fix build and warnings after merge
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
1018 #endif
31014
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1019 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1020 g_strfreev(tokens);
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1021 }
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1022
3a5550f5ab47 Move MsnMessage callbacks to msn.c instead of polluting everywhere.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31003
diff changeset
1023 void
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1024 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
1025 {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1026 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
1027 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
1028 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
1029
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1030 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
1031
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1032 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
1033 /* Nudge */
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1034 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
1035 const char *user;
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
1036 PurpleConnection *gc;
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1037
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1038 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
1039 user = msg->remote_user;
32624
f957ad287bcc Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
1040 gc = purple_account_get_connection(account);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1041
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
1042 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
1043 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
1044 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
1045 ((swboard->conv != NULL) &&
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1046 PURPLE_IS_CHAT_CONVERSATION(swboard->conv)))
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1047 purple_protocol_got_attention_in_chat(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
1048
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 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1050 purple_protocol_got_attention(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
1051 } else {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1052 purple_protocol_got_attention(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
1053 }
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1054
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1055 } 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
1056 /* 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
1057 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
1058 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
1059 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
1060 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
1061 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
1062
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 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
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 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
1066 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
1067 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
1068
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 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
1070 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
1071
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
1072 msn_object_destroy(obj, FALSE);
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
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1074
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1075 } 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
1076 /* 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
1077 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
1078 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
1079 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
1080 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
1081 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
1082
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 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
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 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
1086 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
1087 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
1088
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
1089 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
1090 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
1091
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
1092 msn_object_destroy(obj, FALSE);
25538
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1093
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1094 } 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
1095 /* Action */
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 } else {
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1098 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
1099 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1100
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1101 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
1102 }
22182aef4300 Move some MSN message handlers from switchboard to general msg.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25417
diff changeset
1103
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
1104 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
1105 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
1106 {
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 GHashTable *body;
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1108 const gchar *command;
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1109 const gchar *cookie;
28146
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1110 gboolean accepted = FALSE;
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
1111
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 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
1113 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
1114
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 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
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 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
1118 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
1119 "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
1120 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
1121 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
1122
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1123 /*
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1124 * GUID is NOT always present but Invitation-Command and Invitation-Cookie
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1125 * are mandatory.
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1126 */
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1127 command = g_hash_table_lookup(body, "Invitation-Command");
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1128 cookie = g_hash_table_lookup(body, "Invitation-Cookie");
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
1129
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1130 if (command == NULL || cookie == NULL) {
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1131 purple_debug_warning("msn",
30079
d91306baf541 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
1132 "Invalid invitation message: either Invitation-Command "
d91306baf541 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
1133 "or Invitation-Cookie is missing or invalid.\n"
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1134 );
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1135 return;
28146
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1136
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1137 } else if (!strcmp(command, "INVITE")) {
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1138 const gchar *guid = g_hash_table_lookup(body, "Application-GUID");
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
1139
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1140 if (guid == NULL) {
30317
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1141 purple_debug_warning("msn",
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1142 "Invite msg missing Application-GUID.\n");
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
1143
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1144 accepted = TRUE;
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
1145
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1146 } else if (!strcmp(guid, MSN_FT_GUID)) {
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
1147
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1148 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1149 purple_debug_info("msn", "Computer call\n");
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
1150
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1151 if (cmdproc->session) {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1152 PurpleIMConversation *im = NULL;
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1153 gchar *from = msg->remote_user;
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1154 gchar *buf = NULL;
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1155
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1156 if (from)
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1157 im = purple_conversations_find_im_with_account(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1158 from, cmdproc->session->account);
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34635
diff changeset
1159 if (im)
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1160 buf = g_strdup_printf(
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1161 _("%s sent you a voice chat "
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1162 "invite, which is not yet "
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1163 "supported."), from);
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1164 if (buf) {
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1165 purple_conversation_write_system_message(
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1166 PURPLE_CONVERSATION(im), buf,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1167 PURPLE_MESSAGE_NOTIFY);
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1168 g_free(buf);
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1169 }
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
1170 }
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1171 } else {
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1172 const gchar *application = g_hash_table_lookup(body, "Application-Name");
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1173 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n",
30079
d91306baf541 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
1174 guid, application ? application : "(null)");
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
1175 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31240
diff changeset
1176
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1177 if (!accepted) {
28146
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1178 MsnSwitchBoard *swboard = cmdproc->data;
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1179 char *text;
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1180 MsnMessage *cancel;
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1181
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1182 cancel = msn_message_new(MSN_MSG_TEXT);
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1183 msn_message_set_content_type(cancel, "text/x-msmsgsinvite");
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1184 msn_message_set_charset(cancel, "UTF-8");
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1185 msn_message_set_flag(cancel, 'U');
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1186
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1187 text = g_strdup_printf("Invitation-Command: CANCEL\r\n"
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1188 "Invitation-Cookie: %s\r\n"
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1189 "Cancel-Code: REJECT_NOT_INSTALLED\r\n",
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1190 cookie);
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1191 msn_message_set_bin_data(cancel, text, strlen(text));
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1192 g_free(text);
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1193
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1194 msn_switchboard_send_msg(swboard, cancel, TRUE);
31162
2c596217766b msn_message_destroy() calls msn_message_unref() if refcount>0. This is
Mark Doliner <markdoliner@pidgin.im>
parents: 31136
diff changeset
1195 msn_message_unref(cancel);
28146
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1196 }
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1197
30317
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1198 } else if (!strcmp(command, "CANCEL")) {
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1199 const gchar *code = g_hash_table_lookup(body, "Cancel-Code");
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1200 purple_debug_info("msn", "MSMSGS invitation cancelled: %s.\n",
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1201 code ? code : "no reason given");
279a047f1fc8 Wait, command can't be both INVITE and CANCEL at the same time.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30216
diff changeset
1202
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1203 } else {
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1204 /*
30079
d91306baf541 More minor fixes. Spelling, extra variables, etc.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
1205 * Some other already established invitation session.
30066
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1206 * Can be retrieved by Invitation-Cookie.
25742b976ce2 Initial support for direct connections. Preliminary patch from ticket #247
Gábor Szuromi <kukkerman@gmail.com>
parents: 29485
diff changeset
1207 */
28146
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1208 }
796c252c735e Send a cancel message for any unknown text/x-msmsgsinvite requests, so that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28145
diff changeset
1209
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
1210 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
1211 }
ee13fa0be1a6 Notify the user if a contact invites them to a voice call over MSN.
Michael Ruprecht <maiku@pidgin.im>
parents: 25617
diff changeset
1212
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1213 /* 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
1214 void
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1215 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
1216 {
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1217 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
1218 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
1219
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1220 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
1221 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
1222 }
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26739
diff changeset
1223

mercurial