libpurple/protocols/myspace/user.c

Fri, 09 Aug 2013 13:03:26 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Fri, 09 Aug 2013 13:03:26 +0200
changeset 34287
6cd0c77b1f6a
parent 34233
8bdcc4f84a5e
child 34304
faf0414a8b51
child 34878
41b9075c7714
permissions
-rw-r--r--

HTTP: successful is spelled with one l

19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
1 /* MySpaceIM Protocol Plugin, header file
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
2 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im>
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
4 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
5 * This program is free software; you can redistribute it and/or modify
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
6 * it under the terms of the GNU General Public License as published by
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
8 * (at your option) any later version.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
9 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
10 * This program is distributed in the hope that it will be useful,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
13 * GNU General Public License for more details.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
14 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
15 * You should have received a copy of the GNU General Public License
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
16 * along with this program; if not, write to the Free Software
20376
40eb7fd73b9a merge of 'f78451b4a2f7106eb8f8fa7275a7a29230593449'
Casey Harkins <charkins@pidgin.im>
parents: 19859 19795
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
18 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
19
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
20 #include "myspace.h"
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
21
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
22 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
23
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
24 static char *msim_username_to_set;
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
25
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
26 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
27 * Format the "now playing" indicator, showing the artist and song.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
28 *
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
29 * @return Return a new string (must be g_free()'d), or NULL.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
30 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
31 static gchar *
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
32 msim_format_now_playing(const gchar *band, const gchar *song)
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
33 {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
34 if ((band && *band) || (song && *song)) {
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
35 return g_strdup_printf("%s - %s",
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
36 (band && *band) ? band : "Unknown Artist",
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
37 (song && *song) ? song : "Unknown Song");
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
38 } else {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
39 return NULL;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
40 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
41 }
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
42
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
43 /**
25502
40f87522e2d0 propagate from branch 'im.pidgin.pidgin' (head db75fad3c5a74a5d380131b678995c6a78c140cb)
Paul Aurich <darkrain42@pidgin.im>
parents: 24867 25240
diff changeset
44 * Get the MsimUser from a PurpleBuddy, optionally creating it if needed.
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
45 */
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
46 MsimUser *
24867
69105eeaf010 The Add Buddy dialog should not blindly create a duplicate buddy in a group
Paul Aurich <darkrain42@pidgin.im>
parents: 23517
diff changeset
47 msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create)
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
48 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
49 MsimUser *user;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
50
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
51 if (!buddy) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
52 return NULL;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
53 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
54
26091
83f52ce0929f propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
parents: 25855 25508
diff changeset
55 user = purple_buddy_get_protocol_data(buddy);
83f52ce0929f propagate from branch 'im.pidgin.pidgin' (head b4bbfacd7f2050d87deeda12ea7bb3adc3608cb7)
Paul Aurich <darkrain42@pidgin.im>
parents: 25855 25508
diff changeset
56 if (create && !user) {
29666
28a05d95e20d A few struct hiding cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 27635
diff changeset
57 PurpleBlistNode *node = PURPLE_BLIST_NODE(buddy);
28a05d95e20d A few struct hiding cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 27635
diff changeset
58
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
59 /* No MsimUser for this buddy; make one. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
60
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
61 user = g_new0(MsimUser, 1);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
62 user->buddy = buddy;
29666
28a05d95e20d A few struct hiding cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 27635
diff changeset
63 user->id = purple_blist_node_get_int(node, "UserID");
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25116 24946
diff changeset
64 purple_buddy_set_protocol_data(buddy, user);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
65 }
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
66
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
67 return user;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
68 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
69
25324
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
70 void msim_user_free(MsimUser *user)
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
71 {
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
72 if (!user)
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
73 return;
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
74
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
75 purple_http_conn_cancel(user->http_conn);
25324
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
76 g_free(user->client_info);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
77 g_free(user->gender);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
78 g_free(user->location);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
79 g_free(user->headline);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
80 g_free(user->display_name);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
81 g_free(user->username);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
82 g_free(user->band_name);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
83 g_free(user->song_name);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
84 g_free(user->image_url);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
85 g_free(user);
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
86 }
9a07ddd8cc86 A couple of memory leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25302
diff changeset
87
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
88 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
89 * Find and return an MsimUser * representing a user on the buddy list, or NULL.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
90 */
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
91 MsimUser *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
92 msim_find_user(MsimSession *session, const gchar *username)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
93 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
94 PurpleBuddy *buddy;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
95
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
96 buddy = purple_find_buddy(session->account, username);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
97 if (!buddy) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
98 return NULL;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
99 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
100
29284
2ec96cd911b5 Simplify
Mark Doliner <markdoliner@pidgin.im>
parents: 29144
diff changeset
101 return msim_get_user_from_buddy(buddy, TRUE);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
102 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
103
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
104 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
105 * Append user information to a PurpleNotifyUserInfo, given an MsimUser.
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
106 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
107 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
108 void
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
109 msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
110 {
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
111 PurplePresence *presence;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
112 gchar *str;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
113 guint cv;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
114
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
115 /* Useful to identify the account the tooltip refers to.
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
116 * Other prpls show this. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
117 if (user->username) {
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
118 purple_notify_user_info_add_pair_plaintext(user_info, _("User"), user->username);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
119 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
120
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
121 /* a/s/l...the vitals */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
122 if (user->age) {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
123 char age[16];
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
124 g_snprintf(age, sizeof(age), "%d", user->age);
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
125 purple_notify_user_info_add_pair_plaintext(user_info, _("Age"), age);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
126 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
127
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
128 if (user->gender && *user->gender) {
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
129 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
130 or if we should be using add_pair_plaintext */
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
131 purple_notify_user_info_add_pair_plaintext(user_info, _("Gender"), user->gender);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
132 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
133
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
134 if (user->location && *user->location) {
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
135 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
136 or if we should be using add_pair_plaintext */
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
137 purple_notify_user_info_add_pair_plaintext(user_info, _("Location"), user->location);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
138 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
139
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
140 /* Other information */
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
141 if (user->headline && *user->headline) {
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
142 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
143 or if we should be using add_pair_plaintext */
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
144 purple_notify_user_info_add_pair_plaintext(user_info, _("Headline"), user->headline);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
145 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
146
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
147 if (user->buddy != NULL) {
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
148 presence = purple_buddy_get_presence(user->buddy);
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
149
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
150 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
151 PurpleStatus *status;
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
152 const char *artist, *title;
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
153
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
154 status = purple_presence_get_status(presence, "tune");
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
155 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
156 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
157
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
158 str = msim_format_now_playing(artist, title);
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
159 if (str && *str) {
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
160 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
161 or if we should be using add_pair_plaintext */
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
162 purple_notify_user_info_add_pair_plaintext(user_info, _("Song"), str);
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
163 }
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
164 g_free(str);
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
165 }
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
166 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
167
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
168 /* Note: total friends only available if looked up by uid, not username. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
169 if (user->total_friends) {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
170 char friends[16];
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
171 g_snprintf(friends, sizeof(friends), "%d", user->total_friends);
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
172 purple_notify_user_info_add_pair_plaintext(user_info, _("Total Friends"), friends);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
173 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
174
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
175 if (full) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
176 /* Client information */
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
177 char *client = NULL;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
178
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
179 str = user->client_info;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
180 cv = user->client_cv;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
181
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
182 if (str && cv != 0) {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
183 client = g_strdup_printf("%s (build %d)", str, cv);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
184 } else if (str) {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
185 client = g_strdup(str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
186 } else if (cv) {
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
187 client = g_strdup_printf("Build %d", cv);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
188 }
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
189 if (client && *client) {
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
190 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
191 or if we should be using add_pair_plaintext */
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
192 purple_notify_user_info_add_pair_plaintext(user_info, _("Client Version"), client);
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
193 }
20815
a6c11702ad56 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20404
diff changeset
194 g_free(client);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
195 }
25089
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
196
25116
cb60ad01e2e8 Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <markdoliner@pidgin.im>
parents: 25115
diff changeset
197 if (full && user->id) {
25089
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
198 /* TODO: link to username, if available */
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
199 char *profile;
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
200 purple_notify_user_info_add_section_break(user_info);
25193
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
201 if (user->buddy != NULL)
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
202 profile = g_strdup_printf("<a href=\"http://myspace.com/%s\">%s</a>",
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
203 purple_buddy_get_name(user->buddy), _("View web profile"));
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
204 else
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
205 profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>",
f98a278fd233 Use the friendly/vanity url when it's available in myspace
Mark Doliner <markdoliner@pidgin.im>
parents: 25116
diff changeset
206 user->id, _("View web profile"));
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32188
diff changeset
207 purple_notify_user_info_add_pair_html(user_info, NULL, profile);
25089
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
208 g_free(profile);
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
209 }
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
210 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
211
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
212 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
213 * Callback for when a buddy icon finished being downloaded.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
214 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
215 static void
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
216 msim_downloaded_buddy_icon(PurpleHttpConnection *http_conn,
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
217 PurpleHttpResponse *response, gpointer _user)
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
218 {
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
219 MsimUser *user = _user;
25847
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
220 const char *name = purple_buddy_get_name(user->buddy);
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
221 PurpleAccount *account;
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
222 const gchar *data;
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
223 size_t len;
29141
4096eace0197 Fix a crash when disconnecting with a pending buddy icon fetch request.
Mark Doliner <markdoliner@pidgin.im>
parents: 27635
diff changeset
224
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
225 g_assert(user->http_conn == http_conn);
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
226 user->http_conn = NULL;
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
227
34287
6cd0c77b1f6a HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34233
diff changeset
228 if (!purple_http_response_is_successful(response)) {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
229 purple_debug_info("msim_downloaded_buddy_icon",
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
230 "failed to download icon for %s",
25847
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
231 name);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
232 return;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
233 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
234
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
235 data = purple_http_response_get_data(response, &len);
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
236
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
237 purple_debug_info("msim_downloaded_buddy_icon",
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
238 "Downloaded %" G_GSIZE_FORMAT " bytes\n", len);
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
239
25847
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
240 account = purple_buddy_get_account(user->buddy);
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
241 purple_buddy_icons_set_for_user(account, name,
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
242 g_memdup(data, len), len,
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
243 /* Use URL itself as buddy icon "checksum" (TODO: ETag) */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
244 user->image_url); /* checksum */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
245 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
246
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
247 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
248 * Set the currently playing song artist and or title.
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
249 *
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
250 * @param user User associated with the now playing information.
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
251 *
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
252 * @param new_artist New artist to set, or NULL/empty to not change artist.
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
253 *
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
254 * @param new_title New title to set, or NULL/empty to not change title.
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
255 *
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
256 * If new_artist and new_title are NULL/empty, deactivate PURPLE_STATUS_TUNE.
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
257 *
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
258 * This function is useful because it lets you set the artist or title
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
259 * individually, which purple_prpl_got_user_status() doesn't do.
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
260 */
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
261 static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, const char *new_title)
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
262 {
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
263 PurplePresence *presence;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
264 PurpleAccount *account;
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
265 const char *prev_artist, *prev_title;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
266 const char *name;
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
267
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
268 if (user->buddy == NULL)
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
269 /* User not on buddy list so nothing to do */
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
270 return;
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
271
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
272 prev_artist = NULL;
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
273 prev_title = NULL;
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
274
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
275 if (new_artist && !*new_artist)
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
276 new_artist = NULL;
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
277 if (new_title && !*new_title)
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
278 new_title = NULL;
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
279
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
280 account = purple_buddy_get_account(user->buddy);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
281 name = purple_buddy_get_name(user->buddy);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
282
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
283 if (!new_artist && !new_title) {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
284 purple_prpl_got_user_status_deactive(account, name, "tune");
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
285 return;
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
286 }
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
287
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
288 presence = purple_buddy_get_presence(user->buddy);
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
289
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
290 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
291 PurpleStatus *status;
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
292
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
293 status = purple_presence_get_status(presence, "tune");
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
294 prev_title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
295 prev_artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
296 }
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
297
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
298 if (!new_artist)
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
299 new_artist = prev_artist;
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
300
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
301 if (!new_title)
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
302 new_title = prev_title;
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
303
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
304 purple_prpl_got_user_status(account, name, "tune",
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
305 PURPLE_TUNE_TITLE, new_title,
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
306 PURPLE_TUNE_ARTIST, new_artist,
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
307 NULL);
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
308 }
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
309
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
310 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
311 * Store a field of information about a buddy.
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
312 *
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
313 * @param key_str Key to store.
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
314 * @param value_str Value string, either user takes ownership of this string
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
315 * or it is freed if MsimUser doesn't store the string.
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
316 * @param user User to store data in. Existing data will be replaced.
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
317 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
318 static void
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
319 msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
320 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
321 const char *name = user->buddy ? purple_buddy_get_name(user->buddy) : NULL;
25847
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
322
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
323 if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
324 /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */
25116
cb60ad01e2e8 Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <markdoliner@pidgin.im>
parents: 25115
diff changeset
325 user->id = atol(value_str);
25240
c8093ec246f0 Fix a few small memleaks
Mark Doliner <markdoliner@pidgin.im>
parents: 25233
diff changeset
326 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
327 if (user->buddy)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
328 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
329 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, name);
25847
a1c8c5a23b6d explicit merge of '077b4d6fc595fc99f5c76572f1b5d2e0343b2563'
Richard Laager <rlaager@pidgin.im>
parents: 25197 25846
diff changeset
330 purple_blist_node_set_int(PURPLE_BLIST_NODE(user->buddy), "UserID", user->id);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
331 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
332 /* Need to store in MsimUser, too? What if not on blist? */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
333 } else if (g_str_equal(key_str, "Age")) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
334 user->age = atol(value_str);
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
335 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
336 } else if (g_str_equal(key_str, "Gender")) {
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
337 g_free(user->gender);
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
338 user->gender = value_str;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
339 } else if (g_str_equal(key_str, "Location")) {
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
340 g_free(user->location);
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
341 user->location = value_str;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
342 } else if (g_str_equal(key_str, "TotalFriends")) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
343 user->total_friends = atol(value_str);
25240
c8093ec246f0 Fix a few small memleaks
Mark Doliner <markdoliner@pidgin.im>
parents: 25233
diff changeset
344 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
345 } else if (g_str_equal(key_str, "DisplayName")) {
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
346 g_free(user->display_name);
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
347 user->display_name = value_str;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
348 } else if (g_str_equal(key_str, "BandName")) {
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
349 msim_set_artist_or_title(user, value_str, NULL);
25240
c8093ec246f0 Fix a few small memleaks
Mark Doliner <markdoliner@pidgin.im>
parents: 25233
diff changeset
350 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
351 } else if (g_str_equal(key_str, "SongName")) {
22358
13b8409aea48 In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 21098
diff changeset
352 msim_set_artist_or_title(user, NULL, value_str);
25240
c8093ec246f0 Fix a few small memleaks
Mark Doliner <markdoliner@pidgin.im>
parents: 25233
diff changeset
353 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
354 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
355 /* Ignore because PurpleBuddy knows this already */
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
356 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
357 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) {
21071
801334f9576b Fix a warning
Kevin Stange <kstange@pidgin.im>
parents: 21058
diff changeset
358 const gchar *previous_url;
801334f9576b Fix a warning
Kevin Stange <kstange@pidgin.im>
parents: 21058
diff changeset
359
21058
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
360 if (user->temporary_user) {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
361 /* This user will be destroyed soon; don't try to look up its image or avatar,
21058
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
362 * since that won't return immediately and we will end up accessing freed data.
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
363 */
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
364 g_free(value_str);
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
365 return;
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
366 }
21098
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
367
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
368 g_free(user->image_url);
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
369
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
370 user->image_url = value_str;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
371
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
372 /* Instead of showing 'no photo' picture, show nothing. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
373 if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif"))
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
374 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
375 purple_buddy_icons_set_for_user(purple_buddy_get_account(user->buddy),
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
376 name, NULL, 0, NULL);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
377 return;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
378 }
21098
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
379
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
380 /* TODO: use ETag for checksum */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
381 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
382
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
383 /* Only download if URL changed */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
384 if (!previous_url || !g_str_equal(previous_url, user->image_url)) {
34227
6d016a081401 HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33892
diff changeset
385 purple_http_conn_cancel(user->http_conn);
34233
8bdcc4f84a5e HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34227
diff changeset
386 user->http_conn = purple_http_get(NULL, msim_downloaded_buddy_icon, user, user->image_url);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
387 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
388 } else if (g_str_equal(key_str, "LastImageUpdated")) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
389 /* TODO: use somewhere */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
390 user->last_image_updated = atol(value_str);
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
391 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
392 } else if (g_str_equal(key_str, "Headline")) {
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
393 g_free(user->headline);
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
394 user->headline = value_str;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
395 } else {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
396 /* TODO: other fields in MsimUser */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
397 gchar *msg;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
398
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
399 msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s",
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
400 key_str, value_str);
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
401 g_free(value_str);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
402
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
403 msim_unrecognized(NULL, NULL, msg);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
404
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
405 g_free(msg);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
406 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
407 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
408
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
409 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
410 * Save buddy information to the buddy list from a user info reply message.
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
411 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
412 * @param session
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
413 * @param msg The user information reply, with any amount of information.
32326
3cf491d8cfce Replace the last raw references to "->proto_data".
Andrew Victor <andrew.victor@mxit.com>
parents: 32262
diff changeset
414 * @param user The structure to save to, or NULL to save in PurpleBuddy's protocol_data.
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
415 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
416 * Variable information is saved to the passed MsimUser structure. Permanent
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
417 * information (UserID) is stored in the blist node of the buddy list (and
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
418 * ends up in blist.xml, persisted to disk) if it exists.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
419 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
420 * If the function has no buddy information, this function
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
421 * is a no-op (and returns FALSE).
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
422 */
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
423 gboolean
25233
8a3fe5c4e2f4 Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25212
diff changeset
424 msim_store_user_info(MsimSession *session, const MsimMessage *msg, MsimUser *user)
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
425 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
426 gchar *username;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
427 MsimMessage *body, *body_node;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
428
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
429 g_return_val_if_fail(msg != NULL, FALSE);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
430
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
431 body = msim_msg_get_dictionary(msg, "body");
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
432 if (!body) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
433 return FALSE;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
434 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
435
25212
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
436 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN &&
25297
37cdf2a6d174 Fix a typo in a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 25240
diff changeset
437 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID)
37cdf2a6d174 Fix a typo in a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 25240
diff changeset
438 {
25212
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
439 /*
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
440 * Some of this info will be available on the buddy list if the
25297
37cdf2a6d174 Fix a typo in a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 25240
diff changeset
441 * user has themselves as their own buddy.
25212
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
442 *
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
443 * Much of the info is already available in MsimSession,
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
444 * stored in msim_we_are_logged_on().
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
445 */
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
446 gchar *tmpstr;
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
447
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
448 tmpstr = msim_msg_get_string(body, "ShowOnlyToList");
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
449 if (tmpstr != NULL) {
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
450 session->show_only_to_list = g_str_equal(tmpstr, "True");
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
451 g_free(tmpstr);
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
452 }
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
453
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
454 session->privacy_mode = msim_msg_get_integer(body, "PrivacyMode");
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
455 session->offline_message_mode = msim_msg_get_integer(body, "OfflineMessageMode");
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
456
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
457 msim_send(session,
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
458 "blocklist", MSIM_TYPE_BOOLEAN, TRUE,
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
459 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
460 "idlist", MSIM_TYPE_STRING,
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
461 g_strdup_printf("w%d|c%d",
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
462 session->show_only_to_list ? 1 : 0,
25302
c29df5c659cf This is a bitmask, and the "c" value here should be the least significant
Mark Doliner <markdoliner@pidgin.im>
parents: 25297
diff changeset
463 session->privacy_mode & 1),
25212
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
464 NULL);
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
465 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN &&
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
466 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) {
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
467 /* TODO: same as above, but for MySpace info. */
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
468 }
9b3b9168c9e1 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <markdoliner@pidgin.im>
parents: 25209
diff changeset
469
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
470 username = msim_msg_get_string(body, "UserName");
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
471
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
472 if (!username) {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
473 purple_debug_info("msim",
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
474 "msim_process_reply: not caching body, no UserName\n");
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
475 msim_msg_free(body);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
476 g_free(username);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
477 return FALSE;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
478 }
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
479
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
480 /* Null user = find and store in PurpleBuddy's proto_data */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
481 if (!user) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
482 user = msim_find_user(session, username);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
483 if (!user) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
484 msim_msg_free(body);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
485 g_free(username);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
486 return FALSE;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
487 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
488 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
489
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
490 /* TODO: make looping over MsimMessage's easier. */
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
491 for (body_node = body;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
492 body_node != NULL;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
493 body_node = msim_msg_get_next_element_node(body_node))
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
494 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
495 const gchar *key_str;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
496 gchar *value_str;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
497 MsimMessageElement *elem;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
498
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
499 elem = (MsimMessageElement *)body_node->data;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
500 key_str = elem->name;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
501
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
502 value_str = msim_msg_get_string_from_element(elem);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
503 msim_store_user_info_each(key_str, value_str, user);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
504 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
505
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
506 msim_msg_free(body);
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
507 g_free(username);
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
508
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
509 return TRUE;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
510 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
511
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
512 #if 0
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
513 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
514 * Return whether a given username is syntactically valid.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
515 * Note: does not actually check that the user exists.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
516 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
517 static gboolean
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
518 msim_is_valid_username(const gchar *user)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
519 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
520 return !msim_is_userid(user) && /* Not all numeric */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
521 strlen(user) <= MSIM_MAX_USERNAME_LENGTH
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
522 && strspn(user, "0123456789"
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
523 "abcdefghijklmnopqrstuvwxyz"
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
524 "_"
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
525 "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
526 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
527 #endif
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
528
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
529 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
530 * Check if a string is a userid (all numeric).
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
531 *
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
532 * @param user The user id, email, or name.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
533 *
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
534 * @return TRUE if is userid, FALSE if not.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
535 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
536 gboolean
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
537 msim_is_userid(const gchar *user)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
538 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
539 g_return_val_if_fail(user != NULL, FALSE);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
540
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
541 return strspn(user, "0123456789") == strlen(user);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
542 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
543
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
544 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
545 * Check if a string is an email address (contains an @).
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
546 *
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
547 * @param user The user id, email, or name.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
548 *
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
549 * @return TRUE if is an email, FALSE if not.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
550 *
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
551 * This function is not intended to be used as a generic
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
552 * means of validating email addresses, but to distinguish
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
553 * between a user represented by an email address from
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
554 * other forms of identification.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
555 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
556 static gboolean
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
557 msim_is_email(const gchar *user)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
558 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
559 g_return_val_if_fail(user != NULL, FALSE);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
560
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
561 return strchr(user, '@') != NULL;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
562 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
563
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
564 /**
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
565 * Asynchronously lookup user information, calling callback when receive result.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
566 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
567 * @param session
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
568 * @param user The user id, email address, or username. Not freed.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
569 * @param cb Callback, called with user information when available.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
570 * @param data An arbitray data pointer passed to the callback.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
571 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
572 /* TODO: change to not use callbacks */
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
573 void
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
574 msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
575 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
576 MsimMessage *body;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
577 gchar *field_name;
31739
88b0a203e2e0 Silence a swath of warnings regarding set-but-unused.
Paul Aurich <darkrain42@pidgin.im>
parents: 29689
diff changeset
578 guint rid, dsn, lid;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
579
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
580 g_return_if_fail(user != NULL);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
581 /* Callback can be null to not call anything, just lookup & store information. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
582 /*g_return_if_fail(cb != NULL);*/
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
583
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
584 purple_debug_info("msim", "msim_lookup_userid: "
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
585 "asynchronously looking up <%s>\n", user);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
586
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
587 /* Setup callback. Response will be associated with request using 'rid'. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
588 rid = msim_new_reply_callback(session, cb, data);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
589
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
590 /* Send request */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
591
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
592 if (msim_is_userid(user)) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
593 field_name = "UserID";
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
594 dsn = MG_MYSPACE_INFO_BY_ID_DSN;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
595 lid = MG_MYSPACE_INFO_BY_ID_LID;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
596 } else if (msim_is_email(user)) {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
597 field_name = "Email";
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
598 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
599 lid = MG_MYSPACE_INFO_BY_STRING_LID;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
600 } else {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
601 field_name = "UserName";
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
602 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
603 lid = MG_MYSPACE_INFO_BY_STRING_LID;
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
604 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
605
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
606 body = msim_msg_new(
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
607 field_name, MSIM_TYPE_STRING, g_strdup(user),
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
608 NULL);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
609
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
610 g_return_if_fail(msim_send(session,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
611 "persist", MSIM_TYPE_INTEGER, 1,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
612 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
31739
88b0a203e2e0 Silence a swath of warnings regarding set-but-unused.
Paul Aurich <darkrain42@pidgin.im>
parents: 29689
diff changeset
613 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET,
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
614 "dsn", MSIM_TYPE_INTEGER, dsn,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
615 "uid", MSIM_TYPE_INTEGER, session->userid,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
616 "lid", MSIM_TYPE_INTEGER, lid,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
617 "rid", MSIM_TYPE_INTEGER, rid,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
618 "body", MSIM_TYPE_DICTIONARY, body,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
619 NULL));
22436
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
620 }
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
621
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
622 /**
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
623 * Called after username is set.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
624 */
25233
8a3fe5c4e2f4 Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25212
diff changeset
625 static void msim_username_is_set_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
626 {
25233
8a3fe5c4e2f4 Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25212
diff changeset
627 gchar *username;
8a3fe5c4e2f4 Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25212
diff changeset
628 const gchar *errmsg;
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
629 MsimMessage *body;
19795
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
630
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
631 guint rid;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32596
diff changeset
632 gint cmd,dsn,lid,code;
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
633 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\final\ */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
634
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
635 purple_debug_info("msim","username_is_set made\n");
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
636
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
637 cmd = msim_msg_get_integer(userinfo, "cmd");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
638 dsn = msim_msg_get_integer(userinfo, "dsn");
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32596
diff changeset
639 #if 0
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32596
diff changeset
640 gint uid = msim_msg_get_integer(userinfo, "uid");
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32596
diff changeset
641 #endif
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
642 lid = msim_msg_get_integer(userinfo, "lid");
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
643 body = msim_msg_get_dictionary(userinfo, "body");
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27376
diff changeset
644 errmsg = _("An error occurred while trying to set the username. "
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
645 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
646 "fuseaction=profile.username to set your username.");
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
647
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
648 if (!body) {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
649 purple_debug_info("msim_username_is_set_cb", "No body");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
650 /* Error: No body! */
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31739
diff changeset
651 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
652 }
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
653 username = msim_msg_get_string(body, "UserName");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
654 code = msim_msg_get_integer(body,"Code");
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
655
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
656 msim_msg_free(body);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
657
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
658 purple_debug_info("msim_username_is_set_cb",
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
659 "cmd = %d, dsn = %d, lid = %d, code = %d, username = %s\n",
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
660 cmd, dsn, lid, code, username);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
661
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
662 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_PUT)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
663 && dsn == MC_SET_USERNAME_DSN
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
664 && lid == MC_SET_USERNAME_LID)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
665 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
666 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
667 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",code);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
668 if (code == 0) {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
669 /* Good! */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
670 session->username = username;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
671 msim_we_are_logged_on(session);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
672 } else {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
673 purple_debug_info("msim_username_is_set", "code is %d",code);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
674 /* TODO: what to do here? */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
675 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
676 } else if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
677 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
678 && lid == MG_MYSPACE_INFO_BY_STRING_LID) {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
679 /* Not quite done... ONE MORE STEP :) */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
680 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
681 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username), NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
682 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
683 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
684 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
685 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
686 "uid", MSIM_TYPE_INTEGER, session->userid,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
687 "lid", MSIM_TYPE_INTEGER, MC_SET_USERNAME_LID,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
688 "rid", MSIM_TYPE_INTEGER, rid,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
689 "body", MSIM_TYPE_DICTIONARY, body,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
690 NULL)) {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
691 /* Error! */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
692 /* Can't set... Disconnect */
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31739
diff changeset
693 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
694 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
695
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
696 } else {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
697 /* Error! */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
698 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination");
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31739
diff changeset
699 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
700 }
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
701 }
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
702
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
703 /**
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
704 * Asynchronously set new username, calling callback when receive result.
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
705 *
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
706 * @param session
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
707 * @param username The username we're setting for ourselves. Not freed.
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
708 * @param cb Callback, called with user information when available.
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
709 * @param data An arbitray data pointer passed to the callback.
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
710 */
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
711 static void
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
712 msim_set_username(MsimSession *session, const gchar *username,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
713 MSIM_USER_LOOKUP_CB cb, gpointer data)
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
714 {
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
715 MsimMessage *body;
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
716 guint rid;
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
717
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
718 g_return_if_fail(username != NULL);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
719 g_return_if_fail(cb != NULL);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
720
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
721 purple_debug_info("msim", "msim_set_username: "
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
722 "Setting username %s\n", username);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
723
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
724 /* Setup callback. Response will be associated with request using 'rid'. */
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
725 rid = msim_new_reply_callback(session, cb, data);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
726
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
727 /* TODO: I dont know if the ContactType is -/ALWAYS/- 1 */
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
728
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
729 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username),NULL);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
730 /* \setinfo\\sesskey\469958979\info\Age=21.AvatarUrl=.BandName=.ContactType=1.DisplayName=Msim.Gender=M.ImageURL=http:/1/1x.myspace.com/1images/1no_pic.gif.LastLogin=128335268400000000.Location=US.ShowAvatar=False.SongName=.TotalFriends=1.UserName=msimprpl2\final\
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
731 */
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
732
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
733 /* Send request */
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
734 g_return_if_fail(msim_send(session,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
735 "setinfo", MSIM_TYPE_BOOLEAN, TRUE,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
736 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
737 "info", MSIM_TYPE_DICTIONARY, body,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
738 NULL));
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
739 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username),NULL);
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
740 g_return_if_fail(msim_send(session,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
741 "persist", MSIM_TYPE_INTEGER, 1,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
742 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
22435
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
743 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
744 "dsn", MSIM_TYPE_INTEGER, MG_MYSPACE_INFO_BY_STRING_DSN,
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
745 "uid", MSIM_TYPE_INTEGER, session->userid,
22435
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
746 "lid", MSIM_TYPE_INTEGER, MG_MYSPACE_INFO_BY_STRING_LID,
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
747 "rid", MSIM_TYPE_INTEGER, rid,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
748 "body", MSIM_TYPE_DICTIONARY, body,
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
749 NULL));
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
750 }
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
751
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
752 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
753 * They've confirmed that username that was available, Lets make the call to set it
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
754 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
755 static void msim_set_username_confirmed_cb(PurpleConnection *gc)
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
756 {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
757 MsimMessage *user_msg;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
758 MsimSession *session;
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
759
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
760 g_return_if_fail(gc != NULL);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
761
32262
c764e87d4b34 Convert myspace prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
762 session = purple_connection_get_protocol_data(gc);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
763
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
764 user_msg = msim_msg_new(
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
765 "user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
766 NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
767
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
768 purple_debug_info("msim_set_username_confirmed_cb", "Setting username to %s\n", msim_username_to_set);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
769
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
770 /* Sets our username... keep your fingers crossed :) */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
771 msim_set_username(session, msim_username_to_set, msim_username_is_set_cb, user_msg);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
772 g_free(msim_username_to_set);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
773 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
774
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
775 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
776 * This is where we do a bit more than merely prompt the user.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
777 * Now we have some real data to tell us the state of their requested username
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
778 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
779 */
25233
8a3fe5c4e2f4 Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25212
diff changeset
780 static void msim_username_is_available_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
781 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
782 MsimMessage *msg;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
783 gchar *username;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
784 MsimMessage *body;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
785 gint userid;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
786
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
787 purple_debug_info("msim_username_is_available_cb", "Look up username callback made\n");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
788
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
789 msg = (MsimMessage *)data;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
790 g_return_if_fail(msg != NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
791
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
792 username = msim_msg_get_string(msg, "user");
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
793 body = msim_msg_get_dictionary(userinfo, "body");
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
794
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
795 if (!body) {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
796 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31739
diff changeset
797 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27376
diff changeset
798 _("An error occurred while trying to set the username. "
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
799 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27376
diff changeset
800 "fuseaction=profile.username to set your username."));
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
801 return;
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
802 }
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
803
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
804 userid = msim_msg_get_integer(body, "UserID");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
805
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
806 purple_debug_info("msim_username_is_available_cb", "Returned username is %s and userid is %d\n", username, userid);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
807 msim_msg_free(body);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
808 msim_msg_free(msg);
22435
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
809
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
810 /* The response for a free username will ONLY have the UserName in it..
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
811 * thus making UserID return 0 when we msg_get_integer it */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
812 if (userid == 0) {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
813 /* This username is currently unused */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
814 purple_debug_info("msim_username_is_available_cb", "Username available. Prompting to Confirm.\n");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
815 msim_username_to_set = g_strdup(username);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
816 g_free(username);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
817 purple_request_yes_no(session->gc,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
818 _("MySpaceIM - Username Available"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
819 _("This username is available. Would you like to set it?"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
820 _("ONCE SET, THIS CANNOT BE CHANGED!"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
821 0,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
822 session->account,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
823 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
824 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
825 session->gc,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
826 G_CALLBACK(msim_set_username_confirmed_cb),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
827 G_CALLBACK(msim_do_not_set_username_cb));
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
828 } else {
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
829 /* Looks like its in use or we have an invalid response */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
830 purple_debug_info("msim_username_is_available_cb", "Username unavaiable. Prompting for new entry.\n");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
831 purple_request_input(session->gc, _("MySpaceIM - Please Set a Username"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
832 _("This username is unavailable."),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
833 _("Please try another username:"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
834 "", FALSE, FALSE, NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
835 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
836 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
837 session->account,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
838 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
839 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
840 session->gc);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
841 }
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
842 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
843
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
844 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
845 * Once they've submitted their desired new username,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
846 * check if it is available here.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
847 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
848 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
849 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
850 MsimMessage *user_msg;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
851 MsimSession *session;
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
852
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
853 g_return_if_fail(gc != NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
854
32262
c764e87d4b34 Convert myspace prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32191
diff changeset
855 session = purple_connection_get_protocol_data(gc);
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
856
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
857 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
858
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
859 user_msg = msim_msg_new(
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
860 "user", MSIM_TYPE_STRING, g_strdup(username_to_check),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
861 NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
862
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
863 /* 25 characters: letters, numbers, underscores */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
864 /* TODO: VERIFY ABOVE */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
865
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
866 /* \persist\1\sesskey\288500516\cmd\1\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=Jaywalker\final\ */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
867 /* Official client uses a standard lookup... So do we! */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
868 msim_lookup_user(session, username_to_check, msim_username_is_available_cb, user_msg);
22433
41a60cb99e28 In msimprpl, if the user signs in without any username set (this will happen
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22358
diff changeset
869 }
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
870
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
871 /***
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
872 * If they hit cancel or no at any point in the Setting Username process,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
873 * we come here. Currently we're safe letting them get by without
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
874 * setting it, unless we hear otherwise. So for now give them a menu.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
875 * If this becomes an issue with the official client then boot them here.
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
876 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
877 void msim_do_not_set_username_cb(PurpleConnection *gc)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
878 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
879 purple_debug_info("msim", "Don't set username");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
880
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
881 /* Protocol won't log in now without a username set.. Disconnect */
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 31739
diff changeset
882 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
25197
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
883 }
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
884
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
885 /**
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
886 * They've decided to set a username! Yay!
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
887 */
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
888 void msim_set_username_cb(PurpleConnection *gc)
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
889 {
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
890 g_return_if_fail(gc != NULL);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
891 purple_debug_info("msim","Set username\n");
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
892 purple_request_input(gc, _("MySpaceIM - Please Set a Username"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
893 _("Please enter a username to check its availability:"),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
894 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
895 "", FALSE, FALSE, NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
896 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
897 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
898 purple_connection_get_account(gc),
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
899 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
900 NULL,
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
901 gc);
077b4d6fc595 No functionality change--just cleanup.
Mark Doliner <markdoliner@pidgin.im>
parents: 25193
diff changeset
902 }

mercurial