annotate libpurple/protocols/msn/slplink.c @ 30784:320c0852b5cc

Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
author masca@cpw.pidgin.im
date Tue, 08 Jun 2010 21:26:39 +0000
parents 23b7b1b817c8
children 545fa069c531
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file slplink.c MSNSLP Link support
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19654
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30736
diff changeset
24
30758
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 30742
diff changeset
25 #include "internal.h"
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30736
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30736
diff changeset
27
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "msn.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "slplink.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "switchboard.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "slp.h"
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
33 #include "p2p.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #ifdef MSN_DEBUG_SLP_FILES
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 static int m_sc = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 static int m_rc = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 debug_msg_to_file(MsnMessage *msg, gboolean send)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 char *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 char *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 char *pload;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 int c;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 gsize pload_size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 dir = send ? "send" : "recv";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 c = send ? m_sc++ : m_rc++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 tmp = g_strdup_printf("%s/msntest/%s/%03d", g_get_home_dir(), dir, c);
21116
a3dc160d7914 Patch from eperez to fix some debug code, Fixes #3524
Ka-Hing Cheung <khc@hxbc.us>
parents: 20945
diff changeset
51 pload = msn_message_gen_payload(msg, &pload_size);
a3dc160d7914 Patch from eperez to fix some debug code, Fixes #3524
Ka-Hing Cheung <khc@hxbc.us>
parents: 20945
diff changeset
52 if (!purple_util_write_data_to_file_absolute(tmp, pload, pload_size))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
26505
0c796a1950b7 Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25335
diff changeset
54 purple_debug_error("msn", "could not save debug file\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 * Main
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 **************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
23304
945bf99cb233 msn_slplink_new() is only used within slplink.c, so make it static and
Mark Doliner <mark@kingant.net>
parents: 22832
diff changeset
64 static MsnSlpLink *
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 msn_slplink_new(MsnSession *session, const char *username)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 g_return_val_if_fail(session != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 slplink = g_new0(MsnSlpLink, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
27483
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
73 if (purple_debug_is_verbose())
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
74 purple_debug_info("msn", "slplink_new: slplink(%p)\n", slplink);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 slplink->session = session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 slplink->slp_seq_id = rand() % 0xFFFFFF00 + 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 slplink->remote_user = g_strdup(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 slplink->slp_msg_queue = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 session->slplinks =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 g_list_append(session->slplinks, slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
29762
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
86 return msn_slplink_ref(slplink);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 msn_slplink_destroy(MsnSlpLink *slplink)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 MsnSession *session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
27483
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
94 if (purple_debug_is_verbose())
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
95 purple_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 g_return_if_fail(slplink != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
30114
3f7f469ee1d0 NULL-ify one more link on destroy that might lead to a crash.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30089
diff changeset
99 if (slplink->swboard != NULL) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
30114
3f7f469ee1d0 NULL-ify one more link on destroy that might lead to a crash.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30089
diff changeset
101 slplink->swboard = NULL;
3f7f469ee1d0 NULL-ify one more link on destroy that might lead to a crash.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30089
diff changeset
102 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
29762
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
104 if (slplink->refs > 1) {
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
105 slplink->refs--;
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
106 return;
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
107 }
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
108
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 session = slplink->session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
111 if (slplink->dc != NULL) {
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
112 slplink->dc->slplink = NULL;
30046
e471c1fb9c49 It's probably a good idea to free the direct connection when the slplink
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30036
diff changeset
113 msn_dc_destroy(slplink->dc);
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
114 slplink->dc = NULL;
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
115 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 while (slplink->slp_calls != NULL)
24398
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
118 msn_slpcall_destroy(slplink->slp_calls->data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
20945
4cd97da26150 Leak fix.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
120 g_queue_free(slplink->slp_msg_queue);
4cd97da26150 Leak fix.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
121
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 session->slplinks =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 g_list_remove(session->slplinks, slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
23677
331effbd1cc8 Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23626
diff changeset
125 g_free(slplink->remote_user);
331effbd1cc8 Re-arrange msn_slplink_destroy and msn_slp_call_destroy. Might help
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23626
diff changeset
126
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 g_free(slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 MsnSlpLink *
29762
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
131 msn_slplink_ref(MsnSlpLink *slplink)
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
132 {
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
133 g_return_val_if_fail(slplink != NULL, NULL);
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
134
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
135 slplink->refs++;
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
136 if (purple_debug_is_verbose())
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
137 purple_debug_info("msn", "slplink ref (%p)[%d]\n", slplink, slplink->refs);
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
138
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
139 return slplink;
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
140 }
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
141
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
142 void
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
143 msn_slplink_unref(MsnSlpLink *slplink)
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
144 {
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
145 g_return_if_fail(slplink != NULL);
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
146
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
147 slplink->refs--;
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
148 if (purple_debug_is_verbose())
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
149 purple_debug_info("msn", "slplink unref (%p)[%d]\n", slplink, slplink->refs);
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
150
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
151 if (slplink->refs == 0)
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
152 msn_slplink_destroy(slplink);
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
153 }
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
154
b0bc67f42027 Fix a possible use-after-free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29496
diff changeset
155 MsnSlpLink *
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 msn_session_find_slplink(MsnSession *session, const char *who)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 for (l = session->slplinks; l != NULL; l = l->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 slplink = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 if (!strcmp(slplink->remote_user, who))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 return slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 MsnSlpLink *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 msn_session_get_slplink(MsnSession *session, const char *username)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 g_return_val_if_fail(session != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 g_return_val_if_fail(username != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 slplink = msn_session_find_slplink(session, username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 if (slplink == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 slplink = msn_slplink_new(session, username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 return slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 msn_slplink_add_slpcall(MsnSlpLink *slplink, MsnSlpCall *slpcall)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 if (slplink->swboard != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 slplink->swboard->flag |= MSN_SB_FLAG_FT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 slplink->slp_calls = g_list_append(slplink->slp_calls, slpcall);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
196
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
197 /*
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
198 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED)
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
199 msn_dc_ref(slplink->dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
200 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 msn_slplink_remove_slpcall(MsnSlpLink *slplink, MsnSlpCall *slpcall)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
206 /*
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
207 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED)
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
208 msn_dc_unref(slplink->dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
209 */
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
210
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 slplink->slp_calls = g_list_remove(slplink->slp_calls, slpcall);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
24395
9b253ce969d0 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <mark@kingant.net>
parents: 24393
diff changeset
213 /* The slplink has no slpcalls in it, release it from MSN_SB_FLAG_FT.
9b253ce969d0 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <mark@kingant.net>
parents: 24393
diff changeset
214 * If nothing else is using it then this might cause swboard to be
9b253ce969d0 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <mark@kingant.net>
parents: 24393
diff changeset
215 * destroyed. */
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
216 if (slplink->slp_calls == NULL && slplink->swboard != NULL) {
30129
a83167dd305c And another one just like 94fa017925fa206fc36f520ee42c54f57429b4e1. But
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30124
diff changeset
217 slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
24395
9b253ce969d0 msn_slplink_remove_slpcall() shouldn't be responsible for setting
Mark Doliner <mark@kingant.net>
parents: 24393
diff changeset
218 msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT);
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
219 slplink->swboard = NULL;
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
220 }
30057
7a82bc59b63f Close the DC when the slplink is empty.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30046
diff changeset
221
7a82bc59b63f Close the DC when the slplink is empty.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30046
diff changeset
222 /* The slplink has no slpcalls in it, release it from the DC. */
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
223 if (slplink->slp_calls == NULL && slplink->dc != NULL) {
30124
bc9f74e9f596 And another one of those reverse links. We don't want dc to automatically
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30114
diff changeset
224 slplink->dc->slplink = NULL;
30057
7a82bc59b63f Close the DC when the slplink is empty.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30046
diff changeset
225 msn_dc_destroy(slplink->dc);
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
226 slplink->dc = NULL;
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30077
diff changeset
227 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 MsnSlpCall *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 msn_slplink_find_slp_call(MsnSlpLink *slplink, const char *id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 MsnSlpCall *slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 if (!id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 for (l = slplink->slp_calls; l != NULL; l = l->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 slpcall = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 if (slpcall->id && !strcmp(slpcall->id, id))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 return slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 MsnSlpCall *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 msn_slplink_find_slp_call_with_session_id(MsnSlpLink *slplink, long id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 MsnSlpCall *slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 for (l = slplink->slp_calls; l != NULL; l = l->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 slpcall = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 if (slpcall->session_id == id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 return slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
30077
11e748b759a2 This is supposed to go along with the queue sending stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30068
diff changeset
267 void
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 {
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
270 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
272 msn_dc_enqueue_msg(slplink->dc, msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 if (slplink->swboard == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 slplink->swboard = msn_session_get_swboard(slplink->session,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 slplink->remote_user, MSN_SB_FLAG_FT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
24391
d402644d0f98 slplink->swboard will only be null if slplink->session is null. This
Mark Doliner <mark@kingant.net>
parents: 24390
diff changeset
281 g_return_if_fail(slplink->swboard != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 /* If swboard is destroyed we will be too */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 msn_switchboard_send_msg(slplink->swboard, msg, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
291 void
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 MsnMessage *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 long long real_size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 size_t len = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 /* Maybe we will want to create a new msg for this slpmsg instead of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 * reusing the same one all the time. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 msg = slpmsg->msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
302 real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 if (slpmsg->offset < real_size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 {
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
306 if (slpmsg->slpcall && slpmsg->slpcall->xfer && purple_xfer_get_type(slpmsg->slpcall->xfer) == PURPLE_XFER_SEND &&
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
307 purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED)
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
308 {
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
309 len = MIN(1202, slpmsg->slpcall->u.outgoing.len);
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
310 msn_message_set_bin_data(msg, slpmsg->slpcall->u.outgoing.data, len);
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
311 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 len = slpmsg->size - slpmsg->offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 if (len > 1202)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 len = 1202;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 msn_message_set_bin_data(msg, slpmsg->buffer + slpmsg->offset, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
322 slpmsg->header->offset = slpmsg->offset;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
323 slpmsg->header->length = len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
27483
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
326 if (purple_debug_is_verbose())
3dcc42d3cc12 Apparently, I missed a few changes for purple_debug_is_verbose().
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27137
diff changeset
327 msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 #ifdef MSN_DEBUG_SLP_FILES
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 debug_msg_to_file(msg, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 slpmsg->msgs =
30089
287fc4ac2bd9 Add and remove an extra ref per MsnMessage when saving it in a slpmsg, to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
334 g_list_append(slpmsg->msgs, msn_message_ref(msg));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 msn_slplink_send_msg(slplink, msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
337 if ((slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
338 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
339 slpmsg->flags == P2P_FILE_DATA) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 (slpmsg->slpcall != NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 slpmsg->slpcall->progress = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 if (slpmsg->slpcall->progress_cb != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 len, slpmsg->offset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 /* slpmsg->offset += len; */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
354 /* We have received the message ack */
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
355 static void
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
356 msg_ack(MsnMessage *msg, void *data)
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
357 {
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
358 MsnSlpMessage *slpmsg;
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
359 long long real_size;
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
360
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
361 slpmsg = data;
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
362
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
363 real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
364
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
365 slpmsg->offset += msg->slpmsg->header->length;
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
366
29496
a0adf0bb19b7 Re-order msg_ack, since purple_xfer_prpl_ready might cancel the transfer
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
367 slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
a0adf0bb19b7 Re-order msg_ack, since purple_xfer_prpl_ready might cancel the transfer
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
368
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
369 if (slpmsg->offset < real_size)
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
370 {
28695
ff5d8b8de895 Fix sending an MSN file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28693
diff changeset
371 if (slpmsg->slpcall->xfer && purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED)
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
372 {
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
373 slpmsg->slpcall->xfer_msg = slpmsg;
29896
cb9afb16cc3d Fix MSN FT for UIs that use our abstract FT stuff in ways that are slightly
hanzz@soc.pidgin.im
parents: 29835
diff changeset
374 msn_message_ref(msg);
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
375 purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
376 }
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
377 else
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
378 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
379 }
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
380 else
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
381 {
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
382 /* The whole message has been sent */
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
383 if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
384 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
385 slpmsg->flags == P2P_FILE_DATA)
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
386 {
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
387 if (slpmsg->slpcall != NULL)
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
388 {
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
389 if (slpmsg->slpcall->cb)
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
390 slpmsg->slpcall->cb(slpmsg->slpcall,
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
391 NULL, 0);
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
392 }
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
393 }
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
394 }
30089
287fc4ac2bd9 Add and remove an extra ref per MsnMessage when saving it in a slpmsg, to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
395
287fc4ac2bd9 Add and remove an extra ref per MsnMessage when saving it in a slpmsg, to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
396 msn_message_unref(msg);
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
397 }
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
398
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
399 /* We have received the message nak. */
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
400 static void
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
401 msg_nak(MsnMessage *msg, void *data)
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
402 {
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
403 MsnSlpMessage *slpmsg;
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
404
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
405 slpmsg = data;
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
406
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
407 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
408
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
409 slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
30089
287fc4ac2bd9 Add and remove an extra ref per MsnMessage when saving it in a slpmsg, to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
410 msn_message_unref(msg);
24393
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
411 }
70e662ef2412 Move msn_slplink_send_msgpart() that it doesn't need a forward declaration
Mark Doliner <mark@kingant.net>
parents: 24391
diff changeset
412
24403
89cb1c13036e Make another function static
Mark Doliner <mark@kingant.net>
parents: 24402
diff changeset
413 static void
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 msn_slplink_release_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 MsnMessage *msg;
29916
94c380160595 Normalize the remote passport before sending a P2P message. If it's not
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29896
diff changeset
417 const char *passport;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 slpmsg->msg = msg = msn_message_new_msnslp();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
421 msg->slpmsg = slpmsg;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
422 msg->slpmsg->header = g_new0(MsnP2PHeader, 1);
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
423 msg->slpmsg->footer = g_new0(MsnP2PFooter, 1);
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
424
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
425 if (slpmsg->flags == P2P_NO_FLAG)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 {
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
427 msg->slpmsg->header->session_id = slpmsg->session_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
428 msg->slpmsg->header->ack_id = rand() % 0xFFFFFF00;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 }
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
430 else if (slpmsg->flags == P2P_ACK)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 {
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
432 msg->slpmsg->header->session_id = slpmsg->session_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
433 msg->slpmsg->header->ack_id = slpmsg->ack_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
434 msg->slpmsg->header->ack_size = slpmsg->ack_size;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
435 msg->slpmsg->header->ack_sub_id = slpmsg->ack_sub_id;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 }
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
437 else if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
438 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
439 slpmsg->flags == P2P_FILE_DATA)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 {
23626
96e78c0fa32b Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23510
diff changeset
441 MsnSlpCall *slpcall;
96e78c0fa32b Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23510
diff changeset
442 slpcall = slpmsg->slpcall;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443
23626
96e78c0fa32b Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23510
diff changeset
444 g_return_if_fail(slpcall != NULL);
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
445 msg->slpmsg->header->session_id = slpcall->session_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
446 msg->slpmsg->footer->value = slpcall->app_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
447 msg->slpmsg->header->ack_id = rand() % 0xFFFFFF00;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 else if (slpmsg->flags == 0x100)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 {
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
451 msg->slpmsg->header->ack_id = slpmsg->ack_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
452 msg->slpmsg->header->ack_sub_id = slpmsg->ack_sub_id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
453 msg->slpmsg->header->ack_size = slpmsg->ack_size;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
456 msg->slpmsg->header->id = slpmsg->id;
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
457 msg->slpmsg->header->flags = (guint32)slpmsg->flags;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
30784
320c0852b5cc Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
masca@cpw.pidgin.im
parents: 30779
diff changeset
459 msg->slpmsg->header->total_size = slpmsg->size;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460
29916
94c380160595 Normalize the remote passport before sending a P2P message. If it's not
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29896
diff changeset
461 passport = purple_normalize(slplink->session->account, slplink->remote_user);
30735
66e7fe9f7810 propagate from branch 'im.pidgin.pidgin' (head cd770a44f05f96d1e74ea761e614d1a468ba60df)
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30730 30077
diff changeset
462 msn_message_set_header(msg, "P2P-Dest", passport);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 msg->ack_cb = msg_ack;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 msg->nak_cb = msg_nak;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 msg->ack_data = slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 msn_slplink_send_msgpart(slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 msn_message_destroy(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 msn_slplink_queue_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 {
25329
36897ddd3e08 This should prevent the crash in #8109 by stopping an invalid message from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24403
diff changeset
476 g_return_if_fail(slpmsg != NULL);
36897ddd3e08 This should prevent the crash in #8109 by stopping an invalid message from
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24403
diff changeset
477
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 slpmsg->id = slplink->slp_seq_id++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479
24402
b9e09053e53a This doesn't matter, but I think the metaphor tends to be that you push
Mark Doliner <mark@kingant.net>
parents: 24401
diff changeset
480 g_queue_push_tail(slplink->slp_msg_queue, slpmsg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 msn_slplink_send_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 slpmsg->id = slplink->slp_seq_id++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 msn_slplink_release_slpmsg(slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 void
24401
bceefbae1ca6 Reame msn_slplink_unleash to msn_slplink_send_queued_slpmsgs, which I
Mark Doliner <mark@kingant.net>
parents: 24398
diff changeset
492 msn_slplink_send_queued_slpmsgs(MsnSlpLink *slplink)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
24401
bceefbae1ca6 Reame msn_slplink_unleash to msn_slplink_send_queued_slpmsgs, which I
Mark Doliner <mark@kingant.net>
parents: 24398
diff changeset
496 /* Send the queued msgs in the order they were created */
24402
b9e09053e53a This doesn't matter, but I think the metaphor tends to be that you push
Mark Doliner <mark@kingant.net>
parents: 24401
diff changeset
497 while ((slpmsg = g_queue_pop_head(slplink->slp_msg_queue)) != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 msn_slplink_release_slpmsg(slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
503 static MsnSlpMessage *
30767
e5e712cf9f7e Drop Binary from the struct name.
masca@cpw.pidgin.im
parents: 30765
diff changeset
504 msn_slplink_create_ack(MsnSlpLink *slplink, MsnP2PHeader *header)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 slpmsg = msn_slpmsg_new(slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
510 slpmsg->session_id = header->session_id;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
511 slpmsg->size = header->total_size;
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
512 slpmsg->flags = P2P_ACK;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
513 slpmsg->ack_id = header->id;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
514 slpmsg->ack_sub_id = header->ack_id;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
515 slpmsg->ack_size = header->total_size;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 slpmsg->info = "SLP ACK";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
518 return slpmsg;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
519 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
520
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
521 static void
30767
e5e712cf9f7e Drop Binary from the struct name.
masca@cpw.pidgin.im
parents: 30765
diff changeset
522 msn_slplink_send_ack(MsnSlpLink *slplink, MsnP2PHeader *header)
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
523 {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
524 MsnSlpMessage *slpmsg = msn_slplink_create_ack(slplink, header);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
525
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 msn_slplink_send_slpmsg(slplink, slpmsg);
27939
4200554dd0fc Patch written by Mark Doliner and Paul Aurich to fix a remote crash on MSN
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27887
diff changeset
527 msn_slpmsg_destroy(slpmsg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 static void
23626
96e78c0fa32b Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23510
diff changeset
531 send_file_cb(MsnSlpCall *slpcall)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 MsnSlpMessage *slpmsg;
17054
21830d70709b Patch from sourceforge tracker 1652005 from wabz to fix displaying file
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
534 PurpleXfer *xfer;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535
28795
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
536 xfer = (PurpleXfer *)slpcall->xfer;
30068
dbe96260108c It seems like aMSN can get a bit stuck when using multiple file transfers,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30061
diff changeset
537 if (purple_xfer_get_status(xfer) >= PURPLE_XFER_STATUS_STARTED)
dbe96260108c It seems like aMSN can get a bit stuck when using multiple file transfers,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30061
diff changeset
538 return;
dbe96260108c It seems like aMSN can get a bit stuck when using multiple file transfers,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30061
diff changeset
539
28795
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
540 purple_xfer_ref(xfer);
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
541 purple_xfer_start(xfer, -1, NULL, 0);
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
542 if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_STARTED) {
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
543 purple_xfer_unref(xfer);
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
544 return;
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
545 }
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
546 purple_xfer_unref(xfer);
bffe098efca2 Calling purple_xfer_start may actually cancel the transfer (if the file
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28794
diff changeset
547
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 slpmsg = msn_slpmsg_new(slpcall->slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 slpmsg->slpcall = slpcall;
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
550 slpmsg->flags = P2P_FILE_DATA;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 slpmsg->info = "SLP FILE";
28793
fadc4a7ae32c I don't think there's any reason to stat this file instead of using the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28695
diff changeset
552 slpmsg->size = purple_xfer_get_size(xfer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556
24396
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
557 static MsnSlpMessage *
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
558 msn_slplink_message_find(MsnSlpLink *slplink, long session_id, long id)
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
559 {
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
560 GList *e;
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
561
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
562 for (e = slplink->slp_msgs; e != NULL; e = e->next)
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
563 {
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
564 MsnSlpMessage *slpmsg = e->data;
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
565
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
566 if ((slpmsg->session_id == session_id) && (slpmsg->id == id))
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
567 return slpmsg;
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
568 }
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
569
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
570 return NULL;
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
571 }
58fabce901e1 Make a few more functions static and remove a few declarations for
Mark Doliner <mark@kingant.net>
parents: 24395
diff changeset
572
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 void
30767
e5e712cf9f7e Drop Binary from the struct name.
masca@cpw.pidgin.im
parents: 30765
diff changeset
574 msn_slplink_process_msg(MsnSlpLink *slplink, MsnP2PHeader *header, const char *data, gsize len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 MsnSlpMessage *slpmsg;
25598
9931796e1765 *** Plucked rev 9dd1c4c3 (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25335
diff changeset
577 guint64 offset;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
579 if (header->total_size < header->length)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 {
30697
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
581 /* We seem to have received a bad header */
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
582 purple_debug_warning("msn", "Total size listed in SLP binary header "
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
583 "was less than length of this particular message. This "
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
584 "should not happen. Dropping message.\n");
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
585 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
588 offset = header->offset;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 if (offset == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 slpmsg = msn_slpmsg_new(slplink);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
593 slpmsg->id = header->id;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
594 slpmsg->session_id = header->session_id;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
595 slpmsg->size = header->total_size;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
596 slpmsg->flags = header->flags;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 if (slpmsg->session_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 {
30698
24f371e16a51 We just allocated slpmsg, so of course slpmsg->slpcall will be NULL here
Mark Doliner <mark@kingant.net>
parents: 30697
diff changeset
600 slpmsg->slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 if (slpmsg->slpcall != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 {
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
603 if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
604 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
605 slpmsg->flags == P2P_FILE_DATA)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 {
30697
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
607 PurpleXfer *xfer = slpmsg->slpcall->xfer;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 if (xfer != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 {
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
610 slpmsg->ft = TRUE;
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
611 slpmsg->slpcall->xfer_msg = slpmsg;
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
612
23662
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
613 purple_xfer_ref(xfer);
27874
6adbdd4b2963 ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents: 27751
diff changeset
614 purple_xfer_start(xfer, -1, NULL, 0);
23662
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
615
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
616 if (xfer->data == NULL) {
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
617 purple_xfer_unref(xfer);
27751
58f29c0286fe I don't understand how this branch could be reached, but don't leak the slp
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27483
diff changeset
618 msn_slpmsg_destroy(slpmsg);
58f29c0286fe I don't understand how this branch could be reached, but don't leak the slp
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27483
diff changeset
619 g_return_if_reached();
23662
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
620 } else {
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
621 purple_xfer_unref(xfer);
7b2fdeb078cd take an extra reference to PurpleXfer so we can check whether the whole
Ka-Hing Cheung <khc@hxbc.us>
parents: 23626
diff changeset
622 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 }
28693
6aea98f6a5cd Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28691
diff changeset
627 if (!slpmsg->ft && slpmsg->size)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 slpmsg->buffer = g_try_malloc(slpmsg->size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 if (slpmsg->buffer == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
632 purple_debug_error("msn", "Failed to allocate buffer for slpmsg\n");
25598
9931796e1765 *** Plucked rev 9dd1c4c3 (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents: 25335
diff changeset
633 msn_slpmsg_destroy(slpmsg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
640 slpmsg = msn_slplink_message_find(slplink, header->session_id, header->id);
27887
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
641 if (slpmsg == NULL)
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
642 {
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
643 /* Probably the transfer was canceled */
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
644 purple_debug_error("msn", "Couldn't find slpmsg\n");
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
645 return;
de7f6fd04298 Move this check inside the else condition. The other half of the if
Mark Doliner <mark@kingant.net>
parents: 27874
diff changeset
646 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648
28693
6aea98f6a5cd Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28691
diff changeset
649 if (slpmsg->ft)
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
650 {
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
651 slpmsg->slpcall->u.incoming_data =
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
652 g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)data, len);
30697
f3d2a46a5ea8 Attempt to simplify and clean
Mark Doliner <mark@kingant.net>
parents: 30694
diff changeset
653 purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
654 }
27939
4200554dd0fc Patch written by Mark Doliner and Paul Aurich to fix a remote crash on MSN
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27887
diff changeset
655 else if (slpmsg->size && slpmsg->buffer)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 {
29072
69077f3993f6 Fix CVE-2010-0277, a possible remote crash when parsing an incoming
Mark Doliner <mark@kingant.net>
parents: 28839
diff changeset
657 if (G_MAXSIZE - len < offset || (offset + len) > slpmsg->size || slpmsg->offset != offset)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 {
22822
05cb3f04c01e This cleans up a bunch of warnings that stem from the fact that size_t and
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22568
diff changeset
659 purple_debug_error("msn",
26925
e45fe73b47e3 Fix two warnings when building on OS X
Paul Aurich <paul@darkrain42.org>
parents: 26862
diff changeset
660 "Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n",
22822
05cb3f04c01e This cleans up a bunch of warnings that stem from the fact that size_t and
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22568
diff changeset
661 slpmsg->size, offset, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 g_return_if_reached();
29072
69077f3993f6 Fix CVE-2010-0277, a possible remote crash when parsing an incoming
Mark Doliner <mark@kingant.net>
parents: 28839
diff changeset
663 } else {
69077f3993f6 Fix CVE-2010-0277, a possible remote crash when parsing an incoming
Mark Doliner <mark@kingant.net>
parents: 28839
diff changeset
664 memcpy(slpmsg->buffer + offset, data, len);
69077f3993f6 Fix CVE-2010-0277, a possible remote crash when parsing an incoming
Mark Doliner <mark@kingant.net>
parents: 28839
diff changeset
665 slpmsg->offset += len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
669 if ((slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
670 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
671 slpmsg->flags == P2P_FILE_DATA) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 (slpmsg->slpcall != NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 slpmsg->slpcall->progress = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 if (slpmsg->slpcall->progress_cb != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 len, offset);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 if (slpmsg->buffer == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
688 if (header->offset + header->length >= header->total_size)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 /* All the pieces of the slpmsg have been received */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 MsnSlpCall *slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 slpcall = msn_slp_process_msg(slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694
28797
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
695 if (slpcall == NULL) {
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
696 msn_slpmsg_destroy(slpmsg);
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
697 return;
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
698 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29496
diff changeset
700 purple_debug_info("msn", "msn_slplink_process_msg: slpmsg complete\n");
28797
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
701
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
702 if (/* !slpcall->wasted && */ slpmsg->flags == 0x100)
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
703 {
20431
67cda4e0dac8 Finish commenting out references to directconn that would never be called
Stu Tomlinson <stu@nosnilmot.com>
parents: 20426
diff changeset
704 #if 0
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
705 MsnDirectConn *directconn;
28797
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
706
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
707 directconn = slplink->directconn;
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
708 if (!directconn->acked)
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
709 msn_directconn_send_handshake(directconn);
20431
67cda4e0dac8 Finish commenting out references to directconn that would never be called
Stu Tomlinson <stu@nosnilmot.com>
parents: 20426
diff changeset
710 #endif
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
711 }
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
712 else if (slpmsg->flags == P2P_NO_FLAG || slpmsg->flags == P2P_WML2009_COMP ||
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
713 slpmsg->flags == P2P_MSN_OBJ_DATA ||
30776
432e3331f607 Fix logic error as pointed out by Elliot.
masca@cpw.pidgin.im
parents: 30767
diff changeset
714 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30760
diff changeset
715 slpmsg->flags == P2P_FILE_DATA)
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
716 {
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
717 /* Release all the messages and send the ACK */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
719 if (slpcall->wait_for_socket) {
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
720 /*
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
721 * Save ack for later because we have to send
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
722 * a 200 OK message to the previous direct connect
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
723 * invitation before ACK but the listening socket isn't
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
724 * created yet.
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
725 */
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
726 purple_debug_info("msn", "msn_slplink_process_msg: save ACK\n");
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
727
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
728 slpcall->slplink->dc->prev_ack = msn_slplink_create_ack(slplink, header);
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
729 } else if (!slpcall->wasted) {
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
730 purple_debug_info("msn", "msn_slplink_process_msg: send ACK\n");
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
731
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
732 msn_slplink_send_ack(slplink, header);
28797
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
733 msn_slplink_send_queued_slpmsgs(slplink);
dc7b50d09922 Don't sent an ACK to a SLP message if the SlpCall has been marked as wasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28795
diff changeset
734 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 msn_slpmsg_destroy(slpmsg);
28799
bcea7c92d3f1 Oops, don't break things for successfully receiving of a file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28798
diff changeset
738
30028
911ca152210c Remove old code that was commented out, but is really just not necessary.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
739 if (!slpcall->wait_for_socket && slpcall->wasted)
28799
bcea7c92d3f1 Oops, don't break things for successfully receiving of a file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28798
diff changeset
740 msn_slpcall_destroy(slpcall);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 static gchar *
28830
24b341ae63f7 msn: Use the PurpleXfer size if available.
Paul Aurich <paul@darkrain42.org>
parents: 28799
diff changeset
745 gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 gsize size = 0;
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
748 MsnFileContext *header;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 gchar *u8 = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 gchar *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 gunichar2 *uni = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 glong currentChar = 0;
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
753 glong len = 0;
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
754 const char *preview;
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
755 gsize preview_len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756
28839
932f16167621 I already removed the other g_stat, so I don't think this one is needed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28830
diff changeset
757 size = purple_xfer_get_size(xfer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758
29823
79bb2804a19e Set desired image formats for thumbnails as a parameter to
Marcus Lundblad <ml@update.uu.se>
parents: 29819
diff changeset
759 purple_xfer_prepare_thumbnail(xfer, "png");
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
760
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
761 if (!file_name) {
26862
c69a2e88fee3 Fix a signed-ness warning.
Paul Aurich <paul@darkrain42.org>
parents: 26778
diff changeset
762 gchar *basename = g_path_get_basename(file_path);
c69a2e88fee3 Fix a signed-ness warning.
Paul Aurich <paul@darkrain42.org>
parents: 26778
diff changeset
763 u8 = purple_utf8_try_convert(basename);
c69a2e88fee3 Fix a signed-ness warning.
Paul Aurich <paul@darkrain42.org>
parents: 26778
diff changeset
764 g_free(basename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 file_name = u8;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
768 uni = g_utf8_to_utf16(file_name, -1, NULL, &len, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
770 if (u8) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 g_free(u8);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 file_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 u8 = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775
29835
afc9cec164e4 Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29832
diff changeset
776 preview = purple_xfer_get_thumbnail(xfer, &preview_len);
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
777 header = g_malloc(sizeof(MsnFileContext) + preview_len);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
778
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
779 header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
780 header->version = GUINT32_TO_LE(2); /* V.3 contains additional unnecessary data */
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
781 header->file_size = GUINT64_TO_LE(size);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
782 if (preview)
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
783 header->type = GUINT32_TO_LE(0);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
784 else
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
785 header->type = GUINT32_TO_LE(1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
787 len = MIN(len, MAX_FILE_NAME_LEN);
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
788 for (currentChar = 0; currentChar < len; currentChar++) {
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
789 header->file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
29494
1a9977557dc9 I never liked randomly poking at offsets. Fortunately, I was able to find
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29072
diff changeset
790 }
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
791 memset(&header->file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
793 memset(&header->unknown1, 0, sizeof(header->unknown1));
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
794 header->unknown2 = GUINT32_TO_LE(0xffffffff);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
795 if (preview) {
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
796 memcpy(&header->preview, preview, preview_len);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
797 }
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
798 header->preview[preview_len] = '\0';
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 g_free(uni);
29815
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
801 ret = purple_base64_encode((const guchar *)header, sizeof(MsnFileContext) + preview_len);
3175b89c5156 Add support for recieving and sending MSN file transfer previews.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29495
diff changeset
802 g_free(header);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
807 msn_slplink_request_ft(MsnSlpLink *slplink, PurpleXfer *xfer)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 MsnSlpCall *slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 char *context;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 const char *fn;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 const char *fp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
814 fn = purple_xfer_get_filename(xfer);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
815 fp = purple_xfer_get_local_filename(xfer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 g_return_if_fail(slplink != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 g_return_if_fail(fp != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819
24398
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
820 slpcall = msn_slpcall_new(slplink);
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
821 msn_slpcall_init(slpcall, MSN_SLPCALL_DC);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 slpcall->session_init_cb = send_file_cb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 slpcall->end_cb = msn_xfer_end_cb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 slpcall->cb = msn_xfer_completed_cb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 slpcall->xfer = xfer;
17114
8ed7b2d32ad1 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 <evan.s@dreskin.net>
parents: 17113
diff changeset
827 purple_xfer_ref(slpcall->xfer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 slpcall->pending = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
831 purple_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
28691
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
832 purple_xfer_set_read_fnc(xfer, msn_xfer_read);
59b0c556f787 A quick and dirty hack to make MSN use the in-core code to perform FT.
Paul Aurich <paul@darkrain42.org>
parents: 27996
diff changeset
833 purple_xfer_set_write_fnc(xfer, msn_xfer_write);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 xfer->data = slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836
28830
24b341ae63f7 msn: Use the PurpleXfer size if available.
Paul Aurich <paul@darkrain42.org>
parents: 28799
diff changeset
837 context = gen_context(xfer, fn, fp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838
24398
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
839 msn_slpcall_invite(slpcall, MSN_FT_GUID, 2, context);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 g_free(context);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 msn_slplink_request_object(MsnSlpLink *slplink,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 const char *info,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 MsnSlpCb cb,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 MsnSlpEndCb end_cb,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 const MsnObject *obj)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 MsnSlpCall *slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 char *msnobj_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 char *msnobj_base64;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 g_return_if_fail(slplink != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 g_return_if_fail(obj != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 msnobj_data = msn_object_to_string(obj);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
859 msnobj_base64 = purple_base64_encode((const guchar *)msnobj_data, strlen(msnobj_data));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 g_free(msnobj_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861
24398
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
862 slpcall = msn_slpcall_new(slplink);
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
863 msn_slpcall_init(slpcall, MSN_SLPCALL_ANY);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 slpcall->data_info = g_strdup(info);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 slpcall->cb = cb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 slpcall->end_cb = end_cb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868
24398
b27908701f66 For some reason the slpmsg and slplink functions don't have underscores
Mark Doliner <mark@kingant.net>
parents: 24396
diff changeset
869 msn_slpcall_invite(slpcall, MSN_OBJ_GUID, 1, msnobj_base64);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 g_free(msnobj_base64);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 }