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