Mercurial > pidgin
annotate libpurple/protocols/myspace/user.c @ 22306:7d0e93198c39
If the user sets a username (because they don't have one), and it succeeds,
then set MsimSession.username as well and update the server alias, so that
outgoing messages correctly appear as from their username instead of uid.
Based on patch from Jaywalker. Closes #4857.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 18 Feb 2008 19:20:39 +0000 |
parents | bf4902fce6e4 |
children | 3225c99785b8 |
rev | line source |
---|---|
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
1 /* MySpaceIM Protocol Plugin, header file |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
2 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
4 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
8 * (at your option) any later version. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
9 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
13 * GNU General Public License for more details. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
14 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
18 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
19 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
20 #include "myspace.h" |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
21 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
22 static void msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user); |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
23 static gchar *msim_format_now_playing(const gchar *band, const gchar *song); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
24 static void msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
25 gsize len, const gchar *error_message); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
26 |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
27 /* Callbacks for setting the username bit */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
28 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *value); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
29 static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
30 static void msim_set_username_confirmed_cb(PurpleConnection *gc); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
31 static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
32 static void msim_set_username(MsimSession *session, const gchar *username, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
33 MSIM_USER_LOOKUP_CB cb, gpointer data); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
34 static char *msim_username_to_set; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
35 |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
36 /** Format the "now playing" indicator, showing the artist and song. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
37 * @return Return a new string (must be g_free()'d), or NULL. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
38 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
39 static gchar * |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
40 msim_format_now_playing(const gchar *band, const gchar *song) |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
41 { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
42 if ((band && *band) || (song && *song)) { |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
43 return g_strdup_printf("%s - %s", |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
44 (band && *band) ? band : "Unknown Artist", |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
45 (song && *song) ? song : "Unknown Song"); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
46 } else { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
47 return NULL; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
48 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
49 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
50 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
51 MsimUser * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
52 msim_get_user_from_buddy(PurpleBuddy *buddy) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
53 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
54 MsimUser *user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
55 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
56 if (!buddy) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
57 return NULL; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
58 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
59 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
60 if (!buddy->proto_data) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
61 /* No MsimUser for this buddy; make one. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
62 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
63 /* TODO: where is this freed? */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
64 user = g_new0(MsimUser, 1); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
65 user->buddy = buddy; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
66 buddy->proto_data = (gpointer)user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
67 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
68 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
69 user = (MsimUser *)(buddy->proto_data); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
70 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
71 return user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
72 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
73 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
74 /** Find and return an MsimUser * representing a user on the buddy list, or NULL. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
75 MsimUser * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
76 msim_find_user(MsimSession *session, const gchar *username) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
77 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
78 PurpleBuddy *buddy; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
79 MsimUser *user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
80 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
81 buddy = purple_find_buddy(session->account, username); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
82 if (!buddy) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
83 return NULL; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
84 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
85 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
86 user = msim_get_user_from_buddy(buddy); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
87 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
88 return user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
89 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
90 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
91 /** Append user information to a PurpleNotifyUserInfo, given an MsimUser. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
92 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
93 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
94 void |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
95 msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
96 { |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
97 PurplePresence *presence; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
98 gchar *str; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
99 guint uid; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
100 guint cv; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
101 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
102 /* Useful to identify the account the tooltip refers to. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
103 * Other prpls show this. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
104 if (user->username) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
105 purple_notify_user_info_add_pair(user_info, _("User"), user->username); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
106 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
107 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
108 uid = purple_blist_node_get_int(&user->buddy->node, "UserID"); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
109 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
110 if (full) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
111 /* TODO: link to username, if available */ |
20982
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
112 if (uid) { |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
113 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>", |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
114 uid, uid); |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
115 purple_notify_user_info_add_pair(user_info, _("Profile"), profile); |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
116 g_free(profile); |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
117 } |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
118 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
119 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
120 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
121 /* a/s/l...the vitals */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
122 if (user->age) { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
123 char age[16]; |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
124 g_snprintf(age, sizeof(age), "%d", user->age); |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
125 purple_notify_user_info_add_pair(user_info, _("Age"), age); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
126 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
127 |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
128 if (user->gender && *user->gender) { |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
129 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
130 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
131 |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
132 if (user->location && *user->location) { |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
133 purple_notify_user_info_add_pair(user_info, _("Location"), user->location); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
134 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
135 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
136 /* Other information */ |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
137 if (user->headline && *user->headline) { |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
138 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
139 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
140 |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
141 presence = purple_buddy_get_presence(user->buddy); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
142 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
143 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
144 PurpleStatus *status; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
145 const char *artist, *title; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
146 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
147 status = purple_presence_get_status(presence, "tune"); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
148 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
149 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
150 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
151 str = msim_format_now_playing(artist, title); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
152 if (str && *str) { |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
153 purple_notify_user_info_add_pair(user_info, _("Song"), str); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
154 } |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
155 g_free(str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
156 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
157 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
158 /* Note: total friends only available if looked up by uid, not username. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
159 if (user->total_friends) { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
160 char friends[16]; |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
161 g_snprintf(friends, sizeof(friends), "%d", user->total_friends); |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
162 purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
163 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
164 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
165 if (full) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
166 /* Client information */ |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
167 char *client = NULL; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
168 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
169 str = user->client_info; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
170 cv = user->client_cv; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
171 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
172 if (str && cv != 0) { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
173 client = g_strdup_printf("%s (build %d)", str, cv); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
174 } else if (str) { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
175 client = g_strdup(str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
176 } else if (cv) { |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
177 client = g_strdup_printf("Build %d", cv); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
178 } |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
179 if (client && *client) |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
180 purple_notify_user_info_add_pair(user_info, _("Client Version"), client); |
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20689
diff
changeset
|
181 g_free(client); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
182 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
183 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
184 |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
185 /** Set the currently playing song artist and or title. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
186 * |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
187 * @param user User associated with the now playing information. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
188 * |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
189 * @param new_artist New artist to set, or NULL/empty to not change artist. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
190 * |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
191 * @param new_title New title to set, or NULL/empty to not change title. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
192 * |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
193 * If new_artist and new_title are NULL/empty, deactivate PURPLE_STATUS_TUNE. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
194 * |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
195 * This function is useful because it lets you set the artist or title |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
196 * individually, which purple_prpl_got_user_status() doesn't do. |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
197 */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
198 static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, const char *new_title) |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
199 { |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
200 PurplePresence *presence; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
201 const char *prev_artist, *prev_title; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
202 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
203 prev_artist = NULL; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
204 prev_title = NULL; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
205 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
206 if (new_artist && !strlen(new_artist)) |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
207 new_artist = NULL; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
208 if (new_title && !strlen(new_title)) |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
209 new_title = NULL; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
210 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
211 if (!new_artist && !new_title) { |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
212 purple_prpl_got_user_status_deactive(user->buddy->account, user->buddy->name, "tune"); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
213 return; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
214 } |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
215 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
216 presence = purple_buddy_get_presence(user->buddy); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
217 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
218 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
219 PurpleStatus *status; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
220 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
221 status = purple_presence_get_status(presence, "tune"); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
222 prev_title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
223 prev_artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
224 } |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
225 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
226 if (!new_artist) |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
227 new_artist = prev_artist; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
228 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
229 if (!new_title) |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
230 new_title = prev_title; |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
231 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
232 purple_prpl_got_user_status(user->buddy->account, user->buddy->name, "tune", |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
233 PURPLE_TUNE_TITLE, new_title, |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
234 PURPLE_TUNE_ARTIST, new_artist, |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
235 NULL); |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
236 } |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
237 |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
238 /** Store a field of information about a buddy. |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
239 * |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
240 * @param key_str Key to store. |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
241 * @param value_str Value string, either user takes ownership of this string |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
242 * or it is freed if MsimUser doesn't store the string. |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
243 * @param user User to store data in. Existing data will be replaced. |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
244 * */ |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
245 void |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
246 msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
247 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
248 if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
249 /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
250 if (user->buddy) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
251 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
252 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
253 purple_blist_node_set_int(&user->buddy->node, "UserID", atol(value_str)); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
254 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
255 /* Need to store in MsimUser, too? What if not on blist? */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
256 } else if (g_str_equal(key_str, "Age")) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
257 user->age = atol(value_str); |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
258 g_free(value_str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
259 } else if (g_str_equal(key_str, "Gender")) { |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
260 g_free(user->gender); |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
261 user->gender = value_str; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
262 } else if (g_str_equal(key_str, "Location")) { |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
263 g_free(user->location); |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
264 user->location = value_str; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
265 } else if (g_str_equal(key_str, "TotalFriends")) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
266 user->total_friends = atol(value_str); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
267 } else if (g_str_equal(key_str, "DisplayName")) { |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
268 g_free(user->display_name); |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
269 user->display_name = value_str; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
270 } else if (g_str_equal(key_str, "BandName")) { |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
271 msim_set_artist_or_title(user, value_str, NULL); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
272 } else if (g_str_equal(key_str, "SongName")) { |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21022
diff
changeset
|
273 msim_set_artist_or_title(user, NULL, value_str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
274 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
275 /* Ignore because PurpleBuddy knows this already */ |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
276 g_free(value_str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
277 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) { |
20995 | 278 const gchar *previous_url; |
279 | |
20982
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
280 if (user->temporary_user) { |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
281 /* This user will be destroyed soon; don't try to look up its image or avatar, |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
282 * since that won't return immediately and we will end up accessing freed data. |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
283 */ |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
284 g_free(value_str); |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
285 return; |
aee8d876fed1
When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents:
20753
diff
changeset
|
286 } |
21022 | 287 |
288 if (user->temporary_user) { | |
289 /* This user will be destroyed soon; don't try to look up its image or avatar, | |
290 * since that won't return immediately and we will end up accessing freed data. | |
291 */ | |
292 g_free(value_str); | |
293 return; | |
294 } | |
295 | |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
296 g_free(user->image_url); |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
297 |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
298 user->image_url = value_str; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
299 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
300 /* Instead of showing 'no photo' picture, show nothing. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
301 if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif")) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
302 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
303 purple_buddy_icons_set_for_user(user->buddy->account, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
304 user->buddy->name, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
305 NULL, 0, NULL); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
306 return; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
307 } |
21022 | 308 |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
309 /* TODO: use ETag for checksum */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
310 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
311 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
312 /* Only download if URL changed */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
313 if (!previous_url || !g_str_equal(previous_url, user->image_url)) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
314 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
315 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
316 } else if (g_str_equal(key_str, "LastImageUpdated")) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
317 /* TODO: use somewhere */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
318 user->last_image_updated = atol(value_str); |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
319 g_free(value_str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
320 } else if (g_str_equal(key_str, "Headline")) { |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
321 g_free(user->headline); |
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
322 user->headline = value_str; |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
323 } else { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
324 /* TODO: other fields in MsimUser */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
325 gchar *msg; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
326 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
327 msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s", |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
328 key_str, value_str); |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
329 g_free(value_str); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
330 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
331 msim_unrecognized(NULL, NULL, msg); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
332 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
333 g_free(msg); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
334 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
335 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
336 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
337 /** Save buddy information to the buddy list from a user info reply message. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
338 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
339 * @param session |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
340 * @param msg The user information reply, with any amount of information. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
341 * @param user The structure to save to, or NULL to save in PurpleBuddy->proto_data. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
342 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
343 * Variable information is saved to the passed MsimUser structure. Permanent |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
344 * information (UserID) is stored in the blist node of the buddy list (and |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
345 * ends up in blist.xml, persisted to disk) if it exists. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
346 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
347 * If the function has no buddy information, this function |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
348 * is a no-op (and returns FALSE). |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
349 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
350 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
351 gboolean |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
352 msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
353 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
354 gchar *username; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
355 MsimMessage *body, *body_node; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
356 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
357 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
358 g_return_val_if_fail(msg != NULL, FALSE); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
359 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
360 body = msim_msg_get_dictionary(msg, "body"); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
361 if (!body) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
362 return FALSE; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
363 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
364 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
365 username = msim_msg_get_string(body, "UserName"); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
366 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
367 if (!username) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
368 purple_debug_info("msim", |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
369 "msim_process_reply: not caching body, no UserName\n"); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
370 msim_msg_free(body); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
371 g_free(username); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
372 return FALSE; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
373 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
374 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
375 /* Null user = find and store in PurpleBuddy's proto_data */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
376 if (!user) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
377 user = msim_find_user(session, username); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
378 if (!user) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
379 msim_msg_free(body); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
380 g_free(username); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
381 return FALSE; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
382 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
383 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
384 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
385 /* TODO: make looping over MsimMessage's easier. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
386 for (body_node = body; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
387 body_node != NULL; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
388 body_node = msim_msg_get_next_element_node(body_node)) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
389 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
390 const gchar *key_str; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
391 gchar *value_str; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
392 MsimMessageElement *elem; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
393 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
394 elem = (MsimMessageElement *)body_node->data; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
395 key_str = elem->name; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
396 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
397 value_str = msim_msg_get_string_from_element(elem); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
398 msim_store_user_info_each(key_str, value_str, user); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
399 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
400 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
401 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN && |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
402 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
403 /* TODO: do something with our own IM info, if we need it for some |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
404 * specific purpose. Otherwise it is available on the buddy list, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
405 * if the user has themselves as their own buddy. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
406 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
407 * However, much of the info is already available in MsimSession, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
408 * stored in msim_we_are_logged_on(). */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
409 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN && |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
410 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
411 /* TODO: same as above, but for MySpace info. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
412 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
413 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
414 msim_msg_free(body); |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20147
diff
changeset
|
415 g_free(username); |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
416 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
417 return TRUE; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
418 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
419 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
420 /** |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
421 * Asynchronously lookup user information, calling callback when receive result. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
422 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
423 * @param session |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
424 * @param user The user id, email address, or username. Not freed. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
425 * @param cb Callback, called with user information when available. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
426 * @param data An arbitray data pointer passed to the callback. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
427 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
428 /* TODO: change to not use callbacks */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
429 void |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
430 msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
431 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
432 MsimMessage *body; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
433 gchar *field_name; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
434 guint rid, cmd, dsn, lid; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
435 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
436 g_return_if_fail(MSIM_SESSION_VALID(session)); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
437 g_return_if_fail(user != NULL); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
438 /* Callback can be null to not call anything, just lookup & store information. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
439 /*g_return_if_fail(cb != NULL);*/ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
440 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
441 purple_debug_info("msim", "msim_lookup_userid: " |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
442 "asynchronously looking up <%s>\n", user); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
443 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
444 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
445 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
446 /* Setup callback. Response will be associated with request using 'rid'. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
447 rid = msim_new_reply_callback(session, cb, data); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
448 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
449 /* Send request */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
450 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
451 cmd = MSIM_CMD_GET; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
452 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
453 if (msim_is_userid(user)) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
454 field_name = "UserID"; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
455 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
456 lid = MG_MYSPACE_INFO_BY_ID_LID; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
457 } else if (msim_is_email(user)) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
458 field_name = "Email"; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
459 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
460 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
461 } else { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
462 field_name = "UserName"; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
463 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
464 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
465 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
466 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
467 body = msim_msg_new( |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
468 field_name, MSIM_TYPE_STRING, g_strdup(user), |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
469 NULL); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
470 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
471 g_return_if_fail(msim_send(session, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
472 "persist", MSIM_TYPE_INTEGER, 1, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
473 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
474 "cmd", MSIM_TYPE_INTEGER, 1, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
475 "dsn", MSIM_TYPE_INTEGER, dsn, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
476 "uid", MSIM_TYPE_INTEGER, session->userid, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
477 "lid", MSIM_TYPE_INTEGER, lid, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
478 "rid", MSIM_TYPE_INTEGER, rid, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
479 "body", MSIM_TYPE_DICTIONARY, body, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
480 NULL)); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
481 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
482 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
483 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
484 /** |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
485 * Check if a string is a userid (all numeric). |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
486 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
487 * @param user The user id, email, or name. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
488 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
489 * @return TRUE if is userid, FALSE if not. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
490 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
491 gboolean |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
492 msim_is_userid(const gchar *user) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
493 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
494 g_return_val_if_fail(user != NULL, FALSE); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
495 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
496 return strspn(user, "0123456789") == strlen(user); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
497 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
498 |
22305
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
499 /** Return whether a given username is syntactically valid. |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
500 * Note: does not actually check that the user exists. */ |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
501 gboolean |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
502 msim_is_valid_username(const gchar *user) |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
503 { |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
504 return !msim_is_userid(user) && /* Not all numeric */ |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
505 strlen(user) <= MSIM_MAX_USERNAME_LENGTH |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
506 && strspn(user, "0123456789" |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
507 "abcdefghijklmnopqrstuvwxyz" |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
508 "_" |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
509 "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user); |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
510 } |
bf4902fce6e4
In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22304
diff
changeset
|
511 |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
512 /** |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
513 * Check if a string is an email address (contains an @). |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
514 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
515 * @param user The user id, email, or name. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
516 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
517 * @return TRUE if is an email, FALSE if not. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
518 * |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
519 * This function is not intended to be used as a generic |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
520 * means of validating email addresses, but to distinguish |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
521 * between a user represented by an email address from |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
522 * other forms of identification. |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
523 */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
524 gboolean |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
525 msim_is_email(const gchar *user) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
526 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
527 g_return_val_if_fail(user != NULL, FALSE); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
528 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
529 return strchr(user, '@') != NULL; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
530 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
531 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
532 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
533 /** Callback for when a buddy icon finished being downloaded. */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
534 static void |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
535 msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
536 gpointer user_data, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
537 const gchar *url_text, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
538 gsize len, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
539 const gchar *error_message) |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
540 { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
541 MsimUser *user; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
542 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
543 user = (MsimUser *)user_data; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
544 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
545 purple_debug_info("msim_downloaded_buddy_icon", |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
546 "Downloaded %d bytes\n", len); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
547 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
548 if (!url_text) { |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
549 purple_debug_info("msim_downloaded_buddy_icon", |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
550 "failed to download icon for %s", |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
551 user->buddy->name); |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
552 return; |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
553 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
554 |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
555 purple_buddy_icons_set_for_user(user->buddy->account, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
556 user->buddy->name, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
557 g_memdup((gchar *)url_text, len), len, |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
558 /* Use URL itself as buddy icon "checksum" (TODO: ETag) */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
559 user->image_url); /* checksum */ |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
560 } |
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
561 |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
562 /*** |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
563 * If they hit cancel or no at any point in the Setting Username process, we come here. * |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
564 * Currently.. We're safe letting them get by without setting it.. Unless we hear otherwise.. * |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
565 * So for now, give them a menu.. If this becomes an issue with the Official client.. boot them here */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
566 void msim_do_not_set_username_cb(PurpleConnection *gc) { |
22306
7d0e93198c39
If the user sets a username (because they don't have one), and it succeeds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22305
diff
changeset
|
567 purple_debug_info("msim", "Don't set username"); |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
568 |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
569 /* Protocol won't log in now without a username set.. Disconnect */ |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
570 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set")); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
571 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
572 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
573 /** They've decided to set a username! Yay! */ |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
574 void msim_set_username_cb(PurpleConnection *gc) { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
575 g_return_if_fail(gc != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
576 purple_debug_info("msim","Set username\n"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
577 purple_request_input(gc, _("MySpaceIM - Please Set a Username"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
578 _("Please enter a username to check its availability:"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
579 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
580 "", FALSE, FALSE, NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
581 _("OK"), G_CALLBACK(msim_check_username_availability_cb), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
582 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
583 purple_connection_get_account(gc), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
584 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
585 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
586 gc); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
587 } |
20257
1141d47b162c
Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
588 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
589 /** Once they've submitted their desired new username, |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
590 * check if it is available here. */ |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
591 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check) |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
592 { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
593 MsimMessage *user_msg; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
594 MsimSession *session; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
595 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
596 g_return_if_fail(gc != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
597 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
598 session = (MsimSession *)gc->proto_data; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
599 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
600 g_return_if_fail(MSIM_SESSION_VALID(session)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
601 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
602 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
603 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
604 user_msg = msim_msg_new( |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
605 "user", MSIM_TYPE_STRING, g_strdup(username_to_check), |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
606 NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
607 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
608 /* 25 characters: letters, numbers, underscores */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
609 /* TODO: VERIFY ABOVE */ |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
610 |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
611 /* \persist\1\sesskey\288500516\cmd\1\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=Jaywalker\final\ */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
612 /* Official client uses a standard lookup... So do we! */ |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
613 msim_lookup_user(session, username_to_check, msim_username_is_available_cb, user_msg); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
614 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
615 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
616 /** This is where we do a bit more than merely prompt the user. |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
617 * Now we have some real data to tell us the state of their requested username |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
618 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\ */ |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
619 static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
620 { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
621 MsimMessage *msg; |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
622 gchar *username; |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
623 MsimMessage *body; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
624 gint userid; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
625 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
626 purple_debug_info("msim_username_is_available_cb", "Look up username callback made\n"); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
627 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
628 msg = (MsimMessage *)data; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
629 g_return_if_fail(MSIM_SESSION_VALID(session)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
630 g_return_if_fail(msg != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
631 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
632 username = msim_msg_get_string(msg, "user"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
633 body = msim_msg_get_dictionary(userinfo, "body"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
634 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
635 if (!body) { |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
636 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username); |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
637 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
638 "An error occured while trying to set the username.\n" |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
639 "Please try again, or visit http://editprofile.myspace.com/index.cfm?" |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
640 "fuseaction=profile.username to set your username."); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
641 return; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
642 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
643 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
644 userid = msim_msg_get_integer(body, "UserID"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
645 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
646 purple_debug_info("msim_username_is_available_cb", "Returned username is %s and userid is %d\n", username, userid); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
647 msim_msg_free(body); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
648 msim_msg_free(msg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
649 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
650 /* The response for a free username will ONLY have the UserName in it.. |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
651 * thus making UserID return 0 when we msg_get_integer it */ |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
652 if (userid == 0) { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
653 /* This username is currently unused */ |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
654 purple_debug_info("msim_username_is_available_cb", "Username available. Prompting to Confirm.\n"); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
655 msim_username_to_set = g_strdup(username); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
656 g_free(username); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
657 purple_request_yes_no(session->gc, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
658 _("MySpaceIM - Username Available"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
659 _("This username is available. Would you like to set it?"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
660 _("ONCE SET, THIS CANNOT BE CHANGED!"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
661 0, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
662 session->account, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
663 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
664 NULL, |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
665 session->gc, |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
666 G_CALLBACK(msim_set_username_confirmed_cb), |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
667 G_CALLBACK(msim_do_not_set_username_cb)); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
668 } else { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
669 /* Looks like its in use or we have an invalid response */ |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
670 purple_debug_info("msim_username_is_available_cb", "Username unavaiable. Prompting for new entry.\n"); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
671 purple_request_input(session->gc, _("MySpaceIM - Please Set a Username"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
672 _("This username is unavailable."), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
673 _("Please try another username:"), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
674 "", FALSE, FALSE, NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
675 _("OK"), G_CALLBACK(msim_check_username_availability_cb), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
676 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
677 session->account, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
678 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
679 NULL, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
680 session->gc); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
681 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
682 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
683 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
684 /* They've confirmed that username that was available, Lets make the call to set it */ |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
685 static void msim_set_username_confirmed_cb(PurpleConnection *gc) |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
686 { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
687 MsimMessage *user_msg; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
688 MsimSession *session; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
689 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
690 g_return_if_fail(gc != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
691 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
692 session = (MsimSession *)gc->proto_data; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
693 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
694 g_return_if_fail(MSIM_SESSION_VALID(session)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
695 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
696 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
697 user_msg = msim_msg_new( |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
698 "user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set), |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
699 NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
700 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
701 purple_debug_info("msim_set_username_confirmed_cb", "Setting username to %s\n", msim_username_to_set); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
702 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
703 /* Sets our username... keep your fingers crossed :) */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
704 msim_set_username(session, msim_username_to_set, msim_username_is_set_cb, user_msg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
705 g_free(msim_username_to_set); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
706 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
707 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
708 /** |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
709 * Asynchronously set new username, calling callback when receive result. |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
710 * |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
711 * @param session |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
712 * @param username The username we're setting for ourselves. Not freed. |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
713 * @param cb Callback, called with user information when available. |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
714 * @param data An arbitray data pointer passed to the callback. |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
715 */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
716 static void |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
717 msim_set_username(MsimSession *session, const gchar *username, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
718 MSIM_USER_LOOKUP_CB cb, gpointer data) |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
719 { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
720 MsimMessage *body; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
721 guint rid; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
722 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
723 g_return_if_fail(MSIM_SESSION_VALID(session)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
724 g_return_if_fail(username != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
725 g_return_if_fail(cb != NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
726 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
727 purple_debug_info("msim", "msim_set_username: " |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
728 "Setting username %s\n", username); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
729 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
730 msim_msg_dump("msim_set_username: data=%s\n", (MsimMessage *)data); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
731 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
732 /* Setup callback. Response will be associated with request using 'rid'. */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
733 rid = msim_new_reply_callback(session, cb, data); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
734 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
735 /* TODO: I dont know if the ContactType is -/ALWAYS/- 1 */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
736 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
737 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username),NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
738 /* \setinfo\\sesskey\469958979\info\Age=21.AvatarUrl=.BandName=.ContactType=1.DisplayName=Msim.Gender=M.ImageURL=http:/1/1x.myspace.com/1images/1no_pic.gif.LastLogin=128335268400000000.Location=US.ShowAvatar=False.SongName=.TotalFriends=1.UserName=msimprpl2\final\ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
739 */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
740 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
741 /* Send request */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
742 g_return_if_fail(msim_send(session, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
743 "setinfo", MSIM_TYPE_BOOLEAN, TRUE, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
744 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
745 "info", MSIM_TYPE_DICTIONARY, body, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
746 NULL)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
747 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username),NULL); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
748 g_return_if_fail(msim_send(session, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
749 "persist", MSIM_TYPE_INTEGER, 1, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
750 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
751 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
752 "dsn", MSIM_TYPE_INTEGER, MG_MYSPACE_INFO_BY_STRING_DSN, |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
753 "uid", MSIM_TYPE_INTEGER, session->userid, |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
754 "lid", MSIM_TYPE_INTEGER, MG_MYSPACE_INFO_BY_STRING_LID, |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
755 "rid", MSIM_TYPE_INTEGER, rid, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
756 "body", MSIM_TYPE_DICTIONARY, body, |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
757 NULL)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
758 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
759 |
22303
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
760 /** Called after username is set. */ |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
761 static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22302
diff
changeset
|
762 { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
763 gchar *username, *errmsg; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
764 MsimMessage *body; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
765 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
766 guint rid; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
767 gint cmd,dsn,uid,lid,code; |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
768 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\final\ */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
769 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
770 purple_debug_info("msim","username_is_set made\n"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
771 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
772 g_return_if_fail(MSIM_SESSION_VALID(session)); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
773 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
774 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
775 msim_msg_dump("username_is_set message is: %s\n", userinfo); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
776 cmd = msim_msg_get_integer(userinfo, "cmd"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
777 dsn = msim_msg_get_integer(userinfo, "dsn"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
778 uid = msim_msg_get_integer(userinfo, "uid"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
779 lid = msim_msg_get_integer(userinfo, "lid"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
780 body = msim_msg_get_dictionary(userinfo, "body"); |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
781 errmsg = g_strdup("An error occured while trying to set the username.\n" |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
782 "Please try again, or visit http://editprofile.myspace.com/index.cfm?" |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
783 "fuseaction=profile.username to set your username."); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
784 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
785 if (!body) { |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
786 purple_debug_info("msim_username_is_set_cb", "No body"); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
787 /* Error: No body! */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
788 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
789 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
790 username = msim_msg_get_string(body, "UserName"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
791 code = msim_msg_get_integer(body,"Code"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
792 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
793 msim_msg_free(body); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
794 |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
795 purple_debug_info("msim_username_is_set_cb", |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
796 "cmd = %d, dsn = %d, lid = %d, code = %d, username = %s\n", |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
797 cmd, dsn, lid, code, username); |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
798 |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
799 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_PUT) |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
800 && dsn == MC_SET_USERNAME_DSN |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
801 && lid == MC_SET_USERNAME_LID) { |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
802 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n"); |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
803 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",code); |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
804 if (code == 0) { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
805 /* Good! */ |
22306
7d0e93198c39
If the user sets a username (because they don't have one), and it succeeds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22305
diff
changeset
|
806 session->username = username; |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
807 msim_we_are_logged_on(session); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
808 } else { |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
809 purple_debug_info("msim_username_is_set", "code is %d",code); |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
810 /* TODO: what to do here? */ |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
811 } |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
812 } else if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET) |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
813 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
814 && lid == MG_MYSPACE_INFO_BY_STRING_LID) { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
815 /* Not quite done... ONE MORE STEP :) */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
816 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data); |
22306
7d0e93198c39
If the user sets a username (because they don't have one), and it succeeds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22305
diff
changeset
|
817 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username), NULL); |
22304
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
818 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
819 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
820 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
821 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
822 "uid", MSIM_TYPE_INTEGER, session->userid, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
823 "lid", MSIM_TYPE_INTEGER, MC_SET_USERNAME_LID, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
824 "rid", MSIM_TYPE_INTEGER, rid, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
825 "body", MSIM_TYPE_DICTIONARY, body, |
c3dc9e0d2c08
In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22303
diff
changeset
|
826 NULL)) { |
22302
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
827 /* Error! */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
828 /* Can't set... Disconnect */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
829 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
830 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
831 |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
832 } else { |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
833 /* Error! */ |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
834 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination"); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
835 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
836 } |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
837 g_free(errmsg); |
0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22264
diff
changeset
|
838 } |