annotate libpurple/protocols/myspace/user.c @ 21000:89c7be36fd61

propagate from branch 'im.pidgin.pidgin.2.2.2' (head 0adab134b7a42e144aee3ac60d825db1f28a42a4) to branch 'im.pidgin.pidgin' (head 4e59fcb1e2baf2eb63083224381e0af9fe1331cc)
author Richard Laager <rlaager@wiktel.com>
date Tue, 23 Oct 2007 17:27:12 +0000
parents 4293673c1f37 87c9d114864b
children 3f8b32a4786c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
1 /* MySpaceIM Protocol Plugin, header file
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
2 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im>
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
4 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
5 * This program is free software; you can redistribute it and/or modify
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
6 * it under the terms of the GNU General Public License as published by
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
8 * (at your option) any later version.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
9 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
10 * This program is distributed in the hope that it will be useful,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
13 * GNU General Public License for more details.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
14 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
15 * You should have received a copy of the GNU General Public License
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
16 * along with this program; if not, write to the Free Software
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
18 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
19
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
20 #include "myspace.h"
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
21
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
22 static void msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
23 static gchar *msim_format_now_playing(gchar *band, gchar *song);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
24 static void msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
25 gsize len, const gchar *error_message);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
26
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
27 /** Format the "now playing" indicator, showing the artist and song.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
28 * @return Return a new string (must be g_free()'d), or NULL.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
29 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
30 static gchar *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
31 msim_format_now_playing(gchar *band, gchar *song)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
32 {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
33 if ((band && *band) || (song && *song)) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
34 return g_strdup_printf("%s - %s",
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
35 (band && *band) ? band : "Unknown Artist",
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
36 (song && *song) ? song : "Unknown Song");
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
37 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
38 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
39 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
40 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
41 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
42 MsimUser *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
43 msim_get_user_from_buddy(PurpleBuddy *buddy)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
44 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
45 MsimUser *user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
46
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
47 if (!buddy) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
48 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
49 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
50
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
51 if (!buddy->proto_data) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
52 /* No MsimUser for this buddy; make one. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
53
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
54 /* TODO: where is this freed? */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
55 user = g_new0(MsimUser, 1);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
56 user->buddy = buddy;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
57 buddy->proto_data = (gpointer)user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
58 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
59
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
60 user = (MsimUser *)(buddy->proto_data);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
61
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
62 return user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
63 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
64
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
65 /** Find and return an MsimUser * representing a user on the buddy list, or NULL. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
66 MsimUser *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
67 msim_find_user(MsimSession *session, const gchar *username)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
68 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
69 PurpleBuddy *buddy;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
70 MsimUser *user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
71
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
72 buddy = purple_find_buddy(session->account, username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
73 if (!buddy) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
74 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
75 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
76
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
77 user = msim_get_user_from_buddy(buddy);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
78
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
79 return user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
80 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
81
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
82 /** Append user information to a PurpleNotifyUserInfo, given an MsimUser.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
83 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
84 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
85 void
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
86 msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
87 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
88 gchar *str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
89 guint uid;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
90 guint cv;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
91
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
92 /* Useful to identify the account the tooltip refers to.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
93 * Other prpls show this. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
94 if (user->username) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
95 purple_notify_user_info_add_pair(user_info, _("User"), user->username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
96 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
97
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
98 uid = purple_blist_node_get_int(&user->buddy->node, "UserID");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
99
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
100 if (full) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
101 /* TODO: link to username, if available */
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
102 if (uid) {
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
103 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>",
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
104 uid, uid);
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
105 purple_notify_user_info_add_pair(user_info, _("Profile"), profile);
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
106 g_free(profile);
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
107 }
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
108 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
109
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
110
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
111 /* a/s/l...the vitals */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
112 if (user->age) {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
113 char age[16];
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
114 g_snprintf(age, sizeof(age), "%d", user->age);
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
115 purple_notify_user_info_add_pair(user_info, _("Age"), age);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
116 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
117
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
118 if (user->gender && *user->gender) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
119 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
120 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
121
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
122 if (user->location && *user->location) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
123 purple_notify_user_info_add_pair(user_info, _("Location"), user->location);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
124 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
125
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
126 /* Other information */
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
127 if (user->headline && *user->headline) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
128 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
129 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
130
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
131 str = msim_format_now_playing(user->band_name, user->song_name);
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
132 if (str && *str) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
133 purple_notify_user_info_add_pair(user_info, _("Song"), str);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
134 }
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
135 g_free(str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
136
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
137 /* Note: total friends only available if looked up by uid, not username. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
138 if (user->total_friends) {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
139 char friends[16];
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
140 g_snprintf(friends, sizeof(friends), "%d", user->total_friends);
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
141 purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
142 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
143
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
144 if (full) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
145 /* Client information */
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
146 char *client = NULL;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
147
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
148 str = user->client_info;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
149 cv = user->client_cv;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
150
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
151 if (str && cv != 0) {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
152 client = g_strdup_printf("%s (build %d)", str, cv);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
153 } else if (str) {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
154 client = g_strdup(str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
155 } else if (cv) {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
156 client = g_strdup_printf("Build %d", cv);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
157 }
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
158 if (client && *client)
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
159 purple_notify_user_info_add_pair(user_info, _("Client Version"), client);
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20689
diff changeset
160 g_free(client);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
161 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
162 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
163
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
164 /** Store a field of information about a buddy.
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
165 *
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
166 * @param key_str Key to store.
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
167 * @param value_str Value string, either user takes ownership of this string
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
168 * or it is freed if MsimUser doesn't store the string.
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
169 * @param user User to store data in. Existing data will be replaced.
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
170 * */
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
171 void
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
172 msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
173 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
174 if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
175 /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
176 if (user->buddy)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
177 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
178 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
179 purple_blist_node_set_int(&user->buddy->node, "UserID", atol(value_str));
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
180 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
181 /* Need to store in MsimUser, too? What if not on blist? */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
182 } else if (g_str_equal(key_str, "Age")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
183 user->age = atol(value_str);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
184 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
185 } else if (g_str_equal(key_str, "Gender")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
186 g_free(user->gender);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
187 user->gender = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
188 } else if (g_str_equal(key_str, "Location")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
189 g_free(user->location);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
190 user->location = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
191 } else if (g_str_equal(key_str, "TotalFriends")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
192 user->total_friends = atol(value_str);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
193 } else if (g_str_equal(key_str, "DisplayName")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
194 g_free(user->display_name);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
195 user->display_name = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
196 } else if (g_str_equal(key_str, "BandName")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
197 g_free(user->band_name);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
198 user->band_name = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
199 } else if (g_str_equal(key_str, "SongName")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
200 g_free(user->song_name);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
201 user->song_name = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
202 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
203 /* Ignore because PurpleBuddy knows this already */
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
204 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
205 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) {
20364
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
206 if (user->temporary_user) {
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
207 /* This user will be destroyed soon; don't try to look up its image or avatar,
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
208 * since that won't return immediately and we will end up accessing freed data.
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
209 */
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
210 g_free(value_str);
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
211 return;
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
212 }
4293673c1f37 applied changes from 8e81ccec879f9cfbd8fc282b703803c98e150ff7
Luke Schierer <lschiere@pidgin.im>
parents: 20306
diff changeset
213
20995
87c9d114864b Fix a warning
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
214 const gchar *previous_url;
87c9d114864b Fix a warning
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
215
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
216 if (user->temporary_user) {
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
217 /* This user will be destroyed soon; don't try to look up its image or avatar,
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
218 * since that won't return immediately and we will end up accessing freed data.
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
219 */
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
220 g_free(value_str);
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
221 return;
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
222 }
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20753
diff changeset
223
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
224 g_free(user->image_url);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
225
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
226 user->image_url = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
227
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
228 /* Instead of showing 'no photo' picture, show nothing. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
229 if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif"))
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
230 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
231 purple_buddy_icons_set_for_user(user->buddy->account,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
232 user->buddy->name,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
233 NULL, 0, NULL);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
234 return;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
235 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
236
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
237 /* TODO: use ETag for checksum */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
238 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
239
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
240 /* Only download if URL changed */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
241 if (!previous_url || !g_str_equal(previous_url, user->image_url)) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
242 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
243 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
244 } else if (g_str_equal(key_str, "LastImageUpdated")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
245 /* TODO: use somewhere */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
246 user->last_image_updated = atol(value_str);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
247 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
248 } else if (g_str_equal(key_str, "Headline")) {
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
249 g_free(user->headline);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
250 user->headline = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
251 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
252 /* TODO: other fields in MsimUser */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
253 gchar *msg;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
254
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
255 msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
256 key_str, value_str);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
257 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
258
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
259 msim_unrecognized(NULL, NULL, msg);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
260
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
261 g_free(msg);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
262 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
263 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
264
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
265 /** Save buddy information to the buddy list from a user info reply message.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
266 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
267 * @param session
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
268 * @param msg The user information reply, with any amount of information.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
269 * @param user The structure to save to, or NULL to save in PurpleBuddy->proto_data.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
270 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
271 * Variable information is saved to the passed MsimUser structure. Permanent
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
272 * information (UserID) is stored in the blist node of the buddy list (and
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
273 * ends up in blist.xml, persisted to disk) if it exists.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
274 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
275 * If the function has no buddy information, this function
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
276 * is a no-op (and returns FALSE).
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
277 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
278 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
279 gboolean
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
280 msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
281 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
282 gchar *username;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
283 MsimMessage *body, *body_node;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
284
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
285 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
286 g_return_val_if_fail(msg != NULL, FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
287
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
288 body = msim_msg_get_dictionary(msg, "body");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
289 if (!body) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
290 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
291 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
292
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
293 username = msim_msg_get_string(body, "UserName");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
294
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
295 if (!username) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
296 purple_debug_info("msim",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
297 "msim_process_reply: not caching body, no UserName\n");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
298 msim_msg_free(body);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
299 g_free(username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
300 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
301 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
302
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
303 /* Null user = find and store in PurpleBuddy's proto_data */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
304 if (!user) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
305 user = msim_find_user(session, username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
306 if (!user) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
307 msim_msg_free(body);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
308 g_free(username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
309 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
310 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
311 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
312
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
313 /* TODO: make looping over MsimMessage's easier. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
314 for (body_node = body;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
315 body_node != NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
316 body_node = msim_msg_get_next_element_node(body_node))
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
317 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
318 const gchar *key_str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
319 gchar *value_str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
320 MsimMessageElement *elem;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
321
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
322 elem = (MsimMessageElement *)body_node->data;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
323 key_str = elem->name;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
324
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
325 value_str = msim_msg_get_string_from_element(elem);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
326 msim_store_user_info_each(key_str, value_str, user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
327 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
328
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
329 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN &&
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
330 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
331 /* TODO: do something with our own IM info, if we need it for some
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
332 * specific purpose. Otherwise it is available on the buddy list,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
333 * if the user has themselves as their own buddy.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
334 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
335 * However, much of the info is already available in MsimSession,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
336 * stored in msim_we_are_logged_on(). */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
337 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN &&
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
338 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
339 /* TODO: same as above, but for MySpace info. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
340 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
341
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
342 msim_msg_free(body);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
343 g_free(username);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
344
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
345 return TRUE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
346 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
347
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
348 /**
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
349 * Asynchronously lookup user information, calling callback when receive result.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
350 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
351 * @param session
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
352 * @param user The user id, email address, or username. Not freed.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
353 * @param cb Callback, called with user information when available.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
354 * @param data An arbitray data pointer passed to the callback.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
355 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
356 /* TODO: change to not use callbacks */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
357 void
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
358 msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
359 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
360 MsimMessage *body;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
361 gchar *field_name;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
362 guint rid, cmd, dsn, lid;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
363
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
364 g_return_if_fail(MSIM_SESSION_VALID(session));
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
365 g_return_if_fail(user != NULL);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
366 /* Callback can be null to not call anything, just lookup & store information. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
367 /*g_return_if_fail(cb != NULL);*/
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
368
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
369 purple_debug_info("msim", "msim_lookup_userid: "
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
370 "asynchronously looking up <%s>\n", user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
371
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
372 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
373
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
374 /* Setup callback. Response will be associated with request using 'rid'. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
375 rid = msim_new_reply_callback(session, cb, data);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
376
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
377 /* Send request */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
378
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
379 cmd = MSIM_CMD_GET;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
380
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
381 if (msim_is_userid(user)) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
382 field_name = "UserID";
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
383 dsn = MG_MYSPACE_INFO_BY_ID_DSN;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
384 lid = MG_MYSPACE_INFO_BY_ID_LID;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
385 } else if (msim_is_email(user)) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
386 field_name = "Email";
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
387 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
388 lid = MG_MYSPACE_INFO_BY_STRING_LID;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
389 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
390 field_name = "UserName";
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
391 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
392 lid = MG_MYSPACE_INFO_BY_STRING_LID;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
393 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
394
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
395 body = msim_msg_new(
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
396 field_name, MSIM_TYPE_STRING, g_strdup(user),
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
397 NULL);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
398
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
399 g_return_if_fail(msim_send(session,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
400 "persist", MSIM_TYPE_INTEGER, 1,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
401 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
402 "cmd", MSIM_TYPE_INTEGER, 1,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
403 "dsn", MSIM_TYPE_INTEGER, dsn,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
404 "uid", MSIM_TYPE_INTEGER, session->userid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
405 "lid", MSIM_TYPE_INTEGER, lid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
406 "rid", MSIM_TYPE_INTEGER, rid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
407 "body", MSIM_TYPE_DICTIONARY, body,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
408 NULL));
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
409 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
410
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
411
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
412 /**
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
413 * Check if a string is a userid (all numeric).
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
414 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
415 * @param user The user id, email, or name.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
416 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
417 * @return TRUE if is userid, FALSE if not.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
418 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
419 gboolean
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
420 msim_is_userid(const gchar *user)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
421 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
422 g_return_val_if_fail(user != NULL, FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
423
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
424 return strspn(user, "0123456789") == strlen(user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
425 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
426
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
427 /**
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
428 * Check if a string is an email address (contains an @).
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
429 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
430 * @param user The user id, email, or name.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
431 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
432 * @return TRUE if is an email, FALSE if not.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
433 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
434 * This function is not intended to be used as a generic
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
435 * means of validating email addresses, but to distinguish
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
436 * between a user represented by an email address from
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
437 * other forms of identification.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
438 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
439 gboolean
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
440 msim_is_email(const gchar *user)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
441 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
442 g_return_val_if_fail(user != NULL, FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
443
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
444 return strchr(user, '@') != NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
445 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
446
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
447
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
448 /** Callback for when a buddy icon finished being downloaded. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
449 static void
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
450 msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
451 gpointer user_data,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
452 const gchar *url_text,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
453 gsize len,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
454 const gchar *error_message)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
455 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
456 MsimUser *user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
457
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
458 user = (MsimUser *)user_data;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
459
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
460 purple_debug_info("msim_downloaded_buddy_icon",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
461 "Downloaded %d bytes\n", len);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
462
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
463 if (!url_text) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
464 purple_debug_info("msim_downloaded_buddy_icon",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
465 "failed to download icon for %s",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
466 user->buddy->name);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
467 return;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
468 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
469
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
470 purple_buddy_icons_set_for_user(user->buddy->account,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
471 user->buddy->name,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
472 g_memdup((gchar *)url_text, len), len,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
473 /* Use URL itself as buddy icon "checksum" (TODO: ETag) */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
474 user->image_url); /* checksum */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
475 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
476
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
477