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