libpurple/protocols/myspace/user.c

Fri, 12 Dec 2008 20:03:58 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Fri, 12 Dec 2008 20:03:58 +0000
branch
next.minor
changeset 25140
7c494d2bc5e4
parent 25116
cb60ad01e2e8
parent 24946
390536329dc5
child 25150
b0e1b122d83a
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
to branch 'im.pidgin.pidgin.next.minor' (head 0c35efded3c5ad8d7d633c92fe52845c5c8bb869)

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
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
22 static void msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user);
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
23 static gchar *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
24 static void msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
25 gsize len, const gchar *error_message);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
26
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
27 /* Callbacks for setting the username bit */
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
28 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *value);
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
29 static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, 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
30 static void msim_set_username_confirmed_cb(PurpleConnection *gc);
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
31 static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, 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
32 static void 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
33 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
34 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
35
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
36 /** Format the "now playing" indicator, showing the artist and song.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
37 * @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
38 */
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 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
40 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
41 {
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
42 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
43 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
44 (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
45 (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
46 } 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
47 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
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 }
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 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */
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 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
52 msim_get_user_from_buddy(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
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 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
55
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
56 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
57 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
58 }
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
24946
390536329dc5 Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24398
diff changeset
60 if (!(user = purple_buddy_get_protocol_data(buddy))) {
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
61 /* 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
62
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
63 /* TODO: where is this 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
64 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
65 user->buddy = buddy;
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25116 24946
diff changeset
66 purple_buddy_set_protocol_data(buddy, user);
24946
390536329dc5 Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24398
diff changeset
67 }
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
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 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
70 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
71
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
72 /** Find and return an MsimUser * representing a user on the buddy list, 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
73 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
74 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
75 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
76 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
77 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
78
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
79 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
80 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
81 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
82 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
83
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
84 user = msim_get_user_from_buddy(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
85
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
86 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
87 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
88
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
89 /** Append user information to a PurpleNotifyUserInfo, given an 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
90 * 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
91 */
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 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
93 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
94 {
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
95 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
96 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
97 guint uid;
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 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
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 /* Useful to identify the account the tooltip refers to.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
101 * 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
102 if (user->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
103 purple_notify_user_info_add_pair(user_info, _("User"), user->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
104 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
105
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
106 uid = purple_blist_node_get_int((PurpleBlistNode *)user->buddy, "UserID");
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
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 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
109 /* TODO: link to username, if available */
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
110 if (uid) {
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
111 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>",
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
112 uid, uid);
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
113 purple_notify_user_info_add_pair(user_info, _("Profile"), profile);
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
114 g_free(profile);
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
115 }
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 }
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
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
118
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 /* 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
120 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
121 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
122 g_snprintf(age, sizeof(age), "%d", user->age);
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 purple_notify_user_info_add_pair(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
124 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
125
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
126 if (user->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
127 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
128 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
129
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
130 if (user->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
131 purple_notify_user_info_add_pair(user_info, _("Location"), user->location);
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
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
134 /* 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
135 if (user->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
136 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline);
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
137 }
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
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
139 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
140 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
141
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
142 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
143 PurpleStatus *status;
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
144 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
145
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
146 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
147 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
148 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
149
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
150 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
151 if (str && *str) {
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
152 purple_notify_user_info_add_pair(user_info, _("Song"), str);
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
153 }
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
154 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
155 }
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
156 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
157
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
158 /* 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
159 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
160 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
161 g_snprintf(friends, sizeof(friends), "%d", user->total_friends);
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
162 purple_notify_user_info_add_pair(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
163 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
164
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
165 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
166 /* 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
167 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
168
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 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
170 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
171
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
172 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
173 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
174 } 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
175 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
176 } 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
177 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
178 }
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
179 if (client && *client)
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
180 purple_notify_user_info_add_pair(user_info, _("Client Version"), client);
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
181 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
182 }
25089
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
183
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
184 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
185 /* 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
186 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
187 purple_notify_user_info_add_section_break(user_info);
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
188 profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>",
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
189 user->id, _("View web 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
190 purple_notify_user_info_add_pair(user_info, NULL, profile);
b381e7e2a1cf Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <markdoliner@pidgin.im>
parents: 23517
diff changeset
191 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
192 }
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
193 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
194
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
195 /** Set the currently playing song artist and 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
196 *
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
197 * @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
198 *
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
199 * @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
200 *
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
201 * @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
202 *
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
203 * 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
204 *
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
205 * 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
206 * 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
207 */
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
208 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
209 {
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
210 PurplePresence *presence;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
211 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
212 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
213 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
214
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
215 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
216 /* 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
217 return;
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
218
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
219 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
220 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
221
25115
53ea7403c0a8 Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <markdoliner@pidgin.im>
parents: 25089
diff changeset
222 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
223 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
224 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
225 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
226
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
227 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
228 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
229
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
230 if (!new_artist && !new_title) {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
231 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
232 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
233 }
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
234
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
235 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
236
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
237 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
238 PurpleStatus *status;
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
239
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
240 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
241 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
242 prev_artist = purple_status_get_attr_string(status, PURPLE_TUNE_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
243 }
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
244
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
245 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
246 new_artist = prev_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
247
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
248 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
249 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
250
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
251 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
252 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
253 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
254 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
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
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
257 /** Store a field of information about a buddy.
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
258 *
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
259 * @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
260 * @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
261 * 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
262 * @param user User to store data in. Existing data will be replaced.
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
263 * */
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
264 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
265 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
266 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
267 const char *name = user->buddy ? purple_buddy_get_name(user->buddy) : 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
268 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
269 /* 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
270 user->id = atol(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
271 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
272 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
273 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, name);
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25116 24946
diff changeset
274 purple_blist_node_set_int((PurpleBlistNode *)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
275 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
276 /* 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
277 } 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
278 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
279 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
280 } 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
281 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
282 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
283 } 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
284 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
285 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
286 } 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
287 user->total_friends = atol(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
288 } 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
289 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
290 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
291 } 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
292 msim_set_artist_or_title(user, value_str, 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
293 } 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
294 msim_set_artist_or_title(user, NULL, 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
295 } 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
296 /* 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
297 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
298 } 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
299 const gchar *previous_url;
801334f9576b Fix a warning
Kevin Stange <kstange@pidgin.im>
parents: 21058
diff changeset
300
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
301 if (user->temporary_user) {
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
302 /* This user will be destroyed soon; don't try to look up its image or avatar,
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
303 * 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
304 */
4ccbe30d873e When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evands@pidgin.im>
parents: 20815
diff changeset
305 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
306 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
307 }
21098
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
308
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
309 if (user->temporary_user) {
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
310 /* This user will be destroyed soon; don't try to look up its image or avatar,
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
311 * since that won't return immediately and we will end up accessing freed data.
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
312 */
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
313 g_free(value_str);
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
314 return;
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
315 }
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
316
20402
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
317 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
318
a3a7cbfe1c1c Fix a few memory leaks in #3281 (details in ticket).
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 20376
diff changeset
319 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
320
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
321 /* 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
322 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
323 {
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
324 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
325 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
326 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
327 }
21098
05dca51886e7 Fix this warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21076
diff changeset
328
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
329 /* 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
330 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
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 /* 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
333 if (!previous_url || !g_str_equal(previous_url, user->image_url)) {
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 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)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
335 }
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, "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
337 /* 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
338 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
339 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
340 } 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
341 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
342 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
343 } 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
344 /* 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
345 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
346
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
347 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
348 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
349 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
350
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 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
352
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
353 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
354 }
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 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
356
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 /** Save buddy information to the buddy list from a user info reply message.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
358 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
359 * @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
360 * @param msg The user information reply, with any amount of 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
361 * @param user The structure to save to, or NULL to save in PurpleBuddy->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
362 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
363 * 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
364 * 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
365 * 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
366 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
367 * 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
368 * 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
369 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
370 */
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 gboolean
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 msim_store_user_info(MsimSession *session, MsimMessage *msg, 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
373 {
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 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
375 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
376
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 g_return_val_if_fail(MSIM_SESSION_VALID(session), 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
378 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
379
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 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
381 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
382 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
383 }
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
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
385 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
386
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 if (!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
388 purple_debug_info("msim",
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 "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
390 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
391 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
392 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
393 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
394
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 /* 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
396 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
397 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
398 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
399 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
400 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
401 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
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 }
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 /* TODO: make looping over MsimMessage's easier. */
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 for (body_node = 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
407 body_node != 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
408 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
409 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
410 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
411 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
412 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
413
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
414 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
415 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
416
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 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
418 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
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
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 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_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
422 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_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
423 /* TODO: do something with our own IM info, if we need it for some
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
424 * specific purpose. Otherwise it is available on the buddy list,
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 * if the user has themselves as their own 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
426 *
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 * However, much of the info is already available in MsimSession,
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 * stored in msim_we_are_logged_on(). */
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 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_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
430 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_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
431 /* TODO: same as above, but for MySpace 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
432 }
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
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 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
435 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
436
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
437 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
438 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
439
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
440 /**
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
441 * 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
442 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
443 * @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
444 * @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
445 * @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
446 * @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
447 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
448 /* TODO: change to not use callbacks */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
449 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
450 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
451 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
452 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
453 gchar *field_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
454 guint rid, cmd, dsn, 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
455
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
456 g_return_if_fail(MSIM_SESSION_VALID(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
457 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
458 /* 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
459 /*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
460
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
461 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
462 "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
463
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
464 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)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
465
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
466 /* 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
467 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
468
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
469 /* 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
470
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 cmd = MSIM_CMD_GET;
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
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
473 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
474 field_name = "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
475 dsn = MG_MYSPACE_INFO_BY_ID_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
476 lid = MG_MYSPACE_INFO_BY_ID_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
477 } 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
478 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
479 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
480 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
481 } 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
482 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
483 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
484 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
485 }
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
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 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
488 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
489 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
490
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
491 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
492 "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
493 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
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 "cmd", 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
495 "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
496 "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
497 "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
498 "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
499 "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
500 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
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
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
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 * Check if a string is a userid (all numeric).
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 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
507 * @param user The user id, email, or 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
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 if is userid, FALSE if not.
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 gboolean
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
512 msim_is_userid(const gchar *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
513 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
514 g_return_val_if_fail(user != 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
515
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
516 return strspn(user, "0123456789") == strlen(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
517 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
518
22436
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
519 /** Return whether a given username is syntactically valid.
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
520 * Note: does not actually check that the user exists. */
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
521 gboolean
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
522 msim_is_valid_username(const gchar *user)
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
523 {
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
524 return !msim_is_userid(user) && /* Not all numeric */
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
525 strlen(user) <= MSIM_MAX_USERNAME_LENGTH
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
526 && strspn(user, "0123456789"
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
527 "abcdefghijklmnopqrstuvwxyz"
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
528 "_"
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
529 "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user);
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
530 }
3483af12d74f In msimprpl, add msim_is_valid_username() to check whether a username
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22435
diff changeset
531
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
532 /**
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
533 * Check if a string is an email address (contains an @).
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
534 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
535 * @param user The user id, email, or 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
536 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
537 * @return TRUE if is an email, FALSE if not.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
538 *
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
539 * This function is not intended to be used as a generic
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
540 * means of validating email addresses, but to distinguish
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
541 * between a user represented by an email address from
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
542 * other forms of identification.
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
543 */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
544 gboolean
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
545 msim_is_email(const gchar *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
546 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
547 g_return_val_if_fail(user != 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
548
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
549 return strchr(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
550 }
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
551
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
552
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
553 /** Callback for when a buddy icon finished being downloaded. */
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
554 static 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
555 msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_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
556 gpointer user_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
557 const gchar *url_text,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
558 gsize len,
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
559 const gchar *error_message)
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
560 {
149d7d8284cc Replace all CRLF line-endings with LF line endings (Unix-style). This fixes
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 19635
diff changeset
561 MsimUser *user;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
562 const char *name;
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
563
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 user = (MsimUser *)user_data;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
565 name = purple_buddy_get_name(user->buddy);
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
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 purple_debug_info("msim_downloaded_buddy_icon",
22622
1ecb840b5101 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents: 22439
diff changeset
568 "Downloaded %" G_GSIZE_FORMAT " bytes\n", len);
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
569
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 if (!url_text) {
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 purple_debug_info("msim_downloaded_buddy_icon",
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 "failed to download icon for %s",
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
573 name);
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 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
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
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23517
diff changeset
577 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
578 name, g_memdup((gchar *)url_text, len), len,
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 /* Use URL itself as buddy icon "checksum" (TODO: ETag) */
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 user->image_url); /* 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
581 }
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
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
583 /***
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
584 * If they hit cancel or no at any point in the Setting Username process, we come here. *
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
585 * Currently.. We're safe letting them get by without setting it.. Unless we hear otherwise.. *
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
586 * So for now, give them a menu.. If this becomes an issue with the Official client.. boot them here */
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
587 void msim_do_not_set_username_cb(PurpleConnection *gc) {
22439
7d55e1ec2825 If the user sets a username (because they don't have one), and it succeeds,
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22436
diff changeset
588 purple_debug_info("msim", "Don't set username");
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
589
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
590 /* Protocol won't log in now without a username set.. Disconnect */
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
591 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
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
592 }
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
593
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
594 /** They've decided to set a username! Yay! */
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
595 void msim_set_username_cb(PurpleConnection *gc) {
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
596 g_return_if_fail(gc != 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
597 purple_debug_info("msim","Set username\n");
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
598 purple_request_input(gc, _("MySpaceIM - Please Set a 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
599 _("Please enter a username to check its availability:"),
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
600 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
601 "", FALSE, FALSE, 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
602 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
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
603 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
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
604 purple_connection_get_account(gc),
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
605 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
606 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
607 gc);
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
608 }
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
609
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
610 /** Once they've submitted their desired new username,
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
611 * check if it is available here. */
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
612 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check)
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
613 {
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
614 MsimMessage *user_msg;
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
615 MsimSession *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
616
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
617 g_return_if_fail(gc != 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
618
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
619 session = (MsimSession *)gc->proto_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
620
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
621 g_return_if_fail(MSIM_SESSION_VALID(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
622
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
623 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check);
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
624
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
625 user_msg = msim_msg_new(
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
626 "user", MSIM_TYPE_STRING, g_strdup(username_to_check),
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
627 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
628
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
629 /* 25 characters: letters, numbers, underscores */
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
630 /* TODO: VERIFY ABOVE */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
631
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
632 /* \persist\1\sesskey\288500516\cmd\1\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=Jaywalker\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
633 /* Official client uses a standard lookup... So do we! */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
634 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
635 }
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
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
637 /** This is where we do a bit more than merely prompt the user.
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
638 * Now we have some real data to tell us the state of their requested username
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
639 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\ */
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
640 static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
641 {
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
642 MsimMessage *msg;
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
643 gchar *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
644 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
645 gint userid;
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
646
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
647 purple_debug_info("msim_username_is_available_cb", "Look up username callback 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
648
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
649 msg = (MsimMessage *)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
650 g_return_if_fail(MSIM_SESSION_VALID(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
651 g_return_if_fail(msg != 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
652
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
653 username = msim_msg_get_string(msg, "user");
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
654 body = msim_msg_get_dictionary(userinfo, "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
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 if (!body) {
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
657 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username);
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
658 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
23517
db3d6a500678 Fix occurred to be spelled correctly. Thanks to bruce89 for noticing. Fixes #6096.
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
659 "An error occurred while trying to set the username.\n"
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
660 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
661 "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
662 return;
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
663 }
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
664
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
665 userid = msim_msg_get_integer(body, "UserID");
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
666
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
667 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
668 msim_msg_free(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
669 msim_msg_free(msg);
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
670
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
671 /* The response for a free username will ONLY have the UserName in it..
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
672 * thus making UserID return 0 when we msg_get_integer it */
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
673 if (userid == 0) {
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
674 /* This username is currently unused */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
675 purple_debug_info("msim_username_is_available_cb", "Username available. Prompting to Confirm.\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
676 msim_username_to_set = g_strdup(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
677 g_free(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
678 purple_request_yes_no(session->gc,
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
679 _("MySpaceIM - Username 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
680 _("This username is available. Would you like to set it?"),
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
681 _("ONCE SET, THIS CANNOT BE CHANGED!"),
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
682 0,
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
683 session->account,
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
684 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
685 NULL,
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
686 session->gc,
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
687 G_CALLBACK(msim_set_username_confirmed_cb),
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
688 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
689 } else {
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
690 /* Looks like its in use or we have an invalid response */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
691 purple_debug_info("msim_username_is_available_cb", "Username unavaiable. Prompting for new entry.\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
692 purple_request_input(session->gc, _("MySpaceIM - Please Set a 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
693 _("This username is unavailable."),
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
694 _("Please try another 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
695 "", FALSE, FALSE, 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
696 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
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
697 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
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
698 session->account,
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
699 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
700 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
701 session->gc);
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
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 /* They've confirmed that username that was available, Lets make the call to set it */
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
706 static void msim_set_username_confirmed_cb(PurpleConnection *gc)
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
707 {
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
708 MsimMessage *user_msg;
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 MsimSession *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
710
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
711 g_return_if_fail(gc != 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
712
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 session = (MsimSession *)gc->proto_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 g_return_if_fail(MSIM_SESSION_VALID(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
716
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 user_msg = msim_msg_new(
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 "user", MSIM_TYPE_STRING, g_strdup(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
720 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
721
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
722 purple_debug_info("msim_set_username_confirmed_cb", "Setting username to %s\n", msim_username_to_set);
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
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 /* Sets our username... keep your fingers crossed :) */
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 msim_set_username(session, msim_username_to_set, msim_username_is_set_cb, user_msg);
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 g_free(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
727 }
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 /**
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 * 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
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 * @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
733 * @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
734 * @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
735 * @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
736 */
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 static void
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 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
739 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
740 {
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 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
742 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
743
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
744 g_return_if_fail(MSIM_SESSION_VALID(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
745 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
746 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
747
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 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
749 "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
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 msim_msg_dump("msim_set_username: data=%s\n", (MsimMessage *)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
752
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
753 /* 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
754 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
755
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
756 /* 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
757
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
758 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
759 /* \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
760 */
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
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
762 /* 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
763 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
764 "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
765 "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
766 "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
767 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
768 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
769 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
770 "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
771 "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
772 "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
773 "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
774 "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
775 "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
776 "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
777 "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
778 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
779 }
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
780
22434
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
781 /** Called after username is set. */
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
782 static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
3bc4a0a62c40 In msimprpl, change to patch from Jaywalker regarding setting
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22433
diff changeset
783 {
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
784 gchar *username, *errmsg;
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
785 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
786
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
787 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
788 gint cmd,dsn,uid,lid,code;
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
789 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\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
790
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
791 purple_debug_info("msim","username_is_set made\n");
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
792
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 g_return_if_fail(MSIM_SESSION_VALID(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
794
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
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
796 msim_msg_dump("username_is_set message is: %s\n", userinfo);
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
797 cmd = msim_msg_get_integer(userinfo, "cmd");
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
798 dsn = msim_msg_get_integer(userinfo, "dsn");
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
799 uid = msim_msg_get_integer(userinfo, "uid");
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
800 lid = msim_msg_get_integer(userinfo, "lid");
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
801 body = msim_msg_get_dictionary(userinfo, "body");
23517
db3d6a500678 Fix occurred to be spelled correctly. Thanks to bruce89 for noticing. Fixes #6096.
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
802 errmsg = g_strdup("An error occurred while trying to set the username.\n"
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
803 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
804 "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
805
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
806 if (!body) {
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
807 purple_debug_info("msim_username_is_set_cb", "No body");
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
808 /* Error: No 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
809 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
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
810 }
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
811 username = msim_msg_get_string(body, "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
812 code = msim_msg_get_integer(body,"Code");
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
813
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
814 msim_msg_free(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
815
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
816 purple_debug_info("msim_username_is_set_cb",
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
817 "cmd = %d, dsn = %d, lid = %d, code = %d, username = %s\n",
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
818 cmd, dsn, lid, code, username);
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
819
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
820 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_PUT)
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
821 && dsn == MC_SET_USERNAME_DSN
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
822 && lid == MC_SET_USERNAME_LID) {
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
823 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n");
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
824 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",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
825 if (code == 0) {
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
826 /* Good! */
22439
7d55e1ec2825 If the user sets a username (because they don't have one), and it succeeds,
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22436
diff changeset
827 session->username = 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
828 msim_we_are_logged_on(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
829 } else {
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
830 purple_debug_info("msim_username_is_set", "code is %d",code);
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
831 /* TODO: what to do here? */
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
832 }
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
833 } else if (cmd == (MSIM_CMD_BIT_REPLY | 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
834 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
835 && lid == 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
836 /* Not quite done... ONE MORE STEP :) */
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
837 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data);
22439
7d55e1ec2825 If the user sets a username (because they don't have one), and it succeeds,
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22436
diff changeset
838 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username), NULL);
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
839 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
840 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
841 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
842 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
843 "uid", MSIM_TYPE_INTEGER, session->userid,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
844 "lid", MSIM_TYPE_INTEGER, MC_SET_USERNAME_LID,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
845 "rid", MSIM_TYPE_INTEGER, rid,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
846 "body", MSIM_TYPE_DICTIONARY, body,
602abcb53ab0 In msimprpl, define a new set of symbolic constants for the command to
Jeff Connelly <jeff2@soc.pidgin.im>
parents: 22434
diff changeset
847 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
848 /* Error! */
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
849 /* Can't set... Disconnect */
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
850 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
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
851 }
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
852
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
853 } else {
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
854 /* Error! */
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
855 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination");
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
856 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
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
857 }
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
858 g_free(errmsg);
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
859 }

mercurial