annotate libpurple/protocols/myspace/user.c @ 19443:47c9c00878bf

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