annotate libpurple/protocols/msn/slp.c @ 32422:92711688c245

Convert the msn prpl to use the new API.
author andrew.victor@mxit.com
date Fri, 26 Aug 2011 18:37:27 +0000
parents 462c19eb31d8
children 904686722499
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
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 msnslp.c MSNSLP support
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
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
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19591
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31173
diff changeset
24
31196
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 31180
diff changeset
25 #include "internal.h"
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31173
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 31173
diff changeset
27
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "slp.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "slpcall.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "slpmsg.h"
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
31 #include "msnutils.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "object.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "user.h"
31249
fcfe022982e4 This header is needed to know the max size of a part.
masca@cpw.pidgin.im
parents: 31248
diff changeset
35 #include "sbconn.h"
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
36 #include "directconn.h"
31200
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 31198
diff changeset
37 #include "p2p.h"
31270
eabeba9c823f Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents: 31269
diff changeset
38 #include "xfer.h"
22887
b65997110933 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20990
diff changeset
39
30501
ee423c6c71b6 Minor comment fix.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30499
diff changeset
40 /* seconds to delay between sending buddy icon requests to the server. */
24342
9bdaf273c0ff Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <mark@kingant.net>
parents: 24341
diff changeset
41 #define BUDDY_ICON_DELAY 20
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42
30749
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
43 typedef struct {
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
44 MsnSession *session;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
45 const char *remote_user;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
46 const char *sha1;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
47 } MsnFetchUserDisplayData;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 * SLP Control
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 **************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
53 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
54 msn_slp_send_ok(MsnSlpCall *slpcall, const char *branch,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 const char *type, const char *content)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 MsnSlpMessage *slpmsg;
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 slplink = slpcall->slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 /* 200 OK */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 slpmsg = msn_slpmsg_sip_new(slpcall, 1,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 "MSNSLP/1.0 200 OK",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 branch, type, content);
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 slpmsg->info = "SLP 200 OK";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 slpmsg->text_body = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 msn_slplink_queue_slpmsg(slplink, slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
30433
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
73 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 29893
diff changeset
74 msn_slp_send_decline(MsnSlpCall *slpcall, const char *branch,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 const char *type, const char *content)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 slplink = slpcall->slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 /* 603 Decline */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 slpmsg = msn_slpmsg_sip_new(slpcall, 1,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 "MSNSLP/1.0 603 Decline",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 branch, type, content);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 slpmsg->info = "SLP 603 Decline";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 slpmsg->text_body = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 msn_slplink_queue_slpmsg(slplink, slpmsg);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 * Msg Callbacks
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 **************************************************************************/
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 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 * Called on a timeout from end_user_display(). Frees a buddy icon window slow and dequeues the next
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 * buddy icon request if there is one.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 msn_release_buddy_icon_request_timeout(gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 MsnUserList *userlist = (MsnUserList *)data;
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23131
diff changeset
105
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 /* Free one window slot */
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23131
diff changeset
107 userlist->buddy_icon_window++;
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23131
diff changeset
108
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 /* Clear the tag for our former request timer */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 userlist->buddy_icon_request_timer = 0;
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23131
diff changeset
111
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 msn_release_buddy_icon_request(userlist);
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23131
diff changeset
113
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 }
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 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 got_user_display(MsnSlpCall *slpcall,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 const guchar *data, gsize size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 const char *info;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
122 PurpleAccount *account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 g_return_if_fail(slpcall != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 info = slpcall->data_info;
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26599
diff changeset
127 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26599
diff changeset
128 purple_debug_info("msn", "Got User Display: %s\n", slpcall->slplink->remote_user);
15374
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 account = slpcall->slplink->session->account;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
132 purple_buddy_icons_set_for_user(account, slpcall->slplink->remote_user,
30863
351d07aefb09 Kill off many dead assignments and any useless remaining variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30768
diff changeset
133 g_memdup(data, size), size, info);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 end_user_display(MsnSlpCall *slpcall, MsnSession *session)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 MsnUserList *userlist;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 g_return_if_fail(session != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26599
diff changeset
143 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26599
diff changeset
144 purple_debug_info("msn", "End User Display\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 userlist = session->userlist;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 /* If the session is being destroyed we better stop doing anything. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 if (session->destroying)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 /* Delay before freeing a buddy icon window slot and requesting the next icon, if appropriate.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 * If we don't delay, we'll rapidly hit the MSN equivalent of AIM's rate limiting; the server will
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 * send us an error 800 like so:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 * C: NS 000: XFR 21 SB
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 * S: NS 000: 800 21
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 if (userlist->buddy_icon_request_timer) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 /* Free the window slot used by this previous request */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 userlist->buddy_icon_window++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 /* Clear our pending timeout */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
164 purple_timeout_remove(userlist->buddy_icon_request_timer);
15374
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
24342
9bdaf273c0ff Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <mark@kingant.net>
parents: 24341
diff changeset
167 /* Wait BUDDY_ICON_DELAY s before freeing our window slot and requesting the next icon. */
9bdaf273c0ff Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <mark@kingant.net>
parents: 24341
diff changeset
168 userlist->buddy_icon_request_timer = purple_timeout_add_seconds(BUDDY_ICON_DELAY,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 msn_release_buddy_icon_request_timeout, userlist);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
23542
01c3074b2299 A patch from felipec to make (msn_)request_user_display static.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
172 static void
30749
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
173 fetched_user_display(PurpleUtilFetchUrlData *url_data, gpointer user_data,
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
174 const gchar *url_text, gsize len, const gchar *error_message)
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
175 {
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
176 MsnFetchUserDisplayData *data = user_data;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
177 MsnSession *session = data->session;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
178
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
179 session->url_datas = g_slist_remove(session->url_datas, url_data);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
180
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
181 if (url_text) {
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
182 purple_buddy_icons_set_for_user(session->account, data->remote_user,
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
183 g_memdup(url_text, len), len,
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
184 data->sha1);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
185 }
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
186
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
187 end_user_display(NULL, session);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
188
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
189 g_free(user_data);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
190 }
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
191
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
192 static void
31273
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
193 request_own_user_display(MsnUser *user)
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
194 {
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
195 PurpleAccount *account;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
196 MsnSession *session;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
197 MsnObject *my_obj = NULL;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
198 gconstpointer data = NULL;
31346
bc85e62fdb19 Fix possible uninitialized value.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31344
diff changeset
199 const char *info = NULL;
31273
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
200 size_t len = 0;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
201
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
202 if (purple_debug_is_verbose())
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
203 purple_debug_info("msn", "Requesting our own user display\n");
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
204
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
205 session = user->userlist->session;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
206 account = session->account;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
207 my_obj = msn_user_get_object(user);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
208
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
209 if (my_obj != NULL) {
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
210 PurpleStoredImage *img = msn_object_get_image(my_obj);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
211 data = purple_imgstore_get_data(img);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
212 len = purple_imgstore_get_size(img);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
213 info = msn_object_get_sha1(my_obj);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
214 }
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
215
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
216 purple_buddy_icons_set_for_user(account, user->passport, g_memdup(data, len), len, info);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
217
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
218 /* Free one window slot */
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
219 session->userlist->buddy_icon_window++;
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
220
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
221 if (purple_debug_is_verbose())
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
222 purple_debug_info("msn", "msn_request_user_display(): buddy_icon_window++ yields =%d\n",
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
223 session->userlist->buddy_icon_window);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
224
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
225 msn_release_buddy_icon_request(session->userlist);
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
226 }
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
227
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
228 void
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
229 msn_request_user_display(MsnUser *user)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
231 PurpleAccount *account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 MsnSession *session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 MsnObject *obj;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 const char *info;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 session = user->userlist->session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 account = session->account;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 slplink = msn_session_get_slplink(session, user->passport);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 obj = msn_user_get_object(user);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243
16031
7873f314fadf Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
244 info = msn_object_get_sha1(obj);
15374
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 if (g_ascii_strcasecmp(user->passport,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
247 purple_account_get_username(account)))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 {
30749
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
249 const char *url = msn_object_get_url1(obj);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
250 if (url) {
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
251 MsnFetchUserDisplayData *data = g_new0(MsnFetchUserDisplayData, 1);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
252 PurpleUtilFetchUrlData *url_data;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
253 data->session = session;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
254 data->remote_user = user->passport;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
255 data->sha1 = info;
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
256 url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, 200*1024,
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
257 fetched_user_display, data);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
258 session->url_datas = g_slist_prepend(session->url_datas, url_data);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
259 } else {
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
260 msn_slplink_request_object(slplink, info, got_user_display,
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
261 end_user_display, obj);
76049fde7ad2 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30546
diff changeset
262 }
15374
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 else
31273
56ef12440d52 Move queue logic in requesting user display out of slp code.
masca@cpw.pidgin.im
parents: 31271
diff changeset
265 request_own_user_display(user);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 }
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
267
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
268 static void
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
269 send_file_cb(MsnSlpCall *slpcall)
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
270 {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
271 MsnSlpMessage *slpmsg;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
272 PurpleXfer *xfer;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
273
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
274 xfer = (PurpleXfer *)slpcall->xfer;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
275 if (purple_xfer_get_status(xfer) >= PURPLE_XFER_STATUS_STARTED)
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
276 return;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
277
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
278 purple_xfer_ref(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
279 purple_xfer_start(xfer, -1, NULL, 0);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
280 if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_STARTED) {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
281 purple_xfer_unref(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
282 return;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
283 }
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
284 purple_xfer_unref(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
285
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
286 slpmsg = msn_slpmsg_file_new(slpcall, purple_xfer_get_size(xfer));
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
287
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
288 msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
289 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
291 static gchar *
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
292 gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
293 {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
294 gsize size = 0;
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
295 MsnFileContext context;
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
296 gchar *u8 = NULL;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
297 gchar *ret;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
298 gunichar2 *uni = NULL;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
299 glong currentChar = 0;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
300 glong len = 0;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
301 const char *preview;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
302 gsize preview_len;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
303
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
304 size = purple_xfer_get_size(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
305
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
306 purple_xfer_prepare_thumbnail(xfer, "png");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
308 if (!file_name) {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
309 gchar *basename = g_path_get_basename(file_path);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
310 u8 = purple_utf8_try_convert(basename);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
311 g_free(basename);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
312 file_name = u8;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
313 }
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
314
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
315 uni = g_utf8_to_utf16(file_name, -1, NULL, &len, NULL);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
316
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
317 if (u8) {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
318 g_free(u8);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
319 file_name = NULL;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
320 u8 = NULL;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
321 }
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
322
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
323 preview = purple_xfer_get_thumbnail(xfer, &preview_len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
325 context.length = MSN_FILE_CONTEXT_SIZE;
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
326 context.version = 2; /* V.3 contains additional unnecessary data */
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
327 context.file_size = size;
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
328 if (preview)
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
329 context.type = 0;
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
330 else
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
331 context.type = 1;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
333 len = MIN(len, MAX_FILE_NAME_LEN);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
334 for (currentChar = 0; currentChar < len; currentChar++) {
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
335 context.file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
336 }
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
337 memset(&context.file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
31493
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
338
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
339 memset(&context.unknown1, 0, sizeof(context.unknown1));
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
340 context.unknown2 = 0xffffffff;
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
341
31493
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
342 /* Mind the cast, as in, don't free it after! */
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
343 context.preview = (char *)preview;
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
344 context.preview_len = preview_len;
31493
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
345
31566
9ccbd0302bb2 Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31493
diff changeset
346 u8 = msn_file_context_to_wire(&context);
31493
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
347 ret = purple_base64_encode((const guchar *)u8, MSN_FILE_CONTEXT_SIZE + preview_len);
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
348
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
349 g_free(uni);
31493
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
350 g_free(u8);
b4064198e017 Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31346
diff changeset
351
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
352 return ret;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
353 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
355 void
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
356 msn_request_ft(PurpleXfer *xfer)
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
357 {
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
358 MsnSlpCall *slpcall;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
359 MsnSlpLink *slplink;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
360 char *context;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
361 const char *fn;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
362 const char *fp;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
363
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
364 fn = purple_xfer_get_filename(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
365 fp = purple_xfer_get_local_filename(xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
366
32422
92711688c245 Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents: 32194
diff changeset
367 slplink = purple_xfer_get_protocol_data(xfer);
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
368
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
369 g_return_if_fail(slplink != NULL);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
370 g_return_if_fail(fp != NULL);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
371
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
372 slpcall = msn_slpcall_new(slplink);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
373 msn_slpcall_init(slpcall, MSN_SLPCALL_DC);
23545
1061a9ad1ddb disapproval of revision '075bff91d9cbcfd6f59c270802c5bffeb98c3b50'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23544
diff changeset
374
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
375 slpcall->session_init_cb = send_file_cb;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
376 slpcall->end_cb = msn_xfer_end_cb;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
377 slpcall->cb = msn_xfer_completed_cb;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
378 slpcall->xfer = xfer;
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
379 purple_xfer_ref(slpcall->xfer);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
380
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
381 slpcall->pending = TRUE;
23545
1061a9ad1ddb disapproval of revision '075bff91d9cbcfd6f59c270802c5bffeb98c3b50'
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23544
diff changeset
382
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
383 purple_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
384 purple_xfer_set_read_fnc(xfer, msn_xfer_read);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
385 purple_xfer_set_write_fnc(xfer, msn_xfer_write);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
386
32422
92711688c245 Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents: 32194
diff changeset
387 purple_xfer_set_protocol_data(xfer, slpcall);
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
388
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
389 context = gen_context(xfer, fn, fp);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
390
31282
7b1b7a4e0bb4 Documetn P2P Application ID in a enum and use it instead of 'magic numbers'.
masca@cpw.pidgin.im
parents: 31273
diff changeset
391 msn_slpcall_invite(slpcall, MSN_FT_GUID, P2P_APPID_FILE, context);
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
392 msn_slplink_unref(slplink);
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
393
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
394 g_free(context);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 }
31269
210feb895031 Move file request up in the stack.
masca@cpw.pidgin.im
parents: 31265
diff changeset
396