libpurple/protocols/msn/slpcall.c

Fri, 11 Apr 2014 20:08:22 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Fri, 11 Apr 2014 20:08:22 +0200
changeset 35827
c7c855c36c9b
parent 35765
e5fb5dd15044
child 35839
a7f91bd51911
permissions
-rw-r--r--

imgstore: unref msn

9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1 /**
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
2 * @file slpcall.c SLP Call Functions
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
4 * purple
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.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.
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
9 *
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
14 *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
19 *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.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: 17135
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
23 */
30945
b875cf477e19 Remove unnecesary includes from msn.h.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 29376
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: 29376
diff changeset
26 #include "debug.h"
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
27 #include "smiley.h"
35763
3610871f39ab Custom smileys: make them working with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35732
diff changeset
28 #include "smiley-custom.h"
30945
b875cf477e19 Remove unnecesary includes from msn.h.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 29376
diff changeset
29
20475
0b3826f0e687 The first msn-p13-merge-head.diff.gz from SF Patch #1621854 from Ka-Hing Cheung.
Richard Laager <rlaager@pidgin.im>
parents: 20472
diff changeset
30 #include "msnutils.h"
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
31 #include "slpcall.h"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
32
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
33 #include "slp.h"
30966
c9d0661c74ed Start moving p2p specific code to its own module.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30963
diff changeset
34 #include "p2p.h"
34914
d5f0fbacfbc8 Refactored msn to use the GObject xfer API.
Ankit Vani <a@nevitus.org>
parents: 34912
diff changeset
35 #include "ft.h"
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
36
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
37 /**************************************************************************
10602
111ed237f509 [gaim-migrate @ 12032]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10504
diff changeset
38 * Main
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
39 **************************************************************************/
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
40
24614
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
41 static gboolean
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
42 msn_slpcall_timeout(gpointer data)
24614
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
43 {
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
44 MsnSlpCall *slpcall;
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
45
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
46 slpcall = data;
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
47
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
48 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: 27569
diff changeset
49 purple_debug_info("msn", "slpcall_timeout: slpcall(%p)\n", slpcall);
24614
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
50
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
51 if (!slpcall->pending && !slpcall->progress)
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
52 {
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
53 msn_slpcall_destroy(slpcall);
25677
16fba57509ee We just freed slpcall, so don't set slpcall->timer to 0. And return
Mark Doliner <markdoliner@pidgin.im>
parents: 25580
diff changeset
54 return TRUE;
24614
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
55 }
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
56
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
57 slpcall->progress = FALSE;
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
58
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
59 return TRUE;
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
60 }
fa29263b7eb9 Make msn_slp_call_timeout static
Mark Doliner <markdoliner@pidgin.im>
parents: 24007
diff changeset
61
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
62 MsnSlpCall *
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
63 msn_slpcall_new(MsnSlpLink *slplink)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
64 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
65 MsnSlpCall *slpcall;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
66
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
67 g_return_val_if_fail(slplink != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
68
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
69 slpcall = g_new0(MsnSlpCall, 1);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
70
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
71 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: 27569
diff changeset
72 purple_debug_info("msn", "slpcall_new: slpcall(%p)\n", slpcall);
10773
ef88ffed66eb [gaim-migrate @ 12382]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10602
diff changeset
73
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
74 slpcall->slplink = slplink;
10602
111ed237f509 [gaim-migrate @ 12032]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10504
diff changeset
75
111ed237f509 [gaim-migrate @ 12032]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10504
diff changeset
76 msn_slplink_add_slpcall(slplink, slpcall);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
77
24619
5ece4c87ea96 Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <markdoliner@pidgin.im>
parents: 24618
diff changeset
78 slpcall->timer = purple_timeout_add_seconds(MSN_SLPCALL_TIMEOUT, msn_slpcall_timeout, slpcall);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
79
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
80 return slpcall;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
81 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
82
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
83 void
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
84 msn_slpcall_destroy(MsnSlpCall *slpcall)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
85 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
86 GList *e;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
87
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
88 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: 27569
diff changeset
89 purple_debug_info("msn", "slpcall_destroy: slpcall(%p)\n", slpcall);
10773
ef88ffed66eb [gaim-migrate @ 12382]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10602
diff changeset
90
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
91 g_return_if_fail(slpcall != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
92
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
93 if (slpcall->timer)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
94 purple_timeout_remove(slpcall->timer);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
95
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
96 for (e = slpcall->slplink->slp_msgs; e != NULL; )
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
97 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
98 MsnSlpMessage *slpmsg = e->data;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
99 e = e->next;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
100
27691
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
101 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: 27569
diff changeset
102 purple_debug_info("msn", "slpcall_destroy: trying slpmsg(%p)\n",
d77b2890043e Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27569
diff changeset
103 slpmsg);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
104
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
105 if (slpmsg->slpcall == slpcall)
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10451
diff changeset
106 {
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
107 msn_slpmsg_destroy(slpmsg);
10481
a5d6b8e1717d [gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10451
diff changeset
108 }
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
109 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
110
13126
afce0fe97885 [gaim-migrate @ 15487]
Evan Schoenberg <evands@pidgin.im>
parents: 13027
diff changeset
111 if (slpcall->end_cb != NULL)
24617
ddf4d3926ad5 There's no need for this variable anymore
Mark Doliner <markdoliner@pidgin.im>
parents: 24615
diff changeset
112 slpcall->end_cb(slpcall, slpcall->slplink->session);
13126
afce0fe97885 [gaim-migrate @ 15487]
Evan Schoenberg <evands@pidgin.im>
parents: 13027
diff changeset
113
23991
7f0f58aafd57 take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@pidgin.im>
parents: 23938
diff changeset
114 if (slpcall->xfer != NULL) {
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
115 if (purple_xfer_get_xfer_type(slpcall->xfer) == PURPLE_XFER_TYPE_RECEIVE)
28694
76761af122e8 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <darkrain42@pidgin.im>
parents: 28362
diff changeset
116 g_byte_array_free(slpcall->u.incoming_data, TRUE);
32244
21305036245c Convert the msn prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31951
diff changeset
117 purple_xfer_set_protocol_data(slpcall->xfer, NULL);
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
118 g_object_unref(slpcall->xfer);
23991
7f0f58aafd57 take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@pidgin.im>
parents: 23938
diff changeset
119 }
17135
f17d0ae4cbd0 slpcall now explicitlt references its xfer and unreferences it when it is destroyed. While it *looks* like this should *probably* have happened anyways due to the interactins between xfer_init, xfer_end, and xfer_cancel_remote, having the xfer's owner make this explicit makes the process less fragile and more obvious, and it may fix a crash as the slp is destroyed. Fixes #1070
Evan Schoenberg <evands@pidgin.im>
parents: 17134
diff changeset
120
28694
76761af122e8 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <darkrain42@pidgin.im>
parents: 28362
diff changeset
121
24615
9a156dbd94c4 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <markdoliner@pidgin.im>
parents: 24614
diff changeset
122 msn_slplink_remove_slpcall(slpcall->slplink, slpcall);
9a156dbd94c4 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <markdoliner@pidgin.im>
parents: 24614
diff changeset
123
24005
c3ac92d3222f Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23938
diff changeset
124 g_free(slpcall->id);
c3ac92d3222f Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23938
diff changeset
125 g_free(slpcall->branch);
c3ac92d3222f Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23938
diff changeset
126 g_free(slpcall->data_info);
c3ac92d3222f Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23938
diff changeset
127
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
128 g_free(slpcall);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
129 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
130
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
131 void
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
132 msn_slpcall_init(MsnSlpCall *slpcall, MsnSlpCallType type)
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
133 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
134 slpcall->session_id = rand() % 0xFFFFFF00 + 4;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
135 slpcall->id = rand_guid();
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
136 slpcall->type = type;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
137 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
138
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
139 void
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
140 msn_slpcall_session_init(MsnSlpCall *slpcall)
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
141 {
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
142 if (slpcall->session_init_cb)
23938
4570d6e22b9e Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22981
diff changeset
143 slpcall->session_init_cb(slpcall);
10345
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
144
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
145 slpcall->started = TRUE;
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
146 }
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
147
7d7f8cfa2b4f [gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10296
diff changeset
148 void
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
149 msn_slpcall_invite(MsnSlpCall *slpcall, const char *euf_guid,
31046
33671e05cf24 Documetn P2P Application ID in a enum and use it instead of 'magic numbers'.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31036
diff changeset
150 MsnP2PAppId app_id, const char *context)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
151 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
152 MsnSlpLink *slplink;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
153 MsnSlpMessage *slpmsg;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
154 char *header;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
155 char *content;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
156
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
157 g_return_if_fail(slpcall != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
158 g_return_if_fail(context != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
159
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
160 slplink = slpcall->slplink;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
161
10000
703dc5594c97 [gaim-migrate @ 10914]
Daniel Atallah <datallah@pidgin.im>
parents: 9259
diff changeset
162 slpcall->branch = rand_guid();
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
163
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
164 content = g_strdup_printf(
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
165 "EUF-GUID: {%s}\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
166 "SessionID: %lu\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
167 "AppID: %d\r\n"
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
168 "Context: %s\r\n\r\n",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
169 euf_guid,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
170 slpcall->session_id,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
171 app_id,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
172 context);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
173
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
174 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0",
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
175 slplink->remote_user);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
176
10000
703dc5594c97 [gaim-migrate @ 10914]
Daniel Atallah <datallah@pidgin.im>
parents: 9259
diff changeset
177 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, slpcall->branch,
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
178 "application/x-msnmsgr-sessionreqbody", content);
10773
ef88ffed66eb [gaim-migrate @ 12382]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10602
diff changeset
179
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
180 slpmsg->info = "SLP INVITE";
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
181 slpmsg->text_body = TRUE;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
182
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
183 msn_slplink_send_slpmsg(slplink, slpmsg);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
184
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
185 g_free(header);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
186 g_free(content);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
187 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
188
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
189 void
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
190 msn_slpcall_close(MsnSlpCall *slpcall)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
191 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
192 g_return_if_fail(slpcall != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
193 g_return_if_fail(slpcall->slplink != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
194
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
195 send_bye(slpcall, "application/x-msnmsgr-sessionclosebody");
24620
96c993e8f462 Reame msn_slplink_unleash to msn_slplink_send_queued_slpmsgs, which I
Mark Doliner <markdoliner@pidgin.im>
parents: 24619
diff changeset
196 msn_slplink_send_queued_slpmsgs(slpcall->slplink);
24618
190103ba3381 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <markdoliner@pidgin.im>
parents: 24617
diff changeset
197 msn_slpcall_destroy(slpcall);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
198 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
199
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
200 /*****************************************************************************
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
201 * Parse received SLP messages
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
202 ****************************************************************************/
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
203
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
204 /**************************************************************************
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
205 *** Util
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
206 **************************************************************************/
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
207
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
208 static char *
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
209 get_token(const char *str, const char *start, const char *end)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
210 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
211 const char *c, *c2;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
212
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
213 if ((c = strstr(str, start)) == NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
214 return NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
215
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
216 c += strlen(start);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
217
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
218 if (end != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
219 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
220 if ((c2 = strstr(c, end)) == NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
221 return NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
222
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
223 return g_strndup(c, c2 - c);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
224 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
225 else
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
226 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
227 /* This has to be changed */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
228 return g_strdup(c);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
229 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
230
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
231 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
232
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
233 /* XXX: this could be improved if we tracked custom smileys
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
234 * per-protocol, per-account, per-session or (ideally) per-conversation
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
235 *
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
236 * Note: it should be tracked on the msn prpl side.
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
237 */
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
238 static PurpleImage *
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
239 find_valid_emoticon(PurpleAccount *account, const char *path)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
240 {
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
241 GList *smileys, *it;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
242
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
243 if (!purple_account_get_bool(account, "custom_smileys", TRUE))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
244 return NULL;
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
245 smileys = purple_smiley_list_get_unique(
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
246 purple_smiley_custom_get_list());
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
247
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
248 for (it = smileys; it; it = g_list_next(it)) {
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
249 PurpleSmiley *smiley = it->data;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
250
35763
3610871f39ab Custom smileys: make them working with MSN
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35732
diff changeset
251 if (g_strcmp0(path, purple_smiley_get_path(smiley)) == 0) {
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
252 PurpleImage *img;
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
253
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
254 g_list_free(smileys);
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
255 img = purple_smiley_get_image(smiley);
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
256 g_object_ref(img);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
257 return img;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
258 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
259 }
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
260 g_list_free(smileys);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
261
35765
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
262 purple_debug_error("msn", "Received illegal request for file %s", path);
e5fb5dd15044 Smileys: MSN: reimplement find_valid_emoticon for better (new) API usage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35763
diff changeset
263
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
264 return NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
265 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
266
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
267 static char *
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
268 parse_dc_nonce(const char *content, MsnDirectConnNonceType *ntype)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
269 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
270 char *nonce;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
271
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
272 *ntype = DC_NONCE_UNKNOWN;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
273
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
274 nonce = get_token(content, "Hashed-Nonce: {", "}\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
275 if (nonce) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
276 *ntype = DC_NONCE_SHA1;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
277 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
278 guint32 n1, n6;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
279 guint16 n2, n3, n4, n5;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
280 nonce = get_token(content, "Nonce: {", "}\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
281 if (nonce
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
282 && sscanf(nonce, "%08x-%04hx-%04hx-%04hx-%04hx%08x",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
283 &n1, &n2, &n3, &n4, &n5, &n6) == 6) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
284 *ntype = DC_NONCE_PLAIN;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
285 g_free(nonce);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
286 nonce = g_malloc(16);
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
287 n1 = GUINT32_TO_LE(n1);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
288 n2 = GUINT16_TO_LE(n2);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
289 n3 = GUINT16_TO_LE(n3);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
290 n4 = GUINT16_TO_BE(n4);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
291 n5 = GUINT16_TO_BE(n5);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
292 n6 = GUINT32_TO_BE(n6);
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
293 memcpy(nonce + 0, &n1, sizeof(n1));
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
294 memcpy(nonce + 4, &n2, sizeof(n2));
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
295 memcpy(nonce + 6, &n3, sizeof(n3));
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
296 memcpy(nonce + 8, &n4, sizeof(n4));
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
297 memcpy(nonce + 10, &n5, sizeof(n5));
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34926
diff changeset
298 memcpy(nonce + 12, &n6, sizeof(n6));
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
299 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
300 /* Invalid nonce, so ignore request */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
301 g_free(nonce);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
302 nonce = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
303 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
304 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
305
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
306 return nonce;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
307 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
308
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
309 static void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
310 msn_slp_process_transresp(MsnSlpCall *slpcall, const char *content)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
311 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
312 /* A direct connection negotiation response */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
313 char *bridge;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
314 char *nonce;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
315 char *listening;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
316 MsnDirectConn *dc = slpcall->slplink->dc;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
317 MsnDirectConnNonceType ntype;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
318
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
319 purple_debug_info("msn", "process_transresp\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
320
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
321 /* Direct connections are disabled. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
322 if (!purple_account_get_bool(slpcall->slplink->session->account, "direct_connect", TRUE))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
323 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
324
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
325 g_return_if_fail(dc != NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
326 g_return_if_fail(dc->state == DC_STATE_CLOSED);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
327
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
328 bridge = get_token(content, "Bridge: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
329 nonce = parse_dc_nonce(content, &ntype);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
330 listening = get_token(content, "Listening: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
331 if (listening && bridge && !strcmp(bridge, "TCPv1")) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
332 /* Ok, the client supports direct TCP connection */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
333
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
334 /* We always need this. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
335 if (ntype == DC_NONCE_SHA1) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
336 strncpy(dc->remote_nonce, nonce, 36);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
337 dc->remote_nonce[36] = '\0';
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
338 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
339
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
340 if (!strcasecmp(listening, "false")) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
341 if (dc->listen_data != NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
342 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
343 * We'll listen for incoming connections but
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
344 * the listening socket isn't ready yet so we cannot
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
345 * send the INVITE packet now. Put the slpcall into waiting mode
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
346 * and let the callback send the invite.
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
347 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
348 slpcall->wait_for_socket = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
349
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
350 } else if (dc->listenfd != -1) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
351 /* The listening socket is ready. Send the INVITE here. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
352 msn_dc_send_invite(dc);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
353
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
354 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
355 /* We weren't able to create a listener either. Use SB. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
356 msn_dc_fallback_to_sb(dc);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
357 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
358
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
359 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
360 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
361 * We should connect to the client so parse
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
362 * IP/port from response.
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
363 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
364 char *ip, *port_str;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
365 int port = 0;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
366
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
367 if (ntype == DC_NONCE_PLAIN) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
368 /* Only needed for listening side. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
369 memcpy(dc->nonce, nonce, 16);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
370 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
371
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
372 /* Cancel any listen attempts because we don't need them. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
373 if (dc->listenfd_handle != 0) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
374 purple_input_remove(dc->listenfd_handle);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
375 dc->listenfd_handle = 0;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
376 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
377 if (dc->connect_timeout_handle != 0) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
378 purple_timeout_remove(dc->connect_timeout_handle);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
379 dc->connect_timeout_handle = 0;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
380 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
381 if (dc->listenfd != -1) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
382 purple_network_remove_port_mapping(dc->listenfd);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
383 close(dc->listenfd);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
384 dc->listenfd = -1;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
385 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
386 if (dc->listen_data != NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
387 purple_network_listen_cancel(dc->listen_data);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
388 dc->listen_data = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
389 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
390
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
391 /* Save external IP/port for later use. We'll try local connection first. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
392 dc->ext_ip = get_token(content, "IPv4External-Addrs: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
393 port_str = get_token(content, "IPv4External-Port: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
394 if (port_str) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
395 dc->ext_port = atoi(port_str);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
396 g_free(port_str);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
397 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
398
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
399 ip = get_token(content, "IPv4Internal-Addrs: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
400 port_str = get_token(content, "IPv4Internal-Port: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
401 if (port_str) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
402 port = atoi(port_str);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
403 g_free(port_str);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
404 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
405
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
406 if (ip && port) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
407 /* Try internal address first */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
408 dc->connect_data = purple_proxy_connect(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
409 NULL,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
410 slpcall->slplink->session->account,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
411 ip,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
412 port,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
413 msn_dc_connected_to_peer_cb,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
414 dc
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
415 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
416
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
417 if (dc->connect_data) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
418 /* Add connect timeout handle */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
419 dc->connect_timeout_handle = purple_timeout_add_seconds(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
420 DC_OUTGOING_TIMEOUT,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
421 msn_dc_outgoing_connection_timeout_cb,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
422 dc
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
423 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
424 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
425 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
426 * Connection failed
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
427 * Try external IP/port (if specified)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
428 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
429 msn_dc_outgoing_connection_timeout_cb(dc);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
430 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
431
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
432 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
433 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
434 * Omitted or invalid internal IP address / port
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
435 * Try external IP/port (if specified)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
436 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
437 msn_dc_outgoing_connection_timeout_cb(dc);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
438 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
439
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
440 g_free(ip);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
441 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
442
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
443 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
444 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
445 * Invalid direct connect invitation or
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
446 * TCP connection is not supported
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
447 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
448 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
449
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
450 g_free(listening);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
451 g_free(nonce);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
452 g_free(bridge);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
453
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
454 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
455 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
456
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
457 static void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
458 got_sessionreq(MsnSlpCall *slpcall, const char *branch,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
459 const char *euf_guid, const char *context)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
460 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
461 gboolean accepted = FALSE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
462
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
463 if (!strcmp(euf_guid, MSN_OBJ_GUID))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
464 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
465 /* Emoticon or UserDisplay */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
466 char *content;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
467 gsize len;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
468 MsnSlpLink *slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
469 MsnSlpMessage *slpmsg;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
470 MsnObject *obj;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
471 char *msnobj_data;
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
472 PurpleImage *img = NULL;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
473 int type;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
474
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
475 /* Send Ok */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
476 content = g_strdup_printf("SessionID: %lu\r\n\r\n",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
477 slpcall->session_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
478
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
479 msn_slp_send_ok(slpcall, branch, "application/x-msnmsgr-sessionreqbody",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
480 content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
481
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
482 g_free(content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
483
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
484 slplink = slpcall->slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
485
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
486 msnobj_data = (char *)purple_base64_decode(context, &len);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
487 obj = msn_object_new_from_string(msnobj_data);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
488 type = msn_object_get_type(obj);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
489 g_free(msnobj_data);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
490 if (type == MSN_OBJECT_EMOTICON) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
491 img = find_valid_emoticon(slplink->session->account, obj->location);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
492 } else if (type == MSN_OBJECT_USERTILE) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
493 img = msn_object_get_image(obj);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
494 if (img)
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
495 g_object_ref(img);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
496 }
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32244
diff changeset
497 msn_object_destroy(obj, FALSE);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
498
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
499 if (img != NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
500 /* DATA PREP */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
501 slpmsg = msn_slpmsg_dataprep_new(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
502 msn_slplink_queue_slpmsg(slplink, slpmsg);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
503
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
504 /* DATA */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
505 slpmsg = msn_slpmsg_obj_new(slpcall, img);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
506 msn_slplink_queue_slpmsg(slplink, slpmsg);
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35765
diff changeset
507 g_object_unref(img);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
508
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
509 accepted = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
510
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
511 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
512 purple_debug_error("msn", "Wrong object.\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
513 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
514 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
515
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
516 else if (!strcmp(euf_guid, MSN_FT_GUID))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
517 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
518 /* File Transfer */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
519 PurpleAccount *account;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
520 PurpleXfer *xfer;
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
521 MsnFileContext *file_context;
31249
b6c1a0a39131 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
522 char *buf;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
523 gsize bin_len;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
524 char *file_name;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
525
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
526 account = slpcall->slplink->session->account;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
527
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
528 slpcall->end_cb = msn_xfer_end_cb;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
529 slpcall->branch = g_strdup(branch);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
530
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
531 slpcall->pending = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
532
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
533 xfer = purple_xfer_new(account, PURPLE_XFER_TYPE_RECEIVE,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
534 slpcall->slplink->remote_user);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
535
31249
b6c1a0a39131 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
536 buf = (char *)purple_base64_decode(context, &bin_len);
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
537 file_context = msn_file_context_from_wire(buf, bin_len);
31249
b6c1a0a39131 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
538
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
539 if (file_context != NULL) {
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
540 file_name = g_convert((const gchar *)&file_context->file_name,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
541 MAX_FILE_NAME_LEN * 2,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
542 "UTF-8", "UTF-16LE",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
543 NULL, NULL, NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
544
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
545 purple_xfer_set_filename(xfer, file_name ? file_name : "");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
546 g_free(file_name);
32666
f3e71a830527 Update MSN for 64-bit file transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32658
diff changeset
547 purple_xfer_set_size(xfer, file_context->file_size);
34920
2df7191f56ea Removed IO ops from protocols
Ankit Vani <a@nevitus.org>
parents: 34914
diff changeset
548 purple_xfer_set_init_fnc(xfer, msn_xfer_init);
2df7191f56ea Removed IO ops from protocols
Ankit Vani <a@nevitus.org>
parents: 34914
diff changeset
549 purple_xfer_set_request_denied_fnc(xfer, msn_xfer_cancel);
2df7191f56ea Removed IO ops from protocols
Ankit Vani <a@nevitus.org>
parents: 34914
diff changeset
550 purple_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel);
2df7191f56ea Removed IO ops from protocols
Ankit Vani <a@nevitus.org>
parents: 34914
diff changeset
551 purple_xfer_set_read_fnc(xfer, msn_xfer_read);
2df7191f56ea Removed IO ops from protocols
Ankit Vani <a@nevitus.org>
parents: 34914
diff changeset
552 purple_xfer_set_write_fnc(xfer, msn_xfer_write);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
553
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
554 slpcall->u.incoming_data = g_byte_array_new();
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
555
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
556 slpcall->xfer = xfer;
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
557 g_object_ref(slpcall->xfer);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
558
32244
21305036245c Convert the msn prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31951
diff changeset
559 purple_xfer_set_protocol_data(xfer, slpcall);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
560
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
561 if (file_context->preview) {
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
562 purple_xfer_set_thumbnail(xfer, file_context->preview,
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
563 file_context->preview_len,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
564 "image/png");
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
565 g_free(file_context->preview);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
566 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
567
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
568 purple_xfer_request(xfer);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
569 }
31336
1a91c541c5c5 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31335
diff changeset
570 g_free(file_context);
31249
b6c1a0a39131 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
571 g_free(buf);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
572
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
573 accepted = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
574
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
575 } else if (!strcmp(euf_guid, MSN_CAM_REQUEST_GUID)) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
576 purple_debug_info("msn", "Cam request.\n");
31110
1ac159463a0d slpcall is never NULL here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31084
diff changeset
577 if (slpcall->slplink && slpcall->slplink->session) {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
578 PurpleIMConversation *im;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
579 gchar *from = slpcall->slplink->remote_user;
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
580 im = purple_conversations_find_im_with_account(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
581 from, slpcall->slplink->session->account);
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
582 if (im) {
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
583 char *buf;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
584 buf = g_strdup_printf(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
585 _("%s requests to view your "
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
586 "webcam, but this request is "
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
587 "not yet supported."), from);
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
588 purple_conversation_write(PURPLE_CONVERSATION(im), NULL, buf,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
589 PURPLE_MESSAGE_SYSTEM |
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
590 PURPLE_MESSAGE_NOTIFY,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
591 time(NULL));
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
592 g_free(buf);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
593 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
594 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
595
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
596 } else if (!strcmp(euf_guid, MSN_CAM_GUID)) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
597 purple_debug_info("msn", "Cam invite.\n");
31110
1ac159463a0d slpcall is never NULL here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31084
diff changeset
598 if (slpcall->slplink && slpcall->slplink->session) {
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
599 PurpleIMConversation *im;
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
600 gchar *from = slpcall->slplink->remote_user;
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
601 im = purple_conversations_find_im_with_account(
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
602 from, slpcall->slplink->session->account);
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
603 if (im) {
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
604 char *buf;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
605 buf = g_strdup_printf(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
606 _("%s invited you to view his/her webcam, but "
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
607 "this is not yet supported."), from);
34636
cfbdf3297c99 Refactored msn protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
608 purple_conversation_write(PURPLE_CONVERSATION(im), NULL, buf,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
609 PURPLE_MESSAGE_SYSTEM |
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
610 PURPLE_MESSAGE_NOTIFY,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
611 time(NULL));
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
612 g_free(buf);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
613 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
614 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
615
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
616 } else
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
617 purple_debug_warning("msn", "SLP SessionReq with unknown EUF-GUID: %s\n", euf_guid);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
618
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
619 if (!accepted) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
620 char *content = g_strdup_printf("SessionID: %lu\r\n\r\n",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
621 slpcall->session_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
622 msn_slp_send_decline(slpcall, branch, "application/x-msnmsgr-sessionreqbody", content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
623 g_free(content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
624 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
625 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
626
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
627 void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
628 send_bye(MsnSlpCall *slpcall, const char *type)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
629 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
630 MsnSlpLink *slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
631 PurpleAccount *account;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
632 MsnSlpMessage *slpmsg;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
633 char *header;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
634
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
635 slplink = slpcall->slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
636
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
637 g_return_if_fail(slplink != NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
638
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
639 account = slplink->session->account;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
640
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
641 header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
642 purple_account_get_username(account));
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
643
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
644 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
645 "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
646 type,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
647 "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
648 g_free(header);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
649
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
650 slpmsg->info = "SLP BYE";
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
651 slpmsg->text_body = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
652
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
653 msn_slplink_queue_slpmsg(slplink, slpmsg);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
654 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
655
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
656 static void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
657 got_invite(MsnSlpCall *slpcall,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
658 const char *branch, const char *type, const char *content)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
659 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
660 MsnSlpLink *slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
661
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
662 slplink = slpcall->slplink;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
663
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
664 if (!strcmp(type, "application/x-msnmsgr-sessionreqbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
665 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
666 char *euf_guid, *context;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
667 char *temp;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
668
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
669 euf_guid = get_token(content, "EUF-GUID: {", "}\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
670
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
671 temp = get_token(content, "SessionID: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
672 if (temp != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
673 slpcall->session_id = atoi(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
674 g_free(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
675
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
676 temp = get_token(content, "AppID: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
677 if (temp != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
678 slpcall->app_id = atoi(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
679 g_free(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
680
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
681 context = get_token(content, "Context: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
682
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
683 if (context != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
684 got_sessionreq(slpcall, branch, euf_guid, context);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
685
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
686 g_free(context);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
687 g_free(euf_guid);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
688 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
689 else if (!strcmp(type, "application/x-msnmsgr-transreqbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
690 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
691 /* A direct connection negotiation request */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
692 char *bridges;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
693 char *nonce;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
694 MsnDirectConnNonceType ntype;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
695
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
696 purple_debug_info("msn", "got_invite: transreqbody received\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
697
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
698 /* Direct connections may be disabled. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
699 if (!purple_account_get_bool(slplink->session->account, "direct_connect", TRUE)) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
700 msn_slp_send_ok(slpcall, branch,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
701 "application/x-msnmsgr-transrespbody",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
702 "Bridge: TCPv1\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
703 "Listening: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
704 "Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
705 "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
706 msn_slpcall_session_init(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
707
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
708 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
709 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
710
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
711 /* Don't do anything if we already have a direct connection */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
712 if (slplink->dc != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
713 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
714
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
715 bridges = get_token(content, "Bridges: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
716 nonce = parse_dc_nonce(content, &ntype);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
717 if (bridges && strstr(bridges, "TCPv1") != NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
718 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
719 * Ok, the client supports direct TCP connection
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
720 * Try to create a listening port
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
721 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
722 MsnDirectConn *dc;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
723
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
724 dc = msn_dc_new(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
725 if (ntype == DC_NONCE_PLAIN) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
726 /* There is only one nonce for plain auth. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
727 dc->nonce_type = ntype;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
728 memcpy(dc->nonce, nonce, 16);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
729 } else if (ntype == DC_NONCE_SHA1) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
730 /* Each side has a nonce in SHA1 auth. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
731 dc->nonce_type = ntype;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
732 strncpy(dc->remote_nonce, nonce, 36);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
733 dc->remote_nonce[36] = '\0';
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
734 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
735
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
736 dc->listen_data = purple_network_listen_range(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
737 0, 0,
32593
8fe5585c5397 Rename purple_network_listen_range_family() to purple_network_listen_range().
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
738 AF_UNSPEC,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
739 SOCK_STREAM,
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
740 TRUE,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
741 msn_dc_listen_socket_created_cb,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
742 dc
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
743 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
744
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
745 if (dc->listen_data == NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
746 /* Listen socket creation failed */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
747
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
748 purple_debug_info("msn", "got_invite: listening failed\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
749
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
750 if (dc->nonce_type != DC_NONCE_PLAIN)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
751 msn_slp_send_ok(slpcall, branch,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
752 "application/x-msnmsgr-transrespbody",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
753 "Bridge: TCPv1\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
754 "Listening: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
755 "Hashed-Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
756 "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
757 else
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
758 msn_slp_send_ok(slpcall, branch,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
759 "application/x-msnmsgr-transrespbody",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
760 "Bridge: TCPv1\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
761 "Listening: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
762 "Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
763 "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
764
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
765 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
766 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
767 * Listen socket created successfully.
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
768 * Don't send anything here because we don't know the parameters
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
769 * of the created socket yet. msn_dc_send_ok will be called from
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
770 * the callback function: dc_listen_socket_created_cb
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
771 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
772 purple_debug_info("msn", "got_invite: listening socket created\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
773
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
774 dc->send_connection_info_msg_cb = msn_dc_send_ok;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
775 slpcall->wait_for_socket = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
776 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
777
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
778 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
779 /*
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
780 * Invalid direct connect invitation or
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
781 * TCP connection is not supported.
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
782 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
783 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
784
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
785 g_free(nonce);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
786 g_free(bridges);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
787 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
788 else if (!strcmp(type, "application/x-msnmsgr-transrespbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
789 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
790 /* A direct connection negotiation response */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
791 msn_slp_process_transresp(slpcall, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
792 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
793 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
794
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
795 static void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
796 got_ok(MsnSlpCall *slpcall,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
797 const char *type, const char *content)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
798 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
799 g_return_if_fail(slpcall != NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
800 g_return_if_fail(type != NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
801
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
802 if (!strcmp(type, "application/x-msnmsgr-sessionreqbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
803 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
804 char *content;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
805 char *header;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
806 char *nonce = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
807 MsnSession *session = slpcall->slplink->session;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
808 MsnSlpMessage *msg;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
809 MsnDirectConn *dc;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
810 MsnUser *user;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
811
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
812 if (!purple_account_get_bool(session->account, "direct_connect", TRUE)) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
813 /* Don't attempt a direct connection if disabled. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
814 msn_slpcall_session_init(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
815 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
816 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
817
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
818 if (slpcall->slplink->dc != NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
819 /* If we already have an established direct connection
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
820 * then just start the transfer.
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
821 */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
822 msn_slpcall_session_init(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
823 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
824 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
825
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
826 user = msn_userlist_find_user(session->userlist,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
827 slpcall->slplink->remote_user);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
828 if (!user || !(user->clientid & 0xF0000000)) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
829 /* Just start a normal SB transfer. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
830 msn_slpcall_session_init(slpcall);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
831 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
832 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
833
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
834 /* Try direct file transfer by sending a second INVITE */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
835 dc = msn_dc_new(slpcall);
31136
643ef83b4c67 Fix a lot more leaks, some old, some new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31110
diff changeset
836 g_free(slpcall->branch);
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
837 slpcall->branch = rand_guid();
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
838
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
839 dc->listen_data = purple_network_listen_range(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
840 0, 0,
32593
8fe5585c5397 Rename purple_network_listen_range_family() to purple_network_listen_range().
Andrew Victor <andrew.victor@mxit.com>
parents: 32312
diff changeset
841 AF_UNSPEC,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
842 SOCK_STREAM,
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
843 TRUE,
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
844 msn_dc_listen_socket_created_cb,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
845 dc
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
846 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
847
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
848 header = g_strdup_printf(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
849 "INVITE MSNMSGR:%s MSNSLP/1.0",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
850 slpcall->slplink->remote_user
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
851 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
852
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
853 if (dc->nonce_type == DC_NONCE_SHA1)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
854 nonce = g_strdup_printf("Hashed-Nonce: {%s}\r\n", dc->nonce_hash);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
855
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
856 if (dc->listen_data == NULL) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
857 /* Listen socket creation failed */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
858 purple_debug_info("msn", "got_ok: listening failed\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
859
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
860 content = g_strdup_printf(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
861 "Bridges: TCPv1\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
862 "NetID: %u\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
863 "Conn-Type: IP-Restrict-NAT\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
864 "UPnPNat: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
865 "ICF: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
866 "%s"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
867 "\r\n",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
868
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
869 rand() % G_MAXUINT32,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
870 nonce ? nonce : ""
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
871 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
872
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
873 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
874 /* Listen socket created successfully. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
875 purple_debug_info("msn", "got_ok: listening socket created\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
876
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
877 content = g_strdup_printf(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
878 "Bridges: TCPv1\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
879 "NetID: 0\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
880 "Conn-Type: Direct-Connect\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
881 "UPnPNat: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
882 "ICF: false\r\n"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
883 "%s"
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
884 "\r\n",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
885
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
886 nonce ? nonce : ""
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
887 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
888 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
889
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
890 msg = msn_slpmsg_sip_new(
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
891 slpcall,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
892 0,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
893 header,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
894 slpcall->branch,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
895 "application/x-msnmsgr-transreqbody",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
896 content
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
897 );
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
898 msg->info = "DC INVITE";
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
899 msg->text_body = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
900 g_free(nonce);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
901 g_free(header);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
902 g_free(content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
903
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
904 msn_slplink_queue_slpmsg(slpcall->slplink, msg);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
905 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
906 else if (!strcmp(type, "application/x-msnmsgr-transreqbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
907 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
908 /* Do we get this? */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
909 purple_debug_info("msn", "OK with transreqbody\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
910 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
911 else if (!strcmp(type, "application/x-msnmsgr-transrespbody"))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
912 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
913 msn_slp_process_transresp(slpcall, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
914 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
915 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
916
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
917 static void
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
918 got_error(MsnSlpCall *slpcall,
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
919 const char *error, const char *type, const char *content)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
920 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
921 /* It's not valid. Kill this off. */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
922 purple_debug_error("msn", "Received non-OK result: %s\n",
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
923 error ? error : "Unknown");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
924
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
925 if (type && !strcmp(type, "application/x-msnmsgr-transreqbody")) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
926 MsnDirectConn *dc = slpcall->slplink->dc;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
927 if (dc) {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
928 msn_dc_fallback_to_sb(dc);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
929 return;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
930 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
931 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
932
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
933 slpcall->wasted = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
934 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
935
31036
7caf86cfde06 Remove this prototipe and make the function static since it is not exposed anymore.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31035
diff changeset
936 static MsnSlpCall *
31035
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
937 msn_slp_sip_recv(MsnSlpLink *slplink, const char *body)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
938 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
939 MsnSlpCall *slpcall;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
940
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
941 if (body == NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
942 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
943 purple_debug_warning("msn", "received bogus message\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
944 return NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
945 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
946
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
947 if (!strncmp(body, "INVITE", strlen("INVITE")))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
948 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
949 /* This is an INVITE request */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
950 char *branch;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
951 char *call_id;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
952 char *content;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
953 char *content_type;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
954
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
955 /* From: <msnmsgr:buddy@hotmail.com> */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
956 #if 0
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
957 slpcall->remote_user = get_token(body, "From: <msnmsgr:", ">\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
958 #endif
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
959
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
960 branch = get_token(body, ";branch={", "}");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
961
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
962 call_id = get_token(body, "Call-ID: {", "}");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
963
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
964 #if 0
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
965 long content_len = -1;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
966
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
967 temp = get_token(body, "Content-Length: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
968 if (temp != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
969 content_len = atoi(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
970 g_free(temp);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
971 #endif
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
972 content_type = get_token(body, "Content-Type: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
973
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
974 content = get_token(body, "\r\n\r\n", NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
975
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
976 slpcall = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
977 if (branch && call_id)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
978 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
979 slpcall = msn_slplink_find_slp_call(slplink, call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
980 if (slpcall)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
981 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
982 g_free(slpcall->branch);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
983 slpcall->branch = g_strdup(branch);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
984 got_invite(slpcall, branch, content_type, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
985 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
986 else if (content_type && content)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
987 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
988 slpcall = msn_slpcall_new(slplink);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
989 slpcall->id = g_strdup(call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
990 got_invite(slpcall, branch, content_type, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
991 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
992 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
993
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
994 g_free(call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
995 g_free(branch);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
996 g_free(content_type);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
997 g_free(content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
998 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
999 else if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 ")))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1000 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1001 /* This is a response */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1002 char *content;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1003 char *content_type;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1004 /* Make sure this is "OK" */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1005 const char *status = body + strlen("MSNSLP/1.0 ");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1006 char *call_id;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1007
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1008 call_id = get_token(body, "Call-ID: {", "}");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1009 slpcall = msn_slplink_find_slp_call(slplink, call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1010 g_free(call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1011
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1012 g_return_val_if_fail(slpcall != NULL, NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1013
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1014 content_type = get_token(body, "Content-Type: ", "\r\n");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1015
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1016 content = get_token(body, "\r\n\r\n", NULL);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1017
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1018 if (strncmp(status, "200 OK", 6))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1019 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1020 char *error = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1021 const char *c;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1022
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1023 /* Eww */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1024 if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) ||
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1025 (c = strchr(status, '\0')))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1026 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1027 size_t len = c - status;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1028 error = g_strndup(status, len);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1029 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1030
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1031 got_error(slpcall, error, content_type, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1032 g_free(error);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1033
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1034 } else {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1035 /* Everything's just dandy */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1036 got_ok(slpcall, content_type, content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1037 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1038
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1039 g_free(content_type);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1040 g_free(content);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1041 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1042 else if (!strncmp(body, "BYE", strlen("BYE")))
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1043 {
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1044 /* This is a BYE request */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1045 char *call_id;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1046
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1047 call_id = get_token(body, "Call-ID: {", "}");
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1048 slpcall = msn_slplink_find_slp_call(slplink, call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1049 g_free(call_id);
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1050
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1051 if (slpcall != NULL)
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1052 slpcall->wasted = TRUE;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1053
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1054 /* msn_slpcall_destroy(slpcall); */
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1055 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1056 else
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1057 slpcall = NULL;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1058
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1059 return slpcall;
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1060 }
0a5c16e16d12 Move slp parsing and answering code down the stack to SlpCall. This simplify a lot slp.c.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30980
diff changeset
1061
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1062 MsnSlpCall *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1063 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1064 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1065 MsnSlpCall *slpcall;
11164
4396374c0cd9 [gaim-migrate @ 13265]
Mark Doliner <markdoliner@pidgin.im>
parents: 10773
diff changeset
1066 const guchar *body;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1067 gsize body_len;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1068 guint32 session_id;
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1069 guint32 flags;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1070
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1071 slpcall = NULL;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1072 body = slpmsg->buffer;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1073 body_len = msn_p2p_info_get_offset(slpmsg->p2p_info);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
1074
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1075 session_id = msn_p2p_info_get_session_id(slpmsg->p2p_info);
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1076 flags = msn_p2p_info_get_flags(slpmsg->p2p_info);
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1077
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1078 if (flags == P2P_NO_FLAG || flags == P2P_WLM2009_COMP)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1079 {
11236
3dda2280d355 [gaim-migrate @ 13382]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11164
diff changeset
1080 char *body_str;
3dda2280d355 [gaim-migrate @ 13382]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11164
diff changeset
1081
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1082 if (session_id == 64)
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1083 {
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1084 /* This is for handwritten messages (Ink) */
28362
b579df23a255 So apparently, I messed up the name of this charset. But I wonder why it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28084
diff changeset
1085 GError *error = NULL;
28022
48a34ccabfb4 Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
1086 gsize bytes_read, bytes_written;
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1087
28023
1a16aa3ae741 Fix the warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28022
diff changeset
1088 body_str = g_convert((const gchar *)body, body_len / 2,
28084
969c46b96999 THis conversion specifier is incorrect.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28030
diff changeset
1089 "UTF-8", "UTF-16LE",
28022
48a34ccabfb4 Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
1090 &bytes_read, &bytes_written, &error);
48a34ccabfb4 Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
1091 body_len -= bytes_read + 2;
48a34ccabfb4 Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
1092 body += bytes_read + 2;
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1093 if (body_str == NULL
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1094 || body_len <= 0
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1095 || strstr(body_str, "image/gif") == NULL)
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1096 {
28030
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1097 if (error != NULL) {
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1098 purple_debug_error("msn",
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1099 "Unable to convert Ink header from UTF-16 to UTF-8: %s\n",
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1100 error->message);
28030
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1101 g_error_free(error);
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1102 }
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1103 else
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1104 purple_debug_error("msn",
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1105 "Received Ink in unknown format\n");
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1106 g_free(body_str);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1107 return NULL;
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1108 }
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1109 g_free(body_str);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1110
28023
1a16aa3ae741 Fix the warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28022
diff changeset
1111 body_str = g_convert((const gchar *)body, body_len / 2,
28362
b579df23a255 So apparently, I messed up the name of this charset. But I wonder why it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28084
diff changeset
1112 "UTF-8", "UTF-16LE",
28022
48a34ccabfb4 Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27691
diff changeset
1113 &bytes_read, &bytes_written, &error);
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1114 if (!body_str)
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1115 {
28030
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1116 if (error != NULL) {
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1117 purple_debug_error("msn",
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1118 "Unable to convert Ink body from UTF-16 to UTF-8: %s\n",
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1119 error->message);
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1120 g_error_free(error);
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1121 }
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1122 else
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1123 purple_debug_error("msn",
284f783cffb6 Don't leak the GError from g_convert.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28024
diff changeset
1124 "Received Ink in unknown format\n");
27569
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1125 return NULL;
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1126 }
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1127
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1128 msn_switchboard_show_ink(slpmsg->slplink->swboard,
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1129 slplink->remote_user,
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1130 body_str);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1131 }
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1132 else
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1133 {
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1134 body_str = g_strndup((const char *)body, body_len);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1135 slpcall = msn_slp_sip_recv(slplink, body_str);
7f08e35e35ac Add support for receiving handwritten (Ink) messages from MSN buddies.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25677
diff changeset
1136 }
11236
3dda2280d355 [gaim-migrate @ 13382]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11164
diff changeset
1137 g_free(body_str);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1138 }
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
1139 else if (msn_p2p_msg_is_data(slpmsg->p2p_info))
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1140 {
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1141 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, session_id);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1142
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1143 if (slpcall != NULL)
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
1144 {
25580
8e861bb5f740 Avoid canceling this timer twice
Mark Doliner <markdoliner@pidgin.im>
parents: 25443
diff changeset
1145 if (slpcall->timer) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1146 purple_timeout_remove(slpcall->timer);
25580
8e861bb5f740 Avoid canceling this timer twice
Mark Doliner <markdoliner@pidgin.im>
parents: 25443
diff changeset
1147 slpcall->timer = 0;
8e861bb5f740 Avoid canceling this timer twice
Mark Doliner <markdoliner@pidgin.im>
parents: 25443
diff changeset
1148 }
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
1149
28694
76761af122e8 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <darkrain42@pidgin.im>
parents: 28362
diff changeset
1150 if (slpcall->cb)
76761af122e8 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <darkrain42@pidgin.im>
parents: 28362
diff changeset
1151 slpcall->cb(slpcall, body, body_len);
10225
0dfea1bc8695 [gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents: 10000
diff changeset
1152 }
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1153 }
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
1154 else if (msn_p2p_info_is_ack(slpmsg->p2p_info))
25443
3bec19909b15 On MSN, don't print an "unknown" message for SLP acknowledgement messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25438
diff changeset
1155 {
3bec19909b15 On MSN, don't print an "unknown" message for SLP acknowledgement messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25438
diff changeset
1156 /* Acknowledgement of previous message. Don't do anything currently. */
3bec19909b15 On MSN, don't print an "unknown" message for SLP acknowledgement messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25438
diff changeset
1157 }
25438
3cb4cad30a77 Report a debug warning if a SLP MSG is not processed because it has unknown
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25436
diff changeset
1158 else
31074
a947992cbd5f Fix a warning about the size of the flags and avoi displaying trialing 0 that will not be used.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 31072
diff changeset
1159 purple_debug_warning("msn", "Unprocessed SLP message with flags 0x%04x\n",
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31336
diff changeset
1160 flags);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1161
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1162 return slpcall;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1163 }

mercurial