annotate libpurple/protocols/myspace/user.c @ 29353:94a88e5bd3fc

Simplify
author Mark Doliner <mark@kingant.net>
date Thu, 04 Feb 2010 02:17:38 +0000
parents 10df4b6b149c
children 86ee7772936f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
1 /* MySpaceIM Protocol Plugin, header file
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
2 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im>
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
4 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
5 * This program is free software; you can redistribute it and/or modify
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
6 * it under the terms of the GNU General Public License as published by
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
8 * (at your option) any later version.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
9 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
10 * This program is distributed in the hope that it will be useful,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
13 * GNU General Public License for more details.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
14 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
15 * You should have received a copy of the GNU General Public License
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
16 * along with this program; if not, write to the Free Software
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
18 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
19
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
20 #include "myspace.h"
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
21
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
22 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
23
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
24 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
25
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
26 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
27 * Format the "now playing" indicator, showing the artist and song.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
28 *
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
29 * @return Return a new string (must be g_free()'d), or NULL.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
30 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
31 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
32 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: 19680
diff changeset
33 {
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
34 if ((band && *band) || (song && *song)) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
35 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
36 (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
37 (song && *song) ? song : "Unknown Song");
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
38 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
39 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
40 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
41 }
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
42
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
43 /**
25005
401f548e3544 propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f)
Paul Aurich <paul@darkrain42.org>
parents: 24509 24770
diff changeset
44 * Get the MsimUser from a PurpleBuddy, optionally creating it if needed.
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
45 */
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
46 MsimUser *
24509
125cac3e24ee The Add Buddy dialog should not blindly create a duplicate buddy in a group
Paul Aurich <paul@darkrain42.org>
parents: 23376
diff changeset
47 msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create)
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
48 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
49 MsimUser *user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
50
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
51 if (!buddy) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
52 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
53 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
54
25465
9ea3474065dc propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
Paul Aurich <paul@darkrain42.org>
parents: 25382 25011
diff changeset
55 user = purple_buddy_get_protocol_data(buddy);
9ea3474065dc propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
Paul Aurich <paul@darkrain42.org>
parents: 25382 25011
diff changeset
56 if (create && !user) {
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
57 /* No MsimUser for this buddy; make one. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
58
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
59 user = g_new0(MsimUser, 1);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
60 user->buddy = buddy;
27234
324cc0d6ca0a As far as I can tell this line was accidentally removed in an explicit merge
Mark Doliner <mark@kingant.net>
parents: 25465
diff changeset
61 user->id = purple_blist_node_get_int(&buddy->node, "UserID");
25368
1260a3fb60f4 propagate from branch 'im.pidgin.pidgin' (head b8d6086aef6b2e65d86e8ce60220ab7f460d5079)
Richard Laager <rlaager@wiktel.com>
parents: 24632 25290
diff changeset
62 purple_buddy_set_protocol_data(buddy, user);
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
63 }
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
64
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
65 return user;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
66 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
67
24853
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
68 void msim_user_free(MsimUser *user)
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
69 {
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
70 if (!user)
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
71 return;
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
72
29191
10df4b6b149c Two changes:
Mark Doliner <mark@kingant.net>
parents: 29187
diff changeset
73 if (user->url_data != NULL)
10df4b6b149c Two changes:
Mark Doliner <mark@kingant.net>
parents: 29187
diff changeset
74 purple_util_fetch_url_cancel(user->url_data);
29187
57612c4d495b Fix a crash when disconnecting with a pending buddy icon fetch request.
Mark Doliner <mark@kingant.net>
parents: 27463
diff changeset
75
24853
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
76 g_free(user->client_info);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
77 g_free(user->gender);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
78 g_free(user->location);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
79 g_free(user->headline);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
80 g_free(user->display_name);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
81 g_free(user->username);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
82 g_free(user->band_name);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
83 g_free(user->song_name);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
84 g_free(user->image_url);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
85 g_free(user);
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
86 }
c6cadb7bdcf7 A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24832
diff changeset
87
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
88 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
89 * Find and return an MsimUser * representing a user on the buddy list, or NULL.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
90 */
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
91 MsimUser *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
92 msim_find_user(MsimSession *session, const gchar *username)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
93 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
94 PurpleBuddy *buddy;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
95
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
96 buddy = purple_find_buddy(session->account, username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
97 if (!buddy) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
98 return NULL;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
99 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
100
29353
94a88e5bd3fc Simplify
Mark Doliner <mark@kingant.net>
parents: 29191
diff changeset
101 return msim_get_user_from_buddy(buddy, TRUE);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
102 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
103
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
104 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
105 * Append user information to a PurpleNotifyUserInfo, given an MsimUser.
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
106 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
107 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
108 void
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
109 msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
110 {
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
111 PurplePresence *presence;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
112 gchar *str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
113 guint cv;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
114
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
115 /* Useful to identify the account the tooltip refers to.
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
116 * Other prpls show this. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
117 if (user->username) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
118 purple_notify_user_info_add_pair(user_info, _("User"), user->username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
119 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
120
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
121 /* a/s/l...the vitals */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
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: 19680
diff changeset
126 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
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: 19680
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: 19680
diff changeset
130 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
131
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: 19680
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: 19680
diff changeset
134 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
135
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
136 /* 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: 19680
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: 19680
diff changeset
139 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
140
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
141 if (user->buddy != NULL) {
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
142 presence = purple_buddy_get_presence(user->buddy);
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
143
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
144 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
145 PurpleStatus *status;
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
146 const char *artist, *title;
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
147
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
148 status = purple_presence_get_status(presence, "tune");
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
149 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
150 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
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
151
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
152 str = msim_format_now_playing(artist, title);
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
153 if (str && *str) {
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
154 purple_notify_user_info_add_pair(user_info, _("Song"), str);
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
155 }
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
156 g_free(str);
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
157 }
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
158 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
159
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
160 /* Note: total friends only available if looked up by uid, not username. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
161 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
162 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
163 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
164 purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
165 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
166
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
167 if (full) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
168 /* 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
169 char *client = NULL;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
170
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
171 str = user->client_info;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
172 cv = user->client_cv;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
173
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
174 if (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
175 client = g_strdup_printf("%s (build %d)", str, cv);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
176 } 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
177 client = g_strdup(str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
178 } 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
179 client = g_strdup_printf("Build %d", cv);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
180 }
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
181 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
182 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
183 g_free(client);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
184 }
24615
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
185
24632
128a77f3b3c4 Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <mark@kingant.net>
parents: 24631
diff changeset
186 if (full && user->id) {
24615
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
187 /* TODO: link to username, if available */
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
188 char *profile;
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
189 purple_notify_user_info_add_section_break(user_info);
24726
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
190 if (user->buddy != NULL)
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
191 profile = g_strdup_printf("<a href=\"http://myspace.com/%s\">%s</a>",
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
192 purple_buddy_get_name(user->buddy), _("View web profile"));
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
193 else
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
194 profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>",
694591875bc9 Use the friendly/vanity url when it's available in myspace
Mark Doliner <mark@kingant.net>
parents: 24632
diff changeset
195 user->id, _("View web profile"));
24615
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
196 purple_notify_user_info_add_pair(user_info, NULL, profile);
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
197 g_free(profile);
9fc3f5bf4455 Make our profile text a little cleaner and more uniform across the protocols.
Mark Doliner <mark@kingant.net>
parents: 23376
diff changeset
198 }
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
199 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
200
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
201 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
202 * Callback for when a buddy icon finished being downloaded.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
203 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
204 static void
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
205 msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
206 gpointer user_data,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
207 const gchar *url_text,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
208 gsize len,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
209 const gchar *error_message)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
210 {
25374
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
211 MsimUser *user = (MsimUser *)user_data;
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
212 const char *name = purple_buddy_get_name(user->buddy);
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
213 PurpleAccount *account;
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
214
29187
57612c4d495b Fix a crash when disconnecting with a pending buddy icon fetch request.
Mark Doliner <mark@kingant.net>
parents: 27463
diff changeset
215 user->url_data = NULL;
57612c4d495b Fix a crash when disconnecting with a pending buddy icon fetch request.
Mark Doliner <mark@kingant.net>
parents: 27463
diff changeset
216
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
217 purple_debug_info("msim_downloaded_buddy_icon",
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
218 "Downloaded %" G_GSIZE_FORMAT " bytes\n", len);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
219
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
220 if (!url_text) {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
221 purple_debug_info("msim_downloaded_buddy_icon",
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
222 "failed to download icon for %s",
25374
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
223 name);
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
224 return;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
225 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
226
25374
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
227 account = purple_buddy_get_account(user->buddy);
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
228 purple_buddy_icons_set_for_user(account, name,
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
229 g_memdup((gchar *)url_text, len), len,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
230 /* Use URL itself as buddy icon "checksum" (TODO: ETag) */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
231 user->image_url); /* checksum */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
232 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
233
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
234 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
235 * Set the currently playing song artist and or title.
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
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 * @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
238 *
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
239 * @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
240 *
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
241 * @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
242 *
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
243 * 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
244 *
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
245 * 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
246 * 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
247 */
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
248 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
249 {
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
250 PurplePresence *presence;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
251 PurpleAccount *account;
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
252 const char *prev_artist, *prev_title;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
253 const char *name;
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
254
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
255 if (user->buddy == NULL)
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
256 /* User not on buddy list so nothing to do */
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
257 return;
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
258
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
259 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
260 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
261
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
262 if (new_artist && !*new_artist)
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
263 new_artist = NULL;
24631
1af3baa61c9f Don't create a temporary PurpleBuddy when getting info for someone not
Mark Doliner <mark@kingant.net>
parents: 24615
diff changeset
264 if (new_title && !*new_title)
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
265 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
266
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
267 account = purple_buddy_get_account(user->buddy);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
268 name = purple_buddy_get_name(user->buddy);
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
269
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
270 if (!new_artist && !new_title) {
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
271 purple_prpl_got_user_status_deactive(account, name, "tune");
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
272 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
273 }
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
274
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
275 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
276
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
277 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
278 PurpleStatus *status;
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
279
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
280 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
281 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
282 prev_artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
283 }
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
284
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
285 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
286 new_artist = prev_artist;
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
287
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
288 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
289 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
290
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
291 purple_prpl_got_user_status(account, name, "tune",
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
292 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
293 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
294 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
295 }
e808d83d797e In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21022
diff changeset
296
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
297 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
298 * Store a field of information about a buddy.
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
299 *
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
300 * @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
301 * @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
302 * 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
303 * @param user User to store data in. Existing data will be replaced.
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
304 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
305 static void
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
306 msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
307 {
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
308 const char *name = user->buddy ? purple_buddy_get_name(user->buddy) : NULL;
25374
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
309
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
310 if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
311 /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */
24632
128a77f3b3c4 Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <mark@kingant.net>
parents: 24631
diff changeset
312 user->id = atol(value_str);
24770
22fd7467f0cc Fix a few small memleaks
Mark Doliner <mark@kingant.net>
parents: 24764
diff changeset
313 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
314 if (user->buddy)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
315 {
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
316 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, name);
25374
e22bc87b758b explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
Richard Laager <rlaager@wiktel.com>
parents: 24731 25373
diff changeset
317 purple_blist_node_set_int(PURPLE_BLIST_NODE(user->buddy), "UserID", user->id);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
318 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
319 /* Need to store in MsimUser, too? What if not on blist? */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
320 } else if (g_str_equal(key_str, "Age")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
321 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
322 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
323 } 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
324 g_free(user->gender);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
325 user->gender = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
326 } 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
327 g_free(user->location);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
328 user->location = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
329 } else if (g_str_equal(key_str, "TotalFriends")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
330 user->total_friends = atol(value_str);
24770
22fd7467f0cc Fix a few small memleaks
Mark Doliner <mark@kingant.net>
parents: 24764
diff changeset
331 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
332 } 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
333 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
334 user->display_name = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
335 } 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
336 msim_set_artist_or_title(user, value_str, NULL);
24770
22fd7467f0cc Fix a few small memleaks
Mark Doliner <mark@kingant.net>
parents: 24764
diff changeset
337 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
338 } 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
339 msim_set_artist_or_title(user, NULL, value_str);
24770
22fd7467f0cc Fix a few small memleaks
Mark Doliner <mark@kingant.net>
parents: 24764
diff changeset
340 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
341 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
342 /* 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
343 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
344 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) {
20995
87c9d114864b Fix a warning
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
345 const gchar *previous_url;
87c9d114864b Fix a warning
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
346
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
347 if (user->temporary_user) {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
348 /* This user will be destroyed soon; don't try to look up its image or avatar,
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
349 * 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
350 */
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
351 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
352 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
353 }
21022
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
354
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
355 if (user->temporary_user) {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
356 /* This user will be destroyed soon; don't try to look up its image or avatar,
21022
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
357 * since that won't return immediately and we will end up accessing freed data.
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
358 */
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
359 g_free(value_str);
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
360 return;
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
361 }
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
362
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
363 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
364
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
365 user->image_url = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
366
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
367 /* Instead of showing 'no photo' picture, show nothing. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
368 if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif"))
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
369 {
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
370 purple_buddy_icons_set_for_user(purple_buddy_get_account(user->buddy),
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23376
diff changeset
371 name, NULL, 0, NULL);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
372 return;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
373 }
21022
3f8b32a4786c Fix this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
374
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
375 /* TODO: use ETag for checksum */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
376 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
377
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
378 /* Only download if URL changed */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
379 if (!previous_url || !g_str_equal(previous_url, user->image_url)) {
29191
10df4b6b149c Two changes:
Mark Doliner <mark@kingant.net>
parents: 29187
diff changeset
380 if (user->url_data != NULL)
10df4b6b149c Two changes:
Mark Doliner <mark@kingant.net>
parents: 29187
diff changeset
381 purple_util_fetch_url_cancel(user->url_data);
29187
57612c4d495b Fix a crash when disconnecting with a pending buddy icon fetch request.
Mark Doliner <mark@kingant.net>
parents: 27463
diff changeset
382 user->url_data = purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
383 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
384 } else if (g_str_equal(key_str, "LastImageUpdated")) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
385 /* TODO: use somewhere */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
386 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
387 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
388 } 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
389 g_free(user->headline);
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20147
diff changeset
390 user->headline = value_str;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
391 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
392 /* TODO: other fields in MsimUser */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
393 gchar *msg;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
394
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
395 msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s",
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
396 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
397 g_free(value_str);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
398
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
399 msim_unrecognized(NULL, NULL, msg);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
400
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
401 g_free(msg);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
402 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
403 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
404
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
405 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
406 * Save buddy information to the buddy list from a user info reply message.
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
407 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
408 * @param session
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
409 * @param msg The user information reply, with any amount of information.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
410 * @param user The structure to save to, or NULL to save in PurpleBuddy->proto_data.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
411 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
412 * Variable information is saved to the passed MsimUser structure. Permanent
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
413 * information (UserID) is stored in the blist node of the buddy list (and
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
414 * ends up in blist.xml, persisted to disk) if it exists.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
415 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
416 * If the function has no buddy information, this function
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
417 * is a no-op (and returns FALSE).
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
418 */
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
419 gboolean
24764
c044eb54b7ac Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24746
diff changeset
420 msim_store_user_info(MsimSession *session, const MsimMessage *msg, MsimUser *user)
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
421 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
422 gchar *username;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
423 MsimMessage *body, *body_node;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
424
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
425 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
426 g_return_val_if_fail(msg != NULL, FALSE);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
427
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
428 body = msim_msg_get_dictionary(msg, "body");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
429 if (!body) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
430 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
431 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
432
24746
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
433 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN &&
24827
a9b4599a5367 Fix a typo in a comment
Mark Doliner <mark@kingant.net>
parents: 24770
diff changeset
434 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID)
a9b4599a5367 Fix a typo in a comment
Mark Doliner <mark@kingant.net>
parents: 24770
diff changeset
435 {
24746
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
436 /*
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
437 * Some of this info will be available on the buddy list if the
24827
a9b4599a5367 Fix a typo in a comment
Mark Doliner <mark@kingant.net>
parents: 24770
diff changeset
438 * user has themselves as their own buddy.
24746
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
439 *
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
440 * Much of the info is already available in MsimSession,
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
441 * stored in msim_we_are_logged_on().
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
442 */
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
443 gchar *tmpstr;
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
444
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
445 tmpstr = msim_msg_get_string(body, "ShowOnlyToList");
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
446 if (tmpstr != NULL) {
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
447 session->show_only_to_list = g_str_equal(tmpstr, "True");
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
448 g_free(tmpstr);
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
449 }
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
450
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
451 session->privacy_mode = msim_msg_get_integer(body, "PrivacyMode");
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
452 session->offline_message_mode = msim_msg_get_integer(body, "OfflineMessageMode");
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
453
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
454 msim_send(session,
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
455 "blocklist", MSIM_TYPE_BOOLEAN, TRUE,
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
456 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
457 "idlist", MSIM_TYPE_STRING,
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
458 g_strdup_printf("w%d|c%d",
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
459 session->show_only_to_list ? 1 : 0,
24832
1d77f138847b This is a bitmask, and the "c" value here should be the least significant
Mark Doliner <mark@kingant.net>
parents: 24827
diff changeset
460 session->privacy_mode & 1),
24746
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
461 NULL);
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
462 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN &&
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
463 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) {
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
464 /* TODO: same as above, but for MySpace info. */
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
465 }
8e75a1525156 Grab the "Who can contact me? Only people on my buddy list?" and the
Mark Doliner <mark@kingant.net>
parents: 24743
diff changeset
466
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
467 username = msim_msg_get_string(body, "UserName");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
468
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
469 if (!username) {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
470 purple_debug_info("msim",
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
471 "msim_process_reply: not caching body, no UserName\n");
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
472 msim_msg_free(body);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
473 g_free(username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
474 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
475 }
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
476
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
477 /* Null user = find and store in PurpleBuddy's proto_data */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
478 if (!user) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
479 user = msim_find_user(session, username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
480 if (!user) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
481 msim_msg_free(body);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
482 g_free(username);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
483 return FALSE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
484 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
485 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
486
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
487 /* TODO: make looping over MsimMessage's easier. */
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
488 for (body_node = body;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
489 body_node != NULL;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
490 body_node = msim_msg_get_next_element_node(body_node))
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
491 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
492 const gchar *key_str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
493 gchar *value_str;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
494 MsimMessageElement *elem;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
495
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
496 elem = (MsimMessageElement *)body_node->data;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
497 key_str = elem->name;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
498
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
499 value_str = msim_msg_get_string_from_element(elem);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
500 msim_store_user_info_each(key_str, value_str, user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
501 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
502
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
503 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
504 g_free(username);
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
505
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
506 return TRUE;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
507 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
508
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
509 #if 0
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
510 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
511 * Return whether a given username is syntactically valid.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
512 * Note: does not actually check that the user exists.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
513 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
514 static gboolean
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
515 msim_is_valid_username(const gchar *user)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
516 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
517 return !msim_is_userid(user) && /* Not all numeric */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
518 strlen(user) <= MSIM_MAX_USERNAME_LENGTH
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
519 && strspn(user, "0123456789"
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
520 "abcdefghijklmnopqrstuvwxyz"
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
521 "_"
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
522 "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
523 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
524 #endif
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
525
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
526 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
527 * Check if a string is a userid (all numeric).
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
528 *
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
529 * @param user The user id, email, or name.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
530 *
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
531 * @return TRUE if is userid, FALSE if not.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
532 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
533 gboolean
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
534 msim_is_userid(const gchar *user)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
535 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
536 g_return_val_if_fail(user != NULL, FALSE);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
537
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
538 return strspn(user, "0123456789") == strlen(user);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
539 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
540
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
541 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
542 * Check if a string is an email address (contains an @).
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
543 *
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
544 * @param user The user id, email, or name.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
545 *
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
546 * @return TRUE if is an email, FALSE if not.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
547 *
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
548 * This function is not intended to be used as a generic
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
549 * means of validating email addresses, but to distinguish
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
550 * between a user represented by an email address from
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
551 * other forms of identification.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
552 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
553 static gboolean
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
554 msim_is_email(const gchar *user)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
555 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
556 g_return_val_if_fail(user != NULL, FALSE);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
557
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
558 return strchr(user, '@') != NULL;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
559 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
560
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
561 /**
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
562 * Asynchronously lookup user information, calling callback when receive result.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
563 *
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
564 * @param session
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
565 * @param user The user id, email address, or username. Not freed.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
566 * @param cb Callback, called with user information when available.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
567 * @param data An arbitray data pointer passed to the callback.
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
568 */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
569 /* TODO: change to not use callbacks */
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
570 void
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
571 msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data)
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
572 {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
573 MsimMessage *body;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
574 gchar *field_name;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
575 guint rid, cmd, dsn, lid;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
576
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
577 g_return_if_fail(MSIM_SESSION_VALID(session));
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
578 g_return_if_fail(user != NULL);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
579 /* Callback can be null to not call anything, just lookup & store information. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
580 /*g_return_if_fail(cb != NULL);*/
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
581
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
582 purple_debug_info("msim", "msim_lookup_userid: "
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
583 "asynchronously looking up <%s>\n", user);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
584
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
585 /* Setup callback. Response will be associated with request using 'rid'. */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
586 rid = msim_new_reply_callback(session, cb, data);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
587
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
588 /* Send request */
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
589
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
590 cmd = MSIM_CMD_GET;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
591
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
592 if (msim_is_userid(user)) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
593 field_name = "UserID";
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
594 dsn = MG_MYSPACE_INFO_BY_ID_DSN;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
595 lid = MG_MYSPACE_INFO_BY_ID_LID;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
596 } else if (msim_is_email(user)) {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
597 field_name = "Email";
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
598 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
599 lid = MG_MYSPACE_INFO_BY_STRING_LID;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
600 } else {
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
601 field_name = "UserName";
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
602 dsn = MG_MYSPACE_INFO_BY_STRING_DSN;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
603 lid = MG_MYSPACE_INFO_BY_STRING_LID;
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
604 }
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
605
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
606 body = msim_msg_new(
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
607 field_name, MSIM_TYPE_STRING, g_strdup(user),
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
608 NULL);
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
609
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
610 g_return_if_fail(msim_send(session,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
611 "persist", MSIM_TYPE_INTEGER, 1,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
612 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
613 "cmd", MSIM_TYPE_INTEGER, 1,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
614 "dsn", MSIM_TYPE_INTEGER, dsn,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
615 "uid", MSIM_TYPE_INTEGER, session->userid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
616 "lid", MSIM_TYPE_INTEGER, lid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
617 "rid", MSIM_TYPE_INTEGER, rid,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
618 "body", MSIM_TYPE_DICTIONARY, body,
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
619 NULL));
22305
bf4902fce6e4 In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22304
diff changeset
620 }
bf4902fce6e4 In msimprpl, add msim_is_valid_username() to check whether a username
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22304
diff changeset
621
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
622 /**
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
623 * Called after username is set.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
624 */
24764
c044eb54b7ac Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24746
diff changeset
625 static void msim_username_is_set_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
626 {
24764
c044eb54b7ac Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24746
diff changeset
627 gchar *username;
c044eb54b7ac Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24746
diff changeset
628 const gchar *errmsg;
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
629 MsimMessage *body;
20257
1141d47b162c Kill CRLF line-endings to make sure this compiles on Solaris. This is a
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
630
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
631 guint rid;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
632 gint cmd,dsn,uid,lid,code;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
633 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\final\ */
22303
1097406c8f6c In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22302
diff changeset
634
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
635 purple_debug_info("msim","username_is_set 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
636
0e2207b46080 In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22264
diff changeset
637 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
638
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
639 cmd = msim_msg_get_integer(userinfo, "cmd");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
640 dsn = msim_msg_get_integer(userinfo, "dsn");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
641 uid = msim_msg_get_integer(userinfo, "uid");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
642 lid = msim_msg_get_integer(userinfo, "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
643 body = msim_msg_get_dictionary(userinfo, "body");
27463
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27235
diff changeset
644 errmsg = _("An error occurred while trying to set the username. "
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
645 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
646 "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
647
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 if (!body) {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
649 purple_debug_info("msim_username_is_set_cb", "No body");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
650 /* Error: No body! */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
651 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
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 }
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
653 username = msim_msg_get_string(body, "UserName");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
654 code = msim_msg_get_integer(body,"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
655
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 msim_msg_free(body);
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
657
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
658 purple_debug_info("msim_username_is_set_cb",
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
659 "cmd = %d, dsn = %d, lid = %d, code = %d, username = %s\n",
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
660 cmd, dsn, lid, code, 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
661
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
662 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_PUT)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
663 && dsn == MC_SET_USERNAME_DSN
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
664 && lid == MC_SET_USERNAME_LID)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
665 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
666 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
667 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",code);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
668 if (code == 0) {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
669 /* Good! */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
670 session->username = username;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
671 msim_we_are_logged_on(session);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
672 } else {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
673 purple_debug_info("msim_username_is_set", "code is %d",code);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
674 /* TODO: what to do here? */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
675 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
676 } else if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
677 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
678 && lid == MG_MYSPACE_INFO_BY_STRING_LID) {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
679 /* Not quite done... ONE MORE STEP :) */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
680 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
681 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username), NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
682 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
683 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
684 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
685 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
686 "uid", MSIM_TYPE_INTEGER, session->userid,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
687 "lid", MSIM_TYPE_INTEGER, MC_SET_USERNAME_LID,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
688 "rid", MSIM_TYPE_INTEGER, rid,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
689 "body", MSIM_TYPE_DICTIONARY, body,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
690 NULL)) {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
691 /* Error! */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
692 /* Can't set... Disconnect */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
693 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
694 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
695
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
696 } else {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
697 /* Error! */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
698 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
699 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
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
700 }
0e2207b46080 In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22264
diff changeset
701 }
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 /**
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 * 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
705 *
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 * @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
707 * @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
708 * @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
709 * @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
710 */
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
711 static void
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
712 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
713 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
714 {
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 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
716 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
717
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 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
719 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
720 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
721
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 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
723 "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
724
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 /* 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
726 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
727
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 /* 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
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 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
731 /* \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
732 */
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
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 /* 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
735 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
736 "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
737 "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
738 "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
739 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
740 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
741 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
742 "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
743 "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
744 "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
745 "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
746 "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
747 "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
748 "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
749 "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
750 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
751 }
0e2207b46080 In msimprpl, if the user signs in without any username set (this will happen
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22264
diff changeset
752
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
753 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
754 * They've confirmed that username that was available, Lets make the call to set it
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
755 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
756 static void msim_set_username_confirmed_cb(PurpleConnection *gc)
22303
1097406c8f6c In msimprpl, change to patch from Jaywalker regarding setting
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22302
diff changeset
757 {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
758 MsimMessage *user_msg;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
759 MsimSession *session;
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
760
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
761 g_return_if_fail(gc != 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
762
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
763 session = (MsimSession *)gc->proto_data;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
764
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
765 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
766
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
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
768 user_msg = msim_msg_new(
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
769 "user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
770 NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
771
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
772 purple_debug_info("msim_set_username_confirmed_cb", "Setting username to %s\n", msim_username_to_set);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
773
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
774 /* Sets our username... keep your fingers crossed :) */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
775 msim_set_username(session, msim_username_to_set, msim_username_is_set_cb, user_msg);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
776 g_free(msim_username_to_set);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
777 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
778
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
779 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
780 * This is where we do a bit more than merely prompt the user.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
781 * Now we have some real data to tell us the state of their requested username
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
782 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
783 */
24764
c044eb54b7ac Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24746
diff changeset
784 static void msim_username_is_available_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
785 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
786 MsimMessage *msg;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
787 gchar *username;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
788 MsimMessage *body;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
789 gint userid;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
790
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
791 purple_debug_info("msim_username_is_available_cb", "Look up username callback made\n");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
792
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
793 msg = (MsimMessage *)data;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
794 g_return_if_fail(MSIM_SESSION_VALID(session));
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
795 g_return_if_fail(msg != NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
796
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
797 username = msim_msg_get_string(msg, "user");
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
798 body = msim_msg_get_dictionary(userinfo, "body");
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
799
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
800 if (!body) {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
801 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
802 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
27463
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27235
diff changeset
803 _("An error occurred while trying to set the username. "
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
804 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
27463
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27235
diff changeset
805 "fuseaction=profile.username to set your username."));
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
806 return;
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 }
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
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
809 userid = msim_msg_get_integer(body, "UserID");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
810
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
811 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
812 msim_msg_free(body);
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
813 msim_msg_free(msg);
22304
c3dc9e0d2c08 In msimprpl, define a new set of symbolic constants for the command to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22303
diff changeset
814
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
815 /* The response for a free username will ONLY have the UserName in it..
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
816 * thus making UserID return 0 when we msg_get_integer it */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
817 if (userid == 0) {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
818 /* This username is currently unused */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
819 purple_debug_info("msim_username_is_available_cb", "Username available. Prompting to Confirm.\n");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
820 msim_username_to_set = g_strdup(username);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
821 g_free(username);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
822 purple_request_yes_no(session->gc,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
823 _("MySpaceIM - Username Available"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
824 _("This username is available. Would you like to set it?"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
825 _("ONCE SET, THIS CANNOT BE CHANGED!"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
826 0,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
827 session->account,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
828 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
829 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
830 session->gc,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
831 G_CALLBACK(msim_set_username_confirmed_cb),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
832 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
833 } else {
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
834 /* Looks like its in use or we have an invalid response */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
835 purple_debug_info("msim_username_is_available_cb", "Username unavaiable. Prompting for new entry.\n");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
836 purple_request_input(session->gc, _("MySpaceIM - Please Set a Username"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
837 _("This username is unavailable."),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
838 _("Please try another username:"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
839 "", FALSE, FALSE, NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
840 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
841 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
842 session->account,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
843 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
844 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
845 session->gc);
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
846 }
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
847 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
848
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
849 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
850 * Once they've submitted their desired new username,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
851 * check if it is available here.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
852 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
853 static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
854 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
855 MsimMessage *user_msg;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
856 MsimSession *session;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
857
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
858 g_return_if_fail(gc != NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
859
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
860 session = (MsimSession *)gc->proto_data;
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
861
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
862 g_return_if_fail(MSIM_SESSION_VALID(session));
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
863
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
864 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
865
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
866 user_msg = msim_msg_new(
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
867 "user", MSIM_TYPE_STRING, g_strdup(username_to_check),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
868 NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
869
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
870 /* 25 characters: letters, numbers, underscores */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
871 /* TODO: VERIFY ABOVE */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
872
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
873 /* \persist\1\sesskey\288500516\cmd\1\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=Jaywalker\final\ */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
874 /* Official client uses a standard lookup... So do we! */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
875 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
876 }
24731
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
877
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
878 /***
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
879 * If they hit cancel or no at any point in the Setting Username process,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
880 * we come here. Currently we're safe letting them get by without
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
881 * setting it, unless we hear otherwise. So for now give them a menu.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
882 * If this becomes an issue with the official client then boot them here.
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
883 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
884 void msim_do_not_set_username_cb(PurpleConnection *gc)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
885 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
886 purple_debug_info("msim", "Don't set username");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
887
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
888 /* Protocol won't log in now without a username set.. Disconnect */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
889 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
890 }
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
891
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
892 /**
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
893 * They've decided to set a username! Yay!
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
894 */
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
895 void msim_set_username_cb(PurpleConnection *gc)
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
896 {
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
897 g_return_if_fail(gc != NULL);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
898 purple_debug_info("msim","Set username\n");
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
899 purple_request_input(gc, _("MySpaceIM - Please Set a Username"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
900 _("Please enter a username to check its availability:"),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
901 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
902 "", FALSE, FALSE, NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
903 _("OK"), G_CALLBACK(msim_check_username_availability_cb),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
904 _("Cancel"), G_CALLBACK(msim_do_not_set_username_cb),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
905 purple_connection_get_account(gc),
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
906 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
907 NULL,
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
908 gc);
295464ae2d2a No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents: 24726
diff changeset
909 }