Mercurial > pidgin
annotate libpurple/protocols/myspace/myspace.c @ 25332:6fe309e61bf9
propagate from branch 'im.pidgin.pidgin' (head 42f77b0e8b8ebf5ff3c30d8f8022ac5d289631e8)
to branch 'im.pidgin.cpw.darkrain42.oscar.ssl' (head b6d4e7d29639f3e23e852fcf68d362275de42902)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 18 Jan 2009 04:17:01 +0000 |
parents | b15168f2b7ee |
children | 0d6bd0eca4cb 7bfaa0b61a83 4278d13b5471 94a6eb10c691 |
rev | line source |
---|---|
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2 * MySpaceIM Protocol Plugin |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
4 * \author Jeff Connelly |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
5 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
6 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
7 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
8 * Based on Purple's "C Plugin HOWTO" hello world example. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
9 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
10 * Code also drawn from mockprpl: |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
11 * http://snarfed.org/space/purple+mock+protocol+plugin |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
12 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
13 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
14 * and some constructs also based on existing Purple plugins, which are: |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
15 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
16 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
17 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
18 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
19 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
20 * This program is free software; you can redistribute it and/or modify |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
21 * it under the terms of the GNU General Public License as published by |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
22 * the Free Software Foundation; either version 2 of the License, or |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
23 * (at your option) any later version. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
24 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
25 * This program is distributed in the hope that it will be useful, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
28 * GNU General Public License for more details. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
29 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
30 * You should have received a copy of the GNU General Public License |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
31 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19661
diff
changeset
|
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
33 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
34 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
35 #define PURPLE_PLUGIN |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
36 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
37 #include "myspace.h" |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
38 |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
39 #include "privacy.h" |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
40 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
41 static void msim_set_status(PurpleAccount *account, PurpleStatus *status); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
42 static void msim_set_idle(PurpleConnection *gc, int time); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
43 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
44 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
45 * Perform actual postprocessing on a message, adding userid as specified. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
46 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
47 * @param msg The message to postprocess. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
48 * @param uid_before Name of field where to insert new field before, or NULL for end. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
49 * @param uid_field_name Name of field to add uid to. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
50 * @param uid The userid to insert. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
51 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
52 * If the field named by uid_field_name already exists, then its string contents will |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
53 * be used for the field, except "<uid>" will be replaced by the userid. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
54 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
55 * If the field named by uid_field_name does not exist, it will be added before the |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
56 * field named by uid_before, as an integer, with the userid. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
57 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
58 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
59 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
60 static MsimMessage * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
61 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
62 const gchar *uid_field_name, guint uid) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
63 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
64 MsimMessageElement *elem; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
65 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
66 /* First, check - if the field already exists, replace <uid> within it */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
67 if ((elem = msim_msg_get(msg, uid_field_name)) != NULL) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
68 gchar *fmt_string; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
69 gchar *uid_str, *new_str; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
70 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
71 /* Get the packed element, flattening it. This allows <uid> to be |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
72 * replaced within nested data structures, since the replacement is done |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
73 * on the linear, packed data, not on a complicated data structure. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
74 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
75 * For example, if the field was originally a dictionary or a list, you |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
76 * would have to iterate over all the items in it to see what needs to |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
77 * be replaced. But by packing it first, the <uid> marker is easily replaced |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
78 * just by a string replacement. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
79 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
80 fmt_string = msim_msg_pack_element_data(elem); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
81 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
82 uid_str = g_strdup_printf("%d", uid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
83 new_str = purple_strreplace(fmt_string, "<uid>", uid_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
84 g_free(uid_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
85 g_free(fmt_string); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
86 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
87 /* Free the old element data */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
88 msim_msg_free_element_data(elem->data); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
89 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
90 /* Replace it with our new data */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
91 elem->data = new_str; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
92 elem->type = MSIM_TYPE_RAW; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
93 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
94 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
95 /* Otherwise, insert new field into outgoing message. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
96 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
97 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
98 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
99 return msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
100 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
101 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
102 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
103 * Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
104 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
105 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
106 * @param userinfo The user information reply message, containing the user ID |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
107 * @param data The message to postprocess and send. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
108 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
109 * The data message should contain these fields: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
110 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
111 * _uid_field_name: string, name of field to add with userid from userinfo message |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
112 * _uid_before: string, name of field before field to insert, or NULL for end |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
113 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
114 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
115 msim_postprocess_outgoing_cb(MsimSession *session, const MsimMessage *userinfo, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
116 gpointer data) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
117 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
118 gchar *uid_field_name, *uid_before, *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
119 guint uid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
120 MsimMessage *msg, *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
121 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
122 msg = (MsimMessage *)data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
123 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
124 /* Obtain userid from userinfo message. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
125 body = msim_msg_get_dictionary(userinfo, "body"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
126 g_return_if_fail(body != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
127 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
128 uid = msim_msg_get_integer(body, "UserID"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
129 msim_msg_free(body); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
130 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
131 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
132 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
133 if (!uid) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
134 gchar *msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
135 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
136 msg = g_strdup_printf(_("No such user: %s"), username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
137 if (!purple_conv_present_error(username, session->account, msg)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
138 purple_notify_error(NULL, NULL, _("User lookup"), msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
139 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
140 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
141 g_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
142 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
143 /* TODO: free |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
144 * msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
145 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
146 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
147 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
148 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
149 uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
150 uid_before = msim_msg_get_string(msg, "_uid_before"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
151 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
152 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
153 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
154 /* Send */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
155 if (!msim_msg_send(session, msg)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
156 msim_msg_dump("msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
157 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
158 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
159 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
160 /* Free field names AFTER sending message, because MsimMessage does NOT copy |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
161 * field names - instead, treats them as static strings (which they usually are). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
162 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
163 g_free(uid_field_name); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
164 g_free(uid_before); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
165 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
166 /* TODO: free |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
167 * msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
168 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
169 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
170 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
171 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
172 * Postprocess and send a message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
173 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
174 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
175 * @param msg Message to postprocess. Will NOT be freed. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
176 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
177 * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
178 * @param uid_before Name of existing field to insert username field before. Static string. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
179 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
180 * @return TRUE if successful. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
181 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
182 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
183 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
184 const gchar *username, const gchar *uid_field_name, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
185 const gchar *uid_before) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
186 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
187 PurpleBuddy *buddy; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
188 guint uid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
189 gboolean rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
190 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
191 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
192 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
193 /* Store information for msim_postprocess_outgoing_cb(). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
194 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
195 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
196 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
197 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
198 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
199 if (msim_is_userid(username)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
200 uid = atol(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
201 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
202 /* Next, see if on buddy list and know uid. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
203 buddy = purple_find_buddy(session->account, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
204 if (buddy) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
205 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
206 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
207 uid = 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
208 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
209 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
210 if (!buddy || !uid) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
211 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
212 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
213 username ? username : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
214 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
215 return TRUE; /* not sure of status yet - haven't sent! */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
216 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
217 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
218 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
219 /* Already have uid, postprocess and send msg immediately. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
220 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
221 username ? username : "(NULL)", uid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
222 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
223 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
224 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
225 rc = msim_msg_send(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
226 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
227 /* TODO: free |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
228 * msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
229 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
230 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
231 return rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
232 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
233 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
234 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
235 * Send a buddy message of a given type. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
236 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
237 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
238 * @param who Username to send message to. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
239 * @param text Message text to send. Not freed; will be copied. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
240 * @param type A MSIM_BM_* constant. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
241 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
242 * @return TRUE if success, FALSE if fail. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
243 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
244 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
245 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
246 gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
247 msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
248 int type) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
249 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
250 gboolean rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
251 MsimMessage *msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
252 const gchar *from_username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
253 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
254 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
255 g_return_val_if_fail(who != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
256 g_return_val_if_fail(text != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
257 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
258 from_username = session->account->username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
259 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
260 g_return_val_if_fail(from_username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
261 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
262 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
263 type, from_username, who, text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
264 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
265 msg = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
266 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
267 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
268 /* 't' will be inserted here */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
269 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
270 "msg", MSIM_TYPE_STRING, g_strdup(text), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
271 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
272 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
273 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
274 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
275 msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
276 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
277 return rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
278 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
279 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
280 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
281 * Lookup a username by userid, from buddy list. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
282 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
283 * @param wanted_uid |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
284 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
285 * @return Username of wanted_uid, if on blist, or NULL. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
286 * This is a static string, so don't free it. Copy it if needed. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
287 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
288 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
289 static const gchar * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
290 msim_uid2username_from_blist(PurpleAccount *account, guint wanted_uid) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
291 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
292 GSList *buddies, *cur; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
293 const gchar *ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
294 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
295 buddies = purple_find_buddies(account, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
296 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
297 if (!buddies) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
298 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
299 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
300 return NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
301 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
302 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
303 ret = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
304 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
305 for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
306 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
307 PurpleBuddy *buddy; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
308 guint uid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
309 const gchar *name; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
310 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
311 /* See finch/gnthistory.c */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
312 buddy = cur->data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
313 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
314 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
315 name = purple_buddy_get_name(buddy); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
316 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
317 if (uid == wanted_uid) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
318 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
319 ret = name; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
320 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
321 } |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
322 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
323 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
324 g_slist_free(buddies); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
325 return ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
326 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
327 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
328 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
329 * Setup a callback, to be called when a reply is received with the returned rid. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
330 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
331 * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
332 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
333 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
334 * @return The request/reply ID, used to link replies with requests, or -1. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
335 * Put the rid in your request, 'rid' field. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
336 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
337 * TODO: Make more generic and more specific: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
338 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
339 * 2) data - make it an MsimMessage? |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
340 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
341 guint |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
342 msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
343 gpointer data) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
344 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
345 guint rid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
346 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
347 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
348 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
349 rid = session->next_rid++; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
350 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
351 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
352 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
353 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
354 return rid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
355 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
356 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
357 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
358 * Return the icon name for a buddy and account. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
359 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
360 * @param acct The account to find the icon for, or NULL for protocol icon. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
361 * @param buddy The buddy to find the icon for, or NULL for the account icon. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
362 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
363 * @return The base icon name string. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
364 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
365 static const gchar * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
366 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
367 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
368 /* Use a MySpace icon submitted by hbons at |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
369 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
370 return "myspace"; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
371 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
372 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
373 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
374 * Obtain the status text for a buddy. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
375 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
376 * @param buddy The buddy to obtain status text for. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
377 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
378 * @return Status text, or NULL if error. Caller g_free()'s. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
379 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
380 static char * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
381 msim_status_text(PurpleBuddy *buddy) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
382 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
383 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
384 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
385 const gchar *display_name, *headline; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
386 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
387 g_return_val_if_fail(buddy != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
388 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
389 user = msim_get_user_from_buddy(buddy); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
390 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
391 session = (MsimSession *)buddy->account->gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
392 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
393 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
394 display_name = headline = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
395 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
396 /* Retrieve display name and/or headline, depending on user preference. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
397 if (purple_account_get_bool(session->account, "show_headline", TRUE)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
398 headline = user->headline; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
399 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
400 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
401 if (purple_account_get_bool(session->account, "show_display_name", FALSE)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
402 display_name = user->display_name; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
403 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
404 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
405 /* Return appropriate combination of display name and/or headline, or neither. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
406 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
407 if (display_name && headline) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
408 return g_strconcat(display_name, " ", headline, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
409 } else if (display_name) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
410 return g_strdup(display_name); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
411 } else if (headline) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
412 return g_strdup(headline); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
413 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
414 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
415 return NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
416 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
417 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
418 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
419 * Obtain the tooltip text for a buddy. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
420 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
421 * @param buddy Buddy to obtain tooltip text on. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
422 * @param user_info Variable modified to have the tooltip text. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
423 * @param full TRUE if should obtain full tooltip text. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
424 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
425 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
426 msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
427 gboolean full) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
428 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
429 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
430 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
431 g_return_if_fail(buddy != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
432 g_return_if_fail(user_info != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
433 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
434 user = msim_get_user_from_buddy(buddy); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
435 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
436 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
437 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
438 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
439 session = (MsimSession *)buddy->account->gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
440 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
441 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
442 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
443 /* TODO: if (full), do something different? */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
444 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
445 /* TODO: request information? have to figure out how to do |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
446 * the asynchronous lookup like oscar does (tooltip shows |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
447 * 'retrieving...' if not yet available, then changes when it is). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
448 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
449 * Right now, only show what we have on hand. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
450 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
451 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
452 /* Show abbreviated user info. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
453 msim_append_user_info(session, user_info, user, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
454 } |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
455 } |
22160 | 456 |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
457 /** |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
458 * Get possible user status types. Based on mockprpl. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
459 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
460 * @return GList of status types. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
461 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
462 static GList * |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
463 msim_status_types(PurpleAccount *acct) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
464 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
465 GList *types; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
466 PurpleStatusType *status; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
467 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
468 purple_debug_info("myspace", "returning status types\n"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
469 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
470 types = NULL; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
471 |
22160 | 472 /* Statuses are almost all the same. Define a macro to reduce code repetition. */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
473 #define _MSIM_ADD_NEW_STATUS(prim) status = \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
474 purple_status_type_new_with_attrs( \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
475 prim, /* PurpleStatusPrimitive */ \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
476 NULL, /* id - use default */ \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
477 NULL, /* name - use default */ \ |
24464
3a3d36791a47
I don't know why we'd want the TUNE status to be saveable.
Richard Laager <rlaager@wiktel.com>
parents:
24406
diff
changeset
|
478 TRUE, /* saveable */ \ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
479 TRUE, /* user_settable */ \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
480 FALSE, /* not independent */ \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
481 \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
482 /* Attributes - each status can have a message. */ \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
483 "message", \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
484 _("Message"), \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
485 purple_value_new(PURPLE_TYPE_STRING), \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
486 NULL); \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
487 \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
488 \ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
489 types = g_list_append(types, status) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
490 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
491 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
492 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
493 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
494 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
495 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
496 |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
497 /* Except tune status is different... */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
498 status = purple_status_type_new_with_attrs( |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
499 PURPLE_STATUS_TUNE, /* primitive */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
500 "tune", /* ID */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
501 NULL, /* name - use default */ |
24464
3a3d36791a47
I don't know why we'd want the TUNE status to be saveable.
Richard Laager <rlaager@wiktel.com>
parents:
24406
diff
changeset
|
502 FALSE, /* saveable */ |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
503 TRUE, /* should be user_settable some day */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
504 TRUE, /* independent */ |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
505 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
506 PURPLE_TUNE_ARTIST, _("Artist"), purple_value_new(PURPLE_TYPE_STRING), |
22266
fc31c35d8024
purple_status_type_new_with_attrs() must be NULL terminated. Finally all
Stu Tomlinson <stu@nosnilmot.com>
parents:
22264
diff
changeset
|
507 PURPLE_TUNE_TITLE, _("Title"), purple_value_new(PURPLE_TYPE_STRING), |
fc31c35d8024
purple_status_type_new_with_attrs() must be NULL terminated. Finally all
Stu Tomlinson <stu@nosnilmot.com>
parents:
22264
diff
changeset
|
508 NULL); |
22264
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
509 |
e808d83d797e
In msimprpl, use a PURPLE_STATUS_TUNE presence type to hold the "now playing"
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22226
diff
changeset
|
510 types = g_list_append(types, status); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
511 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
512 return types; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
513 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
514 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
515 /** |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
516 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
517 * |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
518 * @param nonce The base64 encoded nonce ('nc') field from the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
519 * @param email User's email address (used as login name). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
520 * @param password User's cleartext password. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
521 * @param response_len Will be written with response length. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
522 * |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
523 * @return Binary login challenge response, ready to send to the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
524 * Must be g_free()'d when finished. NULL if error. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
525 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
526 static gchar * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
527 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
528 const gchar *email, const gchar *password, guint *response_len) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
529 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
530 PurpleCipherContext *key_context; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
531 PurpleCipher *sha1; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
532 PurpleCipherContext *rc4; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
533 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
534 guchar hash_pw[HASH_SIZE]; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
535 guchar key[HASH_SIZE]; |
24914
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
536 gchar *password_truncated, *password_utf16le, *password_utf8_lc; |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
537 GString *data; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
538 guchar *data_out; |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
539 size_t data_out_len; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
540 gsize conv_bytes_read, conv_bytes_written; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
541 GError *conv_error; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
542 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
543 int i; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
544 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
545 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
546 g_return_val_if_fail(nonce != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
547 g_return_val_if_fail(email != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
548 g_return_val_if_fail(password != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
549 g_return_val_if_fail(response_len != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
550 |
24914
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
551 /* |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
552 * Truncate password to 10 characters. Their "change password" |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
553 * web page doesn't let you enter more than 10 characters, but you |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
554 * can enter more than 10 when logging in on myspace.com and they |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
555 * truncate it. |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
556 */ |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
557 password_truncated = g_strndup(password, 10); |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
558 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
559 /* Convert password to lowercase (required for passwords containing |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
560 * uppercase characters). MySpace passwords are lowercase, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
561 * see ticket #2066. */ |
24914
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
562 password_utf8_lc = g_utf8_strdown(password_truncated, -1); |
1981b04de92e
MySpace? passwords are truncated to 10 characters. Their website doesn't
Mark Doliner <mark@kingant.net>
parents:
24885
diff
changeset
|
563 g_free(password_truncated); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
564 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
565 /* Convert ASCII password to UTF16 little endian */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
566 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
567 conv_error = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
568 password_utf16le = g_convert(password_utf8_lc, -1, "UTF-16LE", "UTF-8", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
569 &conv_bytes_read, &conv_bytes_written, &conv_error); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
570 g_free(password_utf8_lc); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
571 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
572 if (conv_error != NULL) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
573 purple_debug_error("msim", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
574 "g_convert password UTF8->UTF16LE failed: %s", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
575 conv_error->message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
576 g_error_free(conv_error); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
577 return NULL; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
578 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
579 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
580 /* Compute password hash */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
581 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
582 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
583 g_free(password_utf16le); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
584 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
585 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
586 purple_debug_info("msim", "pwhash = "); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
587 for (i = 0; i < sizeof(hash_pw); i++) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
588 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
589 purple_debug_info("msim", "\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
590 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
591 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
592 /* key = sha1(sha1(pw) + nonce2) */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
593 sha1 = purple_ciphers_find_cipher("sha1"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
594 key_context = purple_cipher_context_new(sha1, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
595 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
596 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
597 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
598 purple_cipher_context_destroy(key_context); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
599 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
600 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
601 purple_debug_info("msim", "key = "); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
602 for (i = 0; i < sizeof(key); i++) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
603 purple_debug_info("msim", "%.2x ", key[i]); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
604 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
605 purple_debug_info("msim", "\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
606 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
607 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
608 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
609 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
610 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
611 * but only first 0x10 used for the RC4 key. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
612 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
613 purple_cipher_context_set_key(rc4, key); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
614 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
615 /* TODO: obtain IPs of network interfaces */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
616 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
617 /* rc4 encrypt: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
618 * nonce1+email+IP list */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
619 |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
620 data = g_string_new(NULL); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
621 g_string_append_len(data, nonce, NONCE_SIZE); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
622 g_string_append(data, email); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
623 g_string_append_len(data, MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
624 |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
625 data_out = g_new0(guchar, data->len); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
626 |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
627 purple_cipher_context_encrypt(rc4, (const guchar *)data->str, |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
628 data->len, data_out, &data_out_len); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
629 purple_cipher_context_destroy(rc4); |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
630 |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
631 if (data_out_len != data->len) { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
632 purple_debug_info("msim", "msim_compute_login_response: " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
633 "data length mismatch: %" G_GSIZE_FORMAT " != %" |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
634 G_GSIZE_FORMAT "\n", data_out_len, data->len); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
635 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
636 |
24768
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
637 g_string_free(data, TRUE); |
3c224208b814
Use a GString here when constructing the data. It's way more
Mark Doliner <mark@kingant.net>
parents:
24767
diff
changeset
|
638 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
639 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
640 purple_debug_info("msim", "response=<%s>\n", data_out); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
641 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
642 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
643 *response_len = data_out_len; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
644 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
645 return (gchar *)data_out; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
646 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
647 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
648 /** |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
649 * Process a login challenge, sending a response. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
650 * |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
651 * @param session |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
652 * @param msg Login challenge message. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
653 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
654 * @return TRUE if successful, FALSE if not |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
655 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
656 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
657 msim_login_challenge(MsimSession *session, MsimMessage *msg) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
658 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
659 PurpleAccount *account; |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
660 gchar *response; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
661 guint response_len; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
662 gchar *nc; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
663 gsize nc_len; |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
664 gboolean ret; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
665 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
666 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
667 g_return_val_if_fail(msg != NULL, FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
668 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
669 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
670 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
671 account = session->account; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
672 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
673 g_return_val_if_fail(account != NULL, FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
674 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
675 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
676 |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
677 purple_debug_info("msim", "nc is %" G_GSIZE_FORMAT |
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
678 " bytes, decoded\n", nc_len); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
679 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
680 if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) { |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
681 purple_debug_info("msim", "bad nc length: %" G_GSIZE_MODIFIER |
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
682 "x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH); |
21358 | 683 purple_connection_error_reason (session->gc, |
684 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
20121
e4bcdd9622c2
purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents:
20057
diff
changeset
|
685 _("Unexpected challenge length from server")); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
686 return FALSE; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
687 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
688 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
689 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
690 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
691 response_len = 0; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
692 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
693 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
694 g_free(nc); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
695 |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
696 ret = msim_send(session, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
697 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
698 /* This is actually user's email address. */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
699 "username", MSIM_TYPE_STRING, g_strdup(account->username), |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
700 /* GString will be freed in msim_msg_free() in msim_send(). */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
701 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
702 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
703 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
704 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH), |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
705 "reconn", MSIM_TYPE_INTEGER, 0, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
706 "status", MSIM_TYPE_INTEGER, 100, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
707 "id", MSIM_TYPE_INTEGER, 1, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
708 NULL); |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
709 |
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
710 g_free(response); |
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
711 |
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
712 return ret; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
713 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
714 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
715 /** |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
716 * Process unrecognized information. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
717 * |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
718 * @param session |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
719 * @param msg An MsimMessage that was unrecognized, or NULL. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
720 * @param note Information on what was unrecognized, or NULL. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
721 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
722 void |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
723 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
724 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
725 /* TODO: Some more context, outwardly equivalent to a backtrace, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
726 * for helping figure out what this msg is for. What was going on? |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
727 * But not too much information so that a user |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
728 * posting this dump reveals confidential information. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
729 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
730 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
731 /* TODO: dump unknown msgs to file, so user can send them to me |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
732 * if they wish, to help add support for new messages (inspired |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
733 * by Alexandr Shutko, who maintains OSCAR protocol documentation). |
22156 | 734 * |
735 * Filed enhancement ticket for libpurple as #4688. | |
736 */ | |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
737 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
738 purple_debug_info("msim", "Unrecognized data on account for %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
739 (session && session->account && session->account->username) ? |
19353
af0e77c44667
MySpace added a new field, LastImageUpdated. Save it in MsimUser.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19352
diff
changeset
|
740 session->account->username : "(NULL)"); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
741 if (note) { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
742 purple_debug_info("msim", "(Note: %s)\n", note); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
743 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
744 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
745 if (msg) { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
746 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
747 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
748 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
749 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
750 /** Called when the session key arrives to check whether the user |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
751 * has a username, and set one if desired. */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
752 static gboolean |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
753 msim_is_username_set(MsimSession *session, MsimMessage *msg) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
754 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
755 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
756 g_return_val_if_fail(msg != NULL, FALSE); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
757 g_return_val_if_fail(session->gc != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
758 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
759 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
760 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
761 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
762 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
763 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
764 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
765 * some of the time, but can vary. This is our own user ID. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
766 session->userid = msim_msg_get_integer(msg, "userid"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
767 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
768 /* Save uid to account so this account can be looked up by uid. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
769 purple_account_set_int(session->account, "uid", session->userid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
770 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
771 /* Not sure what profileid is used for. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
772 if (msim_msg_get_integer(msg, "profileid") != session->userid) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
773 msim_unrecognized(session, msg, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
774 "Profile ID didn't match user ID, don't know why"); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
775 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
776 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
777 /* We now know are our own username, only after we're logged in.. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
778 * which is weird, but happens because you login with your email |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
779 * address and not username. Will be freed in msim_session_destroy(). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
780 session->username = msim_msg_get_string(msg, "uniquenick"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
781 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
782 /* If user lacks a username, help them get one. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
783 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
784 purple_debug_info("msim_is_username_set", "no username is set\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
785 purple_request_yes_no(session->gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
786 _("MySpaceIM - No Username Set"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
787 _("You appear to have no MySpace username."), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
788 _("Would you like to set one now? (Note: THIS CANNOT BE CHANGED!)"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
789 0, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
790 session->account, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
791 NULL, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
792 NULL, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
793 session->gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
794 G_CALLBACK(msim_set_username_cb), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
795 G_CALLBACK(msim_do_not_set_username_cb)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
796 purple_debug_info("msim_is_username_set","'username not set' alert prompted\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
797 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
798 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
799 return TRUE; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
800 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
801 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
802 #ifdef MSIM_USE_KEEPALIVE |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
803 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
804 * Check if the connection is still alive, based on last communication. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
805 */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
806 static gboolean |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
807 msim_check_alive(gpointer data) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
808 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
809 MsimSession *session; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
810 time_t delta; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
811 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
812 session = (MsimSession *)data; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
813 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
814 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
815 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
816 delta = time(NULL) - session->last_comm; |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
817 |
22156 | 818 /* purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
819 if (delta >= MSIM_KEEPALIVE_INTERVAL) { |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
820 purple_debug_info("msim", |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
821 "msim_check_alive: %zu > interval of %d, presumed dead\n", |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
822 delta, MSIM_KEEPALIVE_INTERVAL); |
22156 | 823 purple_connection_error_reason(session->gc, |
24682
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
824 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
Mark Doliner <mark@kingant.net>
parents:
24464
diff
changeset
|
825 _("Lost connection with server")); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
826 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
827 return FALSE; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
828 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
829 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
830 return TRUE; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
831 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
832 #endif |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
833 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
834 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
835 * Handle mail reply checks. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
836 */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
837 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
838 msim_check_inbox_cb(MsimSession *session, const MsimMessage *reply, gpointer data) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
839 { |
19251
78558930d9f3
Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19249
diff
changeset
|
840 MsimMessage *body; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
841 guint old_inbox_status; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
842 guint i, n; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
843 const gchar *froms[5], *tos[5], *urls[5], *subjects[5]; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
844 |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
845 /* Information for each new inbox message type. */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
846 static struct |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
847 { |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
848 const gchar *key; |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
849 guint bit; |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
850 const gchar *url; |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
851 const gchar *text; |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
852 } message_types[] = { |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
853 { "Mail", MSIM_INBOX_MAIL, "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox", NULL }, |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
854 { "BlogComment", MSIM_INBOX_BLOG_COMMENT, "http://blog.myspace.com/index.cfm?fuseaction=blog", NULL }, |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
855 { "ProfileComment", MSIM_INBOX_PROFILE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL }, |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
856 { "FriendRequest", MSIM_INBOX_FRIEND_REQUEST, "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", NULL }, |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
857 { "PictureComment", MSIM_INBOX_PICTURE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL } |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
858 }; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
859 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
860 /* Can't write _()'d strings in array initializers. Workaround. */ |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
861 message_types[0].text = _("New mail messages"); |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
862 message_types[1].text = _("New blog comments"); |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
863 message_types[2].text = _("New profile comments"); |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
864 message_types[3].text = _("New friend requests!"); |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
865 message_types[4].text = _("New picture comments"); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
866 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
867 g_return_if_fail(reply != NULL); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
868 |
19251
78558930d9f3
Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19249
diff
changeset
|
869 body = msim_msg_get_dictionary(reply, "body"); |
21758
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
870 |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
871 if (body == NULL) |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
872 return; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
873 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
874 old_inbox_status = session->inbox_status; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
875 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
876 n = 0; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
877 |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
878 for (i = 0; i < sizeof(message_types) / sizeof(message_types[0]); ++i) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
879 const gchar *key; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
880 guint bit; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
881 |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
882 key = message_types[i].key; |
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
883 bit = message_types[i].bit; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
884 |
19251
78558930d9f3
Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19249
diff
changeset
|
885 if (msim_msg_get(body, key)) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
886 /* Notify only on when _changes_ from no mail -> has mail |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
887 * (edge triggered) */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
888 if (!(session->inbox_status & bit)) { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
889 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
890 key ? key : "(NULL)", n); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
891 |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
892 subjects[n] = message_types[i].text; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
893 froms[n] = _("MySpace"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
894 tos[n] = session->username; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
895 /* TODO: append token, web challenge, so automatically logs in. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
896 * Would also need to free strings because they won't be static |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
897 */ |
19430
0104035fd510
In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19429
diff
changeset
|
898 urls[n] = message_types[i].url; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
899 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
900 ++n; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
901 } else { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
902 purple_debug_info("msim", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
903 "msim_check_inbox_cb: already notified of %s\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
904 key ? key : "(NULL)"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
905 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
906 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
907 session->inbox_status |= bit; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
908 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
909 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
910 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
911 if (n) { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
912 purple_debug_info("msim", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
913 "msim_check_inbox_cb: notifying of %d\n", n); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
914 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
915 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
916 purple_notify_emails(session->gc, /* handle */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
917 n, /* count */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
918 TRUE, /* detailed */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
919 subjects, froms, tos, urls, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
920 NULL, /* PurpleNotifyCloseCallback cb */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
921 NULL); /* gpointer user_data */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
922 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
923 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
924 |
19251
78558930d9f3
Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19249
diff
changeset
|
925 msim_msg_free(body); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
926 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
927 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
928 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
929 * Send request to check if there is new mail. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
930 */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
931 static gboolean |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
932 msim_check_inbox(gpointer data) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
933 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
934 MsimSession *session; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
935 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
936 session = (MsimSession *)data; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
937 |
21758
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
938 if (!MSIM_SESSION_VALID(session)) { |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
939 purple_debug_info("msim", "msim_check_inbox: session invalid, stopping the mail check.\n"); |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
940 return FALSE; |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
941 } |
430827922828
Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents:
21709
diff
changeset
|
942 |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
943 purple_debug_info("msim", "msim_check_inbox: checking mail\n"); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
944 g_return_val_if_fail(msim_send(session, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
945 "persist", MSIM_TYPE_INTEGER, 1, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
946 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
947 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
948 "dsn", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_DSN, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
949 "lid", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_LID, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
950 "uid", MSIM_TYPE_INTEGER, session->userid, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
951 "rid", MSIM_TYPE_INTEGER, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
952 msim_new_reply_callback(session, msim_check_inbox_cb, NULL), |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
953 "body", MSIM_TYPE_STRING, g_strdup(""), |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
954 NULL), TRUE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
955 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
956 /* Always return true, so that we keep checking for mail. */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
957 return TRUE; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
958 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
959 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
960 /** |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
961 * Add contact from server to buddy list, after looking up username. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
962 * Callback from msim_add_contact_from_server(). |
19256
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
963 * |
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
964 * @param data An MsimMessage * of the contact information. Will be freed. |
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
965 */ |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
966 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
967 msim_add_contact_from_server_cb(MsimSession *session, const MsimMessage *user_lookup_info, gpointer data) |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
968 { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
969 MsimMessage *contact_info, *user_lookup_info_body; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
970 PurpleGroup *group; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
971 PurpleBuddy *buddy; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
972 MsimUser *user; |
24796
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
973 gchar *username, *group_name, *display_name; |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
974 guint uid, visibility; |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
975 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
976 contact_info = (MsimMessage *)data; |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
977 purple_debug_info("msim_add_contact_from_server_cb", "contact_info addr=%p\n", contact_info); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
978 uid = msim_msg_get_integer(contact_info, "ContactID"); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
979 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
980 if (!user_lookup_info) { |
22159 | 981 username = g_strdup(msim_uid2username_from_blist(session->account, uid)); |
24796
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
982 display_name = NULL; |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
983 g_return_if_fail(username != NULL); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
984 } else { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
985 user_lookup_info_body = msim_msg_get_dictionary(user_lookup_info, "body"); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
986 username = msim_msg_get_string(user_lookup_info_body, "UserName"); |
24796
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
987 display_name = msim_msg_get_string(user_lookup_info_body, "DisplayName"); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
988 msim_msg_free(user_lookup_info_body); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
989 g_return_if_fail(username != NULL); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
990 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
991 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
992 purple_debug_info("msim_add_contact_from_server_cb", |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
993 "*** about to add/update username=%s\n", username); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
994 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
995 /* 1. Creates a new group, or gets existing group if it exists (or so |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
996 * the documentation claims). */ |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
997 group_name = msim_msg_get_string(contact_info, "GroupName"); |
22983
882af25a8edf
Fix handling of empty groups in MySpace. Fixes #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22980
diff
changeset
|
998 if (!group_name || (*group_name == '\0')) { |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
999 g_free(group_name); |
22980
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1000 group_name = g_strdup(_("IM Friends")); |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1001 purple_debug_info("myspace", "No GroupName specified, defaulting to '%s'.\n", group_name); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1002 } |
22980
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1003 group = purple_find_group(group_name); |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1004 if (!group) { |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1005 group = purple_group_new(group_name); |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1006 /* Add group to beginning. See #2752. */ |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1007 purple_blist_add_group(group, NULL); |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1008 } |
77fc073e5a0b
Make MySpace group handling more consistent. References #3378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22607
diff
changeset
|
1009 g_free(group_name); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1010 |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1011 visibility = msim_msg_get_integer(contact_info, "Visibility"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1012 if (visibility == 2) { |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1013 /* This buddy is blocked (and therefore not on our buddy list */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1014 purple_privacy_deny_add(session->account, username, TRUE); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1015 msim_msg_free(contact_info); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1016 g_free(username); |
24796
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1017 g_free(display_name); |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1018 return; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1019 } |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
1020 |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1021 /* 2. Get or create buddy */ |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1022 buddy = purple_find_buddy(session->account, username); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1023 if (!buddy) { |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1024 purple_debug_info("msim_add_contact_from_server_cb", |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1025 "creating new buddy: %s\n", username); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1026 buddy = purple_buddy_new(session->account, username, NULL); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1027 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1028 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1029 /* TODO: use 'Position' in contact_info to take into account where buddy is */ |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1030 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1031 |
24796
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1032 if (strtol(username, NULL, 10) == uid) { |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1033 /* |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1034 * This user has not set their username! Set their server |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1035 * alias to their display name so that we don't see a bunch |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1036 * of numbers in the buddy list. |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1037 */ |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1038 if (display_name != NULL) { |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1039 purple_blist_node_set_string(&buddy->node, "DisplayName", display_name); |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1040 serv_got_alias(session->gc, username, display_name); |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1041 } else { |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1042 serv_got_alias(session->gc, username, |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1043 purple_blist_node_get_string(&buddy->node, "DisplayName")); |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1044 } |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1045 } |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1046 g_free(display_name); |
c2054d8d23fc
Set the server alias for myspace buddies who haven't set their username.
Mark Doliner <mark@kingant.net>
parents:
24785
diff
changeset
|
1047 |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1048 /* 3. Update buddy information */ |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1049 user = msim_get_user_from_buddy(buddy); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1050 |
24684
128a77f3b3c4
Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <mark@kingant.net>
parents:
24683
diff
changeset
|
1051 user->id = uid; |
128a77f3b3c4
Keep track of the user ID in the MsimUser struct so that we have a copy
Mark Doliner <mark@kingant.net>
parents:
24683
diff
changeset
|
1052 /* Keep track of the user ID across sessions */ |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1053 purple_blist_node_set_int(&buddy->node, "UserID", uid); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1054 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1055 /* Stores a few fields in the MsimUser, relevant to the buddy itself. |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1056 * AvatarURL, Headline, ContactID. */ |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1057 msim_store_user_info(session, contact_info, NULL); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1058 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1059 /* TODO: other fields, store in 'user' */ |
19256
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
1060 msim_msg_free(contact_info); |
22226
9f95357c21b9
In msim_uid2username_from_blist(), return a static string as the documentation
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22225
diff
changeset
|
1061 |
9f95357c21b9
In msim_uid2username_from_blist(), return a static string as the documentation
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22225
diff
changeset
|
1062 g_free(username); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1063 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1064 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1065 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1066 * Add first ContactID in contact_info to buddy's list. Used to add |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1067 * server-side buddies to client-side list. |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1068 * |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1069 * @return TRUE if added. |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1070 */ |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1071 static gboolean |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1072 msim_add_contact_from_server(MsimSession *session, MsimMessage *contact_info) |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1073 { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1074 guint uid; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1075 const gchar *username; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1076 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1077 uid = msim_msg_get_integer(contact_info, "ContactID"); |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1078 g_return_val_if_fail(uid != 0, FALSE); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1079 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1080 /* Lookup the username, since NickName and IMName is unreliable */ |
22159 | 1081 username = msim_uid2username_from_blist(session->account, uid); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1082 if (!username) { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1083 gchar *uid_str; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1084 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1085 uid_str = g_strdup_printf("%d", uid); |
19256
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
1086 purple_debug_info("msim_add_contact_from_server", |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22478
diff
changeset
|
1087 "contact_info addr=%p\n", contact_info); |
19256
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
1088 msim_lookup_user(session, uid_str, msim_add_contact_from_server_cb, (gpointer)msim_msg_clone(contact_info)); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1089 g_free(uid_str); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1090 } else { |
19256
34a1957de14b
Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19255
diff
changeset
|
1091 msim_add_contact_from_server_cb(session, NULL, (gpointer)msim_msg_clone(contact_info)); |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1092 } |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1093 |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1094 /* Say that the contact was added, even if we're still looking up |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1095 * their username. */ |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1096 return TRUE; |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1097 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1098 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1099 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1100 * Called when contact list is received from server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1101 */ |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1102 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
1103 msim_got_contact_list(MsimSession *session, const MsimMessage *reply, gpointer user_data) |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1104 { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1105 MsimMessage *body, *body_node; |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1106 gchar *msg; |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1107 guint buddy_count; |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1108 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1109 body = msim_msg_get_dictionary(reply, "body"); |
22160 | 1110 if (!body) { |
1111 /* No friends. Not an error. */ | |
1112 return; | |
1113 } | |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1114 |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1115 buddy_count = 0; |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1116 |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1117 for (body_node = body; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1118 body_node != NULL; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1119 body_node = msim_msg_get_next_element_node(body_node)) |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1120 { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1121 MsimMessageElement *elem; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1122 |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1123 elem = (MsimMessageElement *)body_node->data; |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1124 |
19428
1fa10842eb83
In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19427
diff
changeset
|
1125 if (g_str_equal(elem->name, "ContactID")) |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1126 { |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1127 /* Will look for first contact in body_node */ |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1128 if (msim_add_contact_from_server(session, body_node)) { |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1129 ++buddy_count; |
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1130 } |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1131 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1132 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1133 |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1134 switch (GPOINTER_TO_UINT(user_data)) { |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1135 case MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS: |
23332
19ab21882b38
"This patch pluralizes a few strings that should be pluralized for
Laurynas Biveinis <laurynas.biveinis@gmail.com>
parents:
23319
diff
changeset
|
1136 msg = g_strdup_printf(ngettext("%d buddy was added or updated from the server (including buddies already on the server-side list)", |
19ab21882b38
"This patch pluralizes a few strings that should be pluralized for
Laurynas Biveinis <laurynas.biveinis@gmail.com>
parents:
23319
diff
changeset
|
1137 "%d buddies were added or updated from the server (including buddies already on the server-side list)", |
19ab21882b38
"This patch pluralizes a few strings that should be pluralized for
Laurynas Biveinis <laurynas.biveinis@gmail.com>
parents:
23319
diff
changeset
|
1138 buddy_count), |
19ab21882b38
"This patch pluralizes a few strings that should be pluralized for
Laurynas Biveinis <laurynas.biveinis@gmail.com>
parents:
23319
diff
changeset
|
1139 buddy_count); |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1140 purple_notify_info(session->account, _("Add contacts from server"), msg, NULL); |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1141 g_free(msg); |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1142 break; |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1143 |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1144 case MSIM_CONTACT_LIST_IMPORT_TOP_FRIENDS: |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1145 /* TODO */ |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1146 break; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1147 |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1148 case MSIM_CONTACT_LIST_INITIAL_FRIENDS: |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1149 /* Nothing */ |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1150 break; |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1151 } |
19354
b22a33d3fc95
Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19353
diff
changeset
|
1152 |
19255
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1153 msim_msg_free(body); |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1154 } |
1ea47b06f1a6
Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19251
diff
changeset
|
1155 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1156 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1157 * Get contact list, calling msim_got_contact_list() with |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1158 * what_to_do_after as user_data gpointer. |
24771 | 1159 * |
1160 * @param what_to_do_after should be one of the MSIM_CONTACT_LIST_* #defines. | |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1161 */ |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1162 static gboolean |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1163 msim_get_contact_list(MsimSession *session, int what_to_do_after) |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1164 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1165 return msim_send(session, |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1166 "persist", MSIM_TYPE_INTEGER, 1, |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1167 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1168 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1169 "dsn", MSIM_TYPE_INTEGER, MG_LIST_ALL_CONTACTS_DSN, |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1170 "lid", MSIM_TYPE_INTEGER, MG_LIST_ALL_CONTACTS_LID, |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1171 "uid", MSIM_TYPE_INTEGER, session->userid, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1172 "rid", MSIM_TYPE_INTEGER, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1173 msim_new_reply_callback(session, msim_got_contact_list, GUINT_TO_POINTER(what_to_do_after)), |
19462
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1174 "body", MSIM_TYPE_STRING, g_strdup(""), |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1175 NULL); |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1176 } |
105305518622
On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19442
diff
changeset
|
1177 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1178 /** Called after username is set, if necessary and we're open for business. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1179 gboolean msim_we_are_logged_on(MsimSession *session) |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
1180 { |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
1181 MsimMessage *body; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1182 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1183 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1184 |
24770
512c7c31eb21
Set the display name before marking the connection as "connected."
Mark Doliner <mark@kingant.net>
parents:
24768
diff
changeset
|
1185 /* Set display name to username (otherwise will show email address) */ |
512c7c31eb21
Set the display name before marking the connection as "connected."
Mark Doliner <mark@kingant.net>
parents:
24768
diff
changeset
|
1186 purple_connection_set_display_name(session->gc, session->username); |
512c7c31eb21
Set the display name before marking the connection as "connected."
Mark Doliner <mark@kingant.net>
parents:
24768
diff
changeset
|
1187 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1188 /* The session is now set up, ready to be connected. This emits the |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1189 * signedOn signal, so clients can now do anything with msimprpl, and |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1190 * we're ready for it (session key, userid, username all setup). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1191 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1192 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1193 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1194 body = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1195 "UserID", MSIM_TYPE_INTEGER, session->userid, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1196 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1197 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1198 /* Request IM info about ourself. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1199 msim_send(session, |
24779
e5f8d9ba84db
I'm not sure why these were strings. The official client uses integers
Mark Doliner <mark@kingant.net>
parents:
24778
diff
changeset
|
1200 "persist", MSIM_TYPE_INTEGER, 1, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1201 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
24780
d7fad2c0cf7c
Some other changes to make this more like the official client, and
Mark Doliner <mark@kingant.net>
parents:
24779
diff
changeset
|
1202 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1203 "dsn", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_DSN, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1204 "lid", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_LID, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1205 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
24780
d7fad2c0cf7c
Some other changes to make this more like the official client, and
Mark Doliner <mark@kingant.net>
parents:
24779
diff
changeset
|
1206 "UserID", MSIM_TYPE_INTEGER, session->userid, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1207 "body", MSIM_TYPE_DICTIONARY, body, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1208 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1209 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1210 /* Request MySpace info about ourself. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1211 msim_send(session, |
24779
e5f8d9ba84db
I'm not sure why these were strings. The official client uses integers
Mark Doliner <mark@kingant.net>
parents:
24778
diff
changeset
|
1212 "persist", MSIM_TYPE_INTEGER, 1, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1213 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
24780
d7fad2c0cf7c
Some other changes to make this more like the official client, and
Mark Doliner <mark@kingant.net>
parents:
24779
diff
changeset
|
1214 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1215 "dsn", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_DSN, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1216 "lid", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_LID, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1217 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1218 "body", MSIM_TYPE_STRING, g_strdup(""), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1219 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1220 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1221 /* TODO: set options (persist cmd=514,dsn=1,lid=10) */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1222 /* TODO: set blocklist */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1223 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1224 /* Notify servers of our current status. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1225 purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1226 msim_set_status(session->account, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1227 purple_account_get_active_status(session->account)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1228 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1229 /* TODO: setinfo */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1230 /* |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1231 body = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1232 "TotalFriends", MSIM_TYPE_INTEGER, 666, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1233 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1234 msim_send(session, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1235 "setinfo", MSIM_TYPE_BOOLEAN, TRUE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1236 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1237 "info", MSIM_TYPE_DICTIONARY, body, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1238 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1239 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1240 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1241 /* Disable due to problems with timeouts. TODO: fix. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1242 #ifdef MSIM_USE_KEEPALIVE |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1243 purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1244 (GSourceFunc)msim_check_alive, session); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1245 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1246 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1247 /* Check mail if they want to. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1248 if (purple_account_get_check_mail(session->account)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1249 session->inbox_handle = purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1250 (GSourceFunc)msim_check_inbox, session); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1251 msim_check_inbox(session); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1252 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1253 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1254 msim_get_contact_list(session, MSIM_CONTACT_LIST_INITIAL_FRIENDS); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1255 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1256 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1257 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1258 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1259 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1260 * Record the client version in the buddy list, from an incoming message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1261 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1262 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1263 msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1264 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1265 gchar *username, *cv; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1266 gboolean ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1267 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1268 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1269 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1270 cv = msim_msg_get_string(msg, "cv"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1271 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1272 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1273 if (!cv) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1274 /* No client version to record, don't worry about it. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1275 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1276 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1277 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1278 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1279 user = msim_find_user(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1280 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1281 if (user) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1282 user->client_cv = atol(cv); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1283 ret = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1284 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1285 ret = FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1286 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1287 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1288 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1289 g_free(cv); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1290 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1291 return ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1292 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1293 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1294 #ifdef MSIM_SEND_CLIENT_VERSION |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1295 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1296 * Send our client version to another unofficial client that understands it. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1297 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1298 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1299 msim_send_unofficial_client(MsimSession *session, gchar *username) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1300 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1301 gchar *our_info; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1302 gboolean ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1303 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1304 our_info = g_strdup_printf("Libpurple %d.%d.%d - msimprpl %s", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1305 PURPLE_MAJOR_VERSION, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1306 PURPLE_MINOR_VERSION, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1307 PURPLE_MICRO_VERSION, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1308 MSIM_PRPL_VERSION_STRING); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1309 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1310 ret = msim_send_bm(session, username, our_info, MSIM_BM_UNOFFICIAL_CLIENT); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1311 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1312 return ret; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1313 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1314 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1315 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1316 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1317 * Process incoming status messages. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1318 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1319 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1320 * @param msg Status update message. Caller frees. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1321 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1322 * @return TRUE if successful. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1323 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1324 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1325 msim_incoming_status(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1326 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1327 PurpleBuddyList *blist; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1328 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1329 GList *list; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1330 gchar *status_headline, *status_headline_escaped; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1331 gint status_code, purple_status_code; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1332 gchar *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1333 gchar *unrecognized_msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1334 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1335 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1336 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1337 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1338 /* Helpfully looked up by msim_incoming_resolve() for us. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1339 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1340 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1341 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1342 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1343 gchar *ss; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1344 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1345 ss = msim_msg_get_string(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1346 purple_debug_info("msim", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1347 "msim_status: updating status for <%s> to <%s>\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1348 username, ss ? ss : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1349 g_free(ss); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1350 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1351 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1352 /* Example fields: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1353 * |s|0|ss|Offline |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1354 * |s|1|ss|:-)|ls||ip|0|p|0 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1355 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1356 list = msim_msg_get_list(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1357 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1358 status_code = msim_msg_get_integer_from_element(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1359 purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1360 status_headline = msim_msg_get_string_from_element(g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1361 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1362 blist = purple_get_blist(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1363 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1364 /* Add buddy if not found. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1365 * TODO: Could this be responsible for #3444? */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1366 user = msim_find_user(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1367 if (!user) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1368 PurpleBuddy *buddy; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1369 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1370 purple_debug_info("msim", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1371 "msim_status: making new buddy for %s\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1372 buddy = purple_buddy_new(session->account, username, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1373 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1374 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1375 user = msim_get_user_from_buddy(buddy); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1376 user->id = msim_msg_get_integer(msg, "f"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1377 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1378 /* Keep track of the user ID across sessions */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1379 purple_blist_node_set_int(&buddy->node, "UserID", user->id); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1380 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1381 msim_store_user_info(session, msg, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1382 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1383 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1384 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1385 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1386 if (status_headline && strcmp(status_headline, "") != 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1387 /* The status headline is plaintext, but libpurple treats it as HTML, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1388 * so escape any HTML characters to their entity equivalents. */ |
24805 | 1389 status_headline_escaped = g_markup_escape_text(status_headline, -1); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1390 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1391 status_headline_escaped = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1392 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1393 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1394 g_free(status_headline); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1395 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1396 /* don't copy; let the MsimUser own the headline, memory-wise */ |
24805 | 1397 g_free(user->headline); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1398 user->headline = status_headline_escaped; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1399 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1400 /* Set user status */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1401 switch (status_code) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1402 case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1403 purple_status_code = PURPLE_STATUS_OFFLINE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1404 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1405 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1406 case MSIM_STATUS_CODE_ONLINE: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1407 purple_status_code = PURPLE_STATUS_AVAILABLE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1408 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1409 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1410 case MSIM_STATUS_CODE_AWAY: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1411 purple_status_code = PURPLE_STATUS_AWAY; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1412 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1413 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1414 case MSIM_STATUS_CODE_IDLE: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1415 /* Treat idle as an available status. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1416 purple_status_code = PURPLE_STATUS_AVAILABLE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1417 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1418 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1419 default: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1420 purple_debug_info("msim", "msim_incoming_status for %s, unknown status code %d, treating as available\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1421 username, status_code); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1422 purple_status_code = PURPLE_STATUS_AVAILABLE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1423 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1424 unrecognized_msg = g_strdup_printf("msim_incoming_status, unrecognized status code: %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1425 status_code); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1426 msim_unrecognized(session, NULL, unrecognized_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1427 g_free(unrecognized_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1428 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1429 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1430 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1431 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1432 if (status_code == MSIM_STATUS_CODE_IDLE) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1433 purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
24798
a8643ca8d2e0
Set buddies idle time to 0 when their idle. 0 is a flag to the UI that
Mark Doliner <mark@kingant.net>
parents:
24796
diff
changeset
|
1434 purple_prpl_got_user_idle(session->account, username, TRUE, 0); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1435 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1436 /* All other statuses indicate going back to non-idle. */ |
24798
a8643ca8d2e0
Set buddies idle time to 0 when their idle. 0 is a flag to the UI that
Mark Doliner <mark@kingant.net>
parents:
24796
diff
changeset
|
1437 purple_prpl_got_user_idle(session->account, username, FALSE, 0); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1438 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1439 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1440 #ifdef MSIM_SEND_CLIENT_VERSION |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1441 if (status_code == MSIM_STATUS_CODE_ONLINE) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1442 /* Secretly whisper to unofficial clients our own version as they come online */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1443 msim_send_unofficial_client(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1444 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1445 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1446 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1447 if (status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1448 /* Get information when they come online. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1449 * TODO: periodically refresh? |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1450 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1451 purple_debug_info("msim_incoming_status", "%s came online, looking up\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1452 msim_lookup_user(session, username, NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1453 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1454 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1455 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1456 msim_msg_list_free(list); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1457 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1458 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1459 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1460 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1461 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1462 * Handle an incoming instant message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1463 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1464 * @param session The session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1465 * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1466 * Should also contain username in _username from preprocessing. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1467 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1468 * @return TRUE if successful. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1469 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1470 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1471 msim_incoming_im(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1472 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1473 gchar *username, *msg_msim_markup, *msg_purple_markup; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1474 gchar *userid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1475 time_t time_received; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1476 PurpleConversation *conv; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1477 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1478 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1479 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1480 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1481 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1482 /* I know this isn't really a string... but we need it to be one for |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1483 * purple_find_conversation_with_account(). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1484 userid = msim_msg_get_string(msg, "f"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1485 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1486 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1487 purple_debug_info("msim_incoming_im", "UserID is %s", userid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1488 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1489 if (msim_is_userid(username)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1490 purple_debug_info("msim", "Ignoring message from spambot (%s) on account %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1491 username, purple_account_get_username(session->account)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1492 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1493 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1494 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1495 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1496 /* See if a conversation with their UID already exists...*/ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1497 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, userid, session->account); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1498 if (conv) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1499 /* Since the conversation exists... We need to normalize it */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1500 purple_conversation_set_name(conv, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1501 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1502 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1503 msg_msim_markup = msim_msg_get_string(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1504 g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1505 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1506 msg_purple_markup = msim_markup_to_html(session, msg_msim_markup); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1507 g_free(msg_msim_markup); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1508 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1509 time_received = msim_msg_get_integer(msg, "date"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1510 if (!time_received) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1511 purple_debug_info("msim_incoming_im", "date in message not set.\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1512 time_received = time(NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1513 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1514 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1515 serv_got_im(session->gc, username, msg_purple_markup, PURPLE_MESSAGE_RECV, time_received); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1516 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1517 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1518 g_free(msg_purple_markup); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1519 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1520 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1521 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1522 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1523 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1524 * Handle an incoming action message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1525 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1526 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1527 * @param msg |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1528 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1529 * @return TRUE if successful. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1530 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1531 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1532 msim_incoming_action(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1533 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1534 gchar *msg_text, *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1535 gboolean rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1536 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1537 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1538 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1539 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1540 msg_text = msim_msg_get_string(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1541 g_return_val_if_fail(msg_text != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1542 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1543 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1544 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1545 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1546 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%s>\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1547 msg_text, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1548 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1549 if (g_str_equal(msg_text, "%typing%")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1550 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1551 rc = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1552 } else if (g_str_equal(msg_text, "%stoptyping%")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1553 serv_got_typing_stopped(session->gc, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1554 rc = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1555 } else if (strstr(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1556 rc = msim_incoming_zap(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1557 } else if (strstr(msg_text, "!!!GroupCount=")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1558 /* TODO: support group chats. I think the number in msg_text has |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1559 * something to do with the 'gid' field. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1560 purple_debug_info("msim", "msim_incoming_action: TODO: implement #4691, group chats: %s\n", msg_text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1561 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1562 rc = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1563 } else if (strstr(msg_text, "!!!Offline=")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1564 /* TODO: support group chats. This one might mean a user |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1565 * went offline or exited the chat. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1566 purple_debug_info("msim", "msim_incoming_action: TODO: implement #4691, group chats: %s\n", msg_text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1567 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1568 rc = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1569 } else if (msim_msg_get_integer(msg, "aid") != 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1570 purple_debug_info("msim", "TODO: implement #4691, group chat from %d on %d: %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1571 msim_msg_get_integer(msg, "aid"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1572 msim_msg_get_integer(msg, "f"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1573 msg_text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1574 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1575 rc = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1576 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1577 msim_unrecognized(session, msg, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1578 "got to msim_incoming_action but unrecognized value for 'msg'"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1579 rc = FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1580 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1581 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1582 g_free(msg_text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1583 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1584 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1585 return rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1586 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1587 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1588 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1589 * Process an incoming media (message background?) message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1590 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1591 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1592 msim_incoming_media(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1593 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1594 gchar *username, *text; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1595 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1596 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1597 text = msim_msg_get_string(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1598 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1599 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1600 g_return_val_if_fail(text != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1601 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1602 purple_debug_info("msim", "msim_incoming_media: from %s, got msg=%s\n", username, text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1603 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1604 /* Media messages are sent when the user opens a window to someone. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1605 * Tell libpurple they started typing and stopped typing, to inform the Psychic |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1606 * Mode plugin so it too can open a window to the user. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1607 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1608 serv_got_typing_stopped(session->gc, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1609 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1610 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1611 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1612 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1613 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1614 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1615 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1616 * Process an incoming "unofficial client" message. The plugin for |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1617 * Miranda IM sends this message with the plugin information. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1618 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1619 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1620 msim_incoming_unofficial_client(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1621 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1622 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1623 gchar *username, *client_info; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1624 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1625 username = msim_msg_get_string(msg, "_username"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1626 client_info = msim_msg_get_string(msg, "msg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1627 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1628 g_return_val_if_fail(username != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1629 g_return_val_if_fail(client_info != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1630 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1631 purple_debug_info("msim", "msim_incoming_unofficial_client: %s is using client %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1632 username, client_info); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1633 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1634 user = msim_find_user(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1635 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1636 g_return_val_if_fail(user != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1637 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1638 if (user->client_info) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1639 g_free(user->client_info); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1640 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1641 user->client_info = client_info; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1642 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1643 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1644 /* Do not free client_info - the MsimUser now owns it. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1645 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1646 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1647 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1648 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1649 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1650 * Handle an incoming buddy message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1651 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1652 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1653 msim_incoming_bm(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1654 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1655 guint bm; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1656 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1657 bm = msim_msg_get_integer(msg, "bm"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1658 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1659 msim_incoming_bm_record_cv(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1660 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1661 switch (bm) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1662 case MSIM_BM_STATUS: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1663 return msim_incoming_status(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1664 case MSIM_BM_INSTANT: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1665 return msim_incoming_im(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1666 case MSIM_BM_ACTION: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1667 return msim_incoming_action(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1668 case MSIM_BM_MEDIA: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1669 return msim_incoming_media(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1670 case MSIM_BM_UNOFFICIAL_CLIENT: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1671 return msim_incoming_unofficial_client(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1672 default: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1673 /* Not really an IM, but show it for informational |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1674 * purposes during development. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1675 return msim_incoming_im(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1676 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1677 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1678 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1679 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1680 * Process the initial server information from the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1681 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1682 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1683 msim_process_server_info(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1684 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1685 MsimMessage *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1686 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1687 body = msim_msg_get_dictionary(msg, "body"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1688 g_return_val_if_fail(body != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1689 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1690 /* Example body: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1691 AdUnitRefreshInterval=10. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1692 AlertPollInterval=360. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1693 AllowChatRoomEmoticonSharing=False. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1694 ChatRoomUserIDs=78744676;163733130;1300326231;123521495;142663391. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1695 CurClientVersion=673. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1696 EnableIMBrowse=True. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1697 EnableIMStuffAvatars=False. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1698 EnableIMStuffZaps=False. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1699 MaxAddAllFriends=100. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1700 MaxContacts=1000. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1701 MinClientVersion=594. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1702 MySpaceIM_ENGLISH=78744676. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1703 MySpaceNowTimer=720. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1704 PersistenceDataTimeout=900. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1705 UseWebChallenge=1. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1706 WebTicketGoHome=False |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1707 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1708 Anything useful? TODO: use what is useful, and use it. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1709 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1710 purple_debug_info("msim_process_server_info", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1711 "maximum contacts: %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1712 msim_msg_get_integer(body, "MaxContacts")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1713 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1714 session->server_info = body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1715 /* session->server_info freed in msim_session_destroy */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1716 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1717 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1718 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1719 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1720 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1721 * Process a web challenge, used to login to the web site. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1722 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1723 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1724 msim_web_challenge(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1725 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1726 /* TODO: web challenge, store token. #2659. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1727 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1728 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1729 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1730 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1731 * Process a persistance message reply from the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1732 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1733 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1734 * @param msg Message reply from server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1735 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1736 * @return TRUE if successful. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1737 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1738 * msim_lookup_user sets callback for here |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1739 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1740 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1741 msim_process_reply(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1742 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1743 MSIM_USER_LOOKUP_CB cb; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1744 gpointer data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1745 guint rid, cmd, dsn, lid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1746 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1747 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1748 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1749 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1750 msim_store_user_info(session, msg, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1751 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1752 rid = msim_msg_get_integer(msg, "rid"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1753 cmd = msim_msg_get_integer(msg, "cmd"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1754 dsn = msim_msg_get_integer(msg, "dsn"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1755 lid = msim_msg_get_integer(msg, "lid"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1756 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1757 /* Unsolicited messages */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1758 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1759 if (dsn == MG_SERVER_INFO_DSN && lid == MG_SERVER_INFO_LID) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1760 return msim_process_server_info(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1761 } else if (dsn == MG_WEB_CHALLENGE_DSN && lid == MG_WEB_CHALLENGE_LID) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1762 return msim_web_challenge(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1763 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1764 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1765 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1766 /* If a callback is registered for this userid lookup, call it. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1767 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1768 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1769 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1770 if (cb) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1771 purple_debug_info("msim", "msim_process_reply: calling callback now\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1772 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
1773 cb(session, msg, data); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1774 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1775 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1776 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1777 purple_debug_info("msim", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1778 "msim_process_reply: no callback for rid %d\n", rid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1779 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1780 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1781 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1782 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1783 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1784 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1785 * Handle an error from the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1786 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1787 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1788 * @param msg The message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1789 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1790 * @return TRUE if successfully reported error. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1791 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1792 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1793 msim_error(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1794 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1795 gchar *errmsg, *full_errmsg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1796 guint err; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1797 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1798 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1799 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1800 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1801 err = msim_msg_get_integer(msg, "err"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1802 errmsg = msim_msg_get_string(msg, "errmsg"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1803 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1804 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1805 errmsg ? errmsg : "no 'errmsg' given"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1806 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1807 g_free(errmsg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1808 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1809 purple_debug_info("msim", "msim_error (sesskey=%d): %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1810 session->sesskey, full_errmsg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1811 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1812 /* Destroy session if fatal. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1813 if (msim_msg_get(msg, "fatal")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1814 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1815 purple_debug_info("msim", "fatal error, closing\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1816 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1817 switch (err) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1818 case MSIM_ERROR_INCORRECT_PASSWORD: /* Incorrect password */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1819 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1820 if (!purple_account_get_remember_password(session->account)) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1821 purple_account_set_password(session->account, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1822 #ifdef MSIM_MAX_PASSWORD_LENGTH |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1823 if (session->account->password && (strlen(session->account->password) > MSIM_MAX_PASSWORD_LENGTH)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1824 gchar *suggestion; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1825 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1826 suggestion = g_strdup_printf(_("%s Your password is " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1827 "%d characters, greater than the " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1828 "expected maximum length of %d for " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1829 "MySpaceIM. Please shorten your " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1830 "password at http://profileedit.myspace.com/index.cfm?fuseaction=accountSettings.changePassword and try again."), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1831 full_errmsg, (int) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1832 strlen(session->account->password), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1833 MSIM_MAX_PASSWORD_LENGTH); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1834 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1835 /* Replace full_errmsg. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1836 g_free(full_errmsg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1837 full_errmsg = suggestion; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1838 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1839 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1840 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1841 case MSIM_ERROR_LOGGED_IN_ELSEWHERE: /* Logged in elsewhere */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1842 reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1843 if (!purple_account_get_remember_password(session->account)) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1844 purple_account_set_password(session->account, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1845 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1846 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1847 purple_connection_error_reason (session->gc, reason, full_errmsg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1848 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1849 purple_notify_error(session->account, _("MySpaceIM Error"), full_errmsg, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1850 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1851 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1852 g_free(full_errmsg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1853 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1854 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1855 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1856 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1857 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1858 * Process a message. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1859 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1860 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1861 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1862 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1863 * @return TRUE if successful. FALSE if processing failed. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1864 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1865 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1866 msim_process(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1867 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1868 g_return_val_if_fail(session != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1869 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1870 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1871 if (msim_msg_get_integer(msg, "lc") == 1) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1872 return msim_login_challenge(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1873 } else if (msim_msg_get_integer(msg, "lc") == 2) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1874 /* return msim_we_are_logged_on(session, msg); */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1875 if (msim_is_username_set(session, msg)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1876 return msim_we_are_logged_on(session); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1877 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1878 /* No username is set... We'll wait for the callbacks to do their work */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1879 /* When they're all done, the last one will call msim_we_are_logged_on() and pick up where we left off */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1880 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1881 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1882 } else if (msim_msg_get(msg, "bm")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1883 return msim_incoming_bm(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1884 } else if (msim_msg_get(msg, "rid")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1885 return msim_process_reply(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1886 } else if (msim_msg_get(msg, "error")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1887 return msim_error(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1888 } else if (msim_msg_get(msg, "ka")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1889 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1890 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1891 msim_unrecognized(session, msg, "in msim_process"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1892 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1893 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1894 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1895 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1896 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1897 * After a uid is resolved to username, tag it with the username and submit for processing. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1898 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1899 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1900 * @param userinfo Response messsage to resolving request. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1901 * @param data MsimMessage *, the message to attach information to. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1902 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1903 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
1904 msim_incoming_resolved(MsimSession *session, const MsimMessage *userinfo, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1905 gpointer data) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1906 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1907 gchar *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1908 MsimMessage *msg, *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1909 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1910 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1911 g_return_if_fail(userinfo != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1912 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1913 body = msim_msg_get_dictionary(userinfo, "body"); |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
1914 g_return_if_fail(body != NULL); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1915 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1916 username = msim_msg_get_string(body, "UserName"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1917 g_return_if_fail(username != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1918 /* Note: username will be owned by 'msg' below. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1919 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1920 msg = (MsimMessage *)data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1921 g_return_if_fail(msg != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1922 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1923 /* TODO: more elegant solution than below. attach whole message? */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1924 /* Special elements name beginning with '_', we'll use internally within the |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1925 * program (did not come directly from the wire). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1926 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, username); /* This makes 'msg' the owner of 'username' */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1927 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1928 /* TODO: attach more useful information, like ImageURL */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1929 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1930 msim_process(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1931 |
24885
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
1932 msim_msg_free(msg); |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
1933 msim_msg_free(body); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1934 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1935 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1936 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1937 * Preprocess incoming messages, resolving as needed, calling |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1938 * msim_process() when ready to process. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1939 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1940 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1941 * @param msg MsimMessage *, freed by caller. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1942 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1943 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1944 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1945 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1946 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1947 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1948 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1949 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1950 guint uid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1951 const gchar *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1952 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1953 /* 'f' = userid message is from, in buddy messages */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1954 uid = msim_msg_get_integer(msg, "f"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1955 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1956 username = msim_uid2username_from_blist(session->account, uid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1957 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1958 if (username) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1959 /* Know username already, use it. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1960 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1961 username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1962 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1963 return msim_process(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1964 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1965 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1966 gchar *from; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1967 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1968 /* Send lookup request. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1969 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1970 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1971 from = msim_msg_get_string(msg, "f"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1972 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1973 g_free(from); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1974 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1975 /* indeterminate */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1976 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1977 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1978 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1979 /* Nothing to resolve - send directly to processing. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1980 return msim_process(session, msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1981 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1982 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1983 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1984 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1985 * Callback when input available. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1986 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1987 * @param gc_uncasted A PurpleConnection pointer. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1988 * @param source File descriptor. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1989 * @param cond PURPLE_INPUT_READ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1990 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1991 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1992 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1993 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1994 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1995 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1996 PurpleConnection *gc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1997 PurpleAccount *account; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1998 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
1999 gchar *end; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2000 int n; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2001 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2002 g_return_if_fail(gc_uncasted != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2003 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2004 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2005 gc = (PurpleConnection *)(gc_uncasted); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2006 account = purple_connection_get_account(gc); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2007 session = gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2008 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2009 /* libpurple/eventloop.h only defines these two */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2010 if (cond != PURPLE_INPUT_READ && cond != PURPLE_INPUT_WRITE) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2011 purple_debug_info("msim_input_cb", "unknown condition=%d\n", cond); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2012 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2013 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2014 _("Invalid input condition")); |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2015 return; |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2016 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2017 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2018 g_return_if_fail(cond == PURPLE_INPUT_READ); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2019 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2020 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2021 /* Mark down that we got data, so we don't timeout. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2022 session->last_comm = time(NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2023 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2024 /* If approaching end of buffer, reallocate some more memory. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2025 if (session->rxsize < session->rxoff + MSIM_READ_BUF_SIZE) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2026 purple_debug_info("msim", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2027 "msim_input_cb: %d-byte read buffer full, rxoff=%d, " "growing by %d bytes\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2028 session->rxsize, session->rxoff, MSIM_READ_BUF_SIZE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2029 session->rxsize += MSIM_READ_BUF_SIZE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2030 session->rxbuf = g_realloc(session->rxbuf, session->rxsize); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2031 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2032 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2033 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2034 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2035 purple_debug_info("msim", "dynamic buffer at %d (max %d), reading up to %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2036 session->rxoff, session->rxsize, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2037 MSIM_READ_BUF_SIZE - session->rxoff - 1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2038 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2039 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2040 * the file descriptor, but it sometimes differs from the 'source' parameter. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2041 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2042 n = recv(session->fd, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2043 session->rxbuf + session->rxoff, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2044 session->rxsize - session->rxoff - 1, 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2045 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2046 if (n < 0 && errno == EAGAIN) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2047 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2048 } else if (n < 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2049 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2050 "error=%s, source=%d, fd=%d (%X))\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2051 n, g_strerror(errno), source, session->fd, session->fd); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2052 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2053 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2054 _("Read error")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2055 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2056 } else if (n == 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2057 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2058 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2059 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2060 _("Server has disconnected")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2061 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2062 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2063 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2064 if (n + session->rxoff > session->rxsize) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2065 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2066 n, n + session->rxoff, session->rxsize); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2067 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2068 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2069 _("Read buffer full (2)")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2070 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2071 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2072 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2073 /* Null terminate */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2074 purple_debug_info("msim", "msim_input_cb: going to null terminate " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2075 "at n=%d\n", n); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2076 session->rxbuf[session->rxoff + n] = 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2077 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2078 #ifdef MSIM_CHECK_EMBEDDED_NULLS |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2079 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2080 if (strlen(session->rxbuf + session->rxoff) != n) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2081 /* Occurs after login, but it is not a null byte. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2082 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2083 "--null byte encountered?\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2084 strlen(session->rxbuf + session->rxoff), n); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2085 /*purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2086 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2087 "Invalid message - null byte on input"); */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2088 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2089 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2090 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2091 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2092 session->rxoff += n; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2093 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2094 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2095 #ifdef MSIM_DEBUG_RXBUF |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2096 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2097 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2098 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2099 /* Look for \\final\\ end markers. If found, process message. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2100 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2101 MsimMessage *msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2102 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2103 #ifdef MSIM_DEBUG_RXBUF |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2104 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2105 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2106 *end = 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2107 msg = msim_parse(session->rxbuf); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2108 if (!msg) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2109 purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2110 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2111 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2112 _("Unparseable message")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2113 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2114 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2115 /* Process message and then free it (processing function should |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2116 * clone message if it wants to keep it afterwards.) */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2117 if (!msim_preprocess_incoming(session, msg)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2118 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2119 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2120 msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2121 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2122 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2123 /* Move remaining part of buffer to beginning. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2124 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2125 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2126 session->rxsize - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2127 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2128 /* Clear end of buffer |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2129 * memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2130 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2131 } |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2132 } |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2133 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2134 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2135 * Callback when connected. Sets up input handlers. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2136 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2137 * @param data A PurpleConnection pointer. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2138 * @param source File descriptor. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2139 * @param error_message |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2140 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2141 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2142 msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2143 { |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2144 PurpleConnection *gc; |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2145 MsimSession *session; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2146 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2147 g_return_if_fail(data != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2148 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2149 gc = (PurpleConnection *)data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2150 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2151 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2152 if (source < 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2153 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2154 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2155 g_strdup_printf(_("Couldn't connect to host: %s (%d)"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2156 error_message ? error_message : "no message given", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2157 source)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2158 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2159 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2160 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2161 session->fd = source; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2162 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2163 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2164 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2165 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2166 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2167 * Start logging in to the MSIM servers. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2168 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2169 * @param acct Account information to use to login. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2170 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2171 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2172 msim_login(PurpleAccount *acct) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2173 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2174 PurpleConnection *gc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2175 const gchar *host; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2176 int port; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2177 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2178 g_return_if_fail(acct != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2179 g_return_if_fail(acct->username != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2180 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2181 purple_debug_info("msim", "logging in %s\n", acct->username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2182 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2183 gc = purple_account_get_connection(acct); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2184 gc->proto_data = msim_session_new(acct); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2185 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2186 |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2187 /* |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2188 * Lets wipe out our local list of blocked buddies. We'll get a |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2189 * list of all blocked buddies from the server, and we shouldn't |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2190 * have stuff in the local list that isn't on the server list. |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2191 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2192 while (acct->deny != NULL) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2193 purple_privacy_deny_remove(acct, acct->deny->data, TRUE); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2194 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2195 /* 1. connect to server */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2196 purple_connection_update_progress(gc, _("Connecting"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2197 0, /* which connection step this is */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2198 4); /* total number of steps */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2199 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2200 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2201 port = purple_account_get_int(acct, "port", MSIM_PORT); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2202 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2203 /* From purple.sf.net/api: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2204 * """Note that this function name can be misleading--although it is called |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2205 * "proxy connect," it is used for establishing any outgoing TCP connection, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2206 * whether through a proxy or not.""" */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2207 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2208 /* Calls msim_connect_cb when connected. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2209 if (!purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2210 /* TODO: try other ports if in auto mode, then save |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2211 * working port and try that first next time. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2212 purple_connection_error_reason (gc, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2213 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2214 _("Couldn't create socket")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2215 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2216 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2217 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2218 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2219 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2220 * Close the connection. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2221 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2222 * @param gc The connection. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2223 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2224 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2225 msim_close(PurpleConnection *gc) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2226 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2227 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2228 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2229 if (gc == NULL) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2230 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2231 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2232 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2233 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2234 if (session == NULL) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2235 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2236 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2237 gc->proto_data = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2238 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2239 if (!MSIM_SESSION_VALID(session)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2240 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2241 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2242 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2243 if (session->gc->inpa) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2244 purple_input_remove(session->gc->inpa); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2245 } |
24802
075d700fdc75
Let's actually close the socket when we sign off a myspace account.
Mark Doliner <mark@kingant.net>
parents:
24798
diff
changeset
|
2246 if (session->fd >= 0) { |
075d700fdc75
Let's actually close the socket when we sign off a myspace account.
Mark Doliner <mark@kingant.net>
parents:
24798
diff
changeset
|
2247 close(session->fd); |
075d700fdc75
Let's actually close the socket when we sign off a myspace account.
Mark Doliner <mark@kingant.net>
parents:
24798
diff
changeset
|
2248 session->fd = -1; |
075d700fdc75
Let's actually close the socket when we sign off a myspace account.
Mark Doliner <mark@kingant.net>
parents:
24798
diff
changeset
|
2249 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2250 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2251 msim_session_destroy(session); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2252 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2253 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2254 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2255 * Schedule an IM to be sent once the user ID is looked up. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2256 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2257 * @param gc Connection. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2258 * @param who A user id, email, or username to send the message to. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2259 * @param message Instant message text to send. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2260 * @param flags Flags. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2261 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2262 * @return 1 if successful or postponed, -1 if failed |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2263 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2264 * Allows sending to a user by username, email address, or userid. If |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2265 * a username or email address is given, the userid must be looked up. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2266 * This function does that by calling msim_postprocess_outgoing(). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2267 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2268 static int |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2269 msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2270 PurpleMessageFlags flags) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2271 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2272 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2273 gchar *message_msim; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2274 int rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2275 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2276 g_return_val_if_fail(gc != NULL, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2277 g_return_val_if_fail(who != NULL, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2278 g_return_val_if_fail(message != NULL, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2279 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2280 /* 'flags' has many options, not used here. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2281 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2282 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2283 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2284 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2285 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2286 message_msim = html_to_msim_markup(session, message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2287 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2288 if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2289 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2290 * return 1 even if the message could not be sent, since I don't know if |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2291 * it has failed yet--because the IM is only sent after the userid is |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2292 * retrieved from the server (which happens after this function returns). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2293 * If an error does occur, it should be logged to the IM window. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2294 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2295 rc = 1; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2296 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2297 rc = -1; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2298 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2299 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2300 g_free(message_msim); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2301 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2302 return rc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2303 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2304 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2305 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2306 * Handle when our user starts or stops typing to another user. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2307 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2308 * @param gc |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2309 * @param name The buddy name to which our user is typing to |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2310 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2311 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2312 * @return 0 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2313 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2314 static unsigned int |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2315 msim_send_typing(PurpleConnection *gc, const gchar *name, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2316 PurpleTypingState state) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2317 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2318 const gchar *typing_str; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2319 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2320 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2321 g_return_val_if_fail(gc != NULL, 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2322 g_return_val_if_fail(name != NULL, 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2323 |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2324 session = (MsimSession *)gc->proto_data; |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2325 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2326 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2327 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2328 switch (state) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2329 case PURPLE_TYPING: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2330 typing_str = "%typing%"; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2331 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2332 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2333 case PURPLE_TYPED: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2334 case PURPLE_NOT_TYPING: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2335 default: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2336 typing_str = "%stoptyping%"; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2337 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2338 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2339 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2340 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2341 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2342 return 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2343 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2344 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2345 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2346 * Callback for msim_get_info(), for when user info is received. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2347 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2348 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
2349 msim_get_info_cb(MsimSession *session, const MsimMessage *user_info_msg, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2350 gpointer data) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2351 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2352 MsimMessage *msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2353 gchar *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2354 PurpleNotifyUserInfo *user_info; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2355 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2356 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2357 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2358 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2359 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2360 orthogonality. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2361 msg = (MsimMessage *)data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2362 g_return_if_fail(msg != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2363 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2364 username = msim_msg_get_string(msg, "user"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2365 if (!username) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2366 purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2367 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2368 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2369 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2370 msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2371 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2372 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2373 user = msim_find_user(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2374 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2375 if (!user) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2376 /* User isn't on blist, create a temporary user to store info. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2377 user = g_new0(MsimUser, 1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2378 user->temporary_user = TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2379 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2380 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2381 /* Update user structure with new information */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2382 msim_store_user_info(session, user_info_msg, user); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2383 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2384 user_info = purple_notify_user_info_new(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2385 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2386 /* Append data from MsimUser to PurpleNotifyUserInfo for display, full */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2387 msim_append_user_info(session, user_info, user, TRUE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2388 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2389 purple_notify_userinfo(session->gc, username, user_info, NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2390 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2391 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2392 purple_notify_user_info_destroy(user_info); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2393 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2394 if (user->temporary_user) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2395 g_free(user->client_info); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2396 g_free(user->gender); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2397 g_free(user->location); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2398 g_free(user->headline); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2399 g_free(user->display_name); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2400 g_free(user->username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2401 g_free(user->image_url); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2402 g_free(user); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2403 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2404 g_free(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2405 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2406 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2407 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2408 * Retrieve a user's profile. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2409 * @param username Username, user ID, or email address to lookup. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2410 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2411 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2412 msim_get_info(PurpleConnection *gc, const gchar *username) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2413 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2414 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2415 MsimUser *user; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2416 gchar *user_to_lookup; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2417 MsimMessage *user_msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2418 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2419 g_return_if_fail(gc != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2420 g_return_if_fail(username != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2421 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2422 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2423 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2424 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2425 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2426 /* Obtain uid of buddy. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2427 user = msim_find_user(session, username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2428 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2429 /* If is on buddy list, lookup by uid since it is faster. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2430 if (user && user->id) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2431 user_to_lookup = g_strdup_printf("%d", user->id); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2432 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2433 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2434 user_to_lookup = g_strdup(username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2435 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2436 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2437 /* Pass the username to msim_get_info_cb(), because since we lookup |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2438 * by userid, the userinfo message will only contain the uid (not |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2439 * the username) but it would be useful to display the username too. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2440 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2441 user_msg = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2442 "user", MSIM_TYPE_STRING, g_strdup(username), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2443 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2444 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", username); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2445 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2446 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2447 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2448 g_free(user_to_lookup); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2449 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2450 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2451 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2452 * Set status using an MSIM_STATUS_CODE_* value. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2453 * @param status_code An MSIM_STATUS_CODE_* value. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2454 * @param statstring Status string, must be a dynamic string (will be freed by msim_send). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2455 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2456 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2457 msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2458 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2459 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2460 g_return_if_fail(statstring != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2461 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2462 purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2463 status_code, statstring); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2464 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2465 if (!msim_send(session, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2466 "status", MSIM_TYPE_INTEGER, status_code, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2467 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2468 "statstring", MSIM_TYPE_STRING, statstring, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2469 "locstring", MSIM_TYPE_STRING, g_strdup(""), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2470 NULL)) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2471 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2472 purple_debug_info("msim", "msim_set_status: failed to set status\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2473 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2474 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2475 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2476 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2477 * Set your status - callback for when user manually sets it. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2478 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2479 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2480 msim_set_status(PurpleAccount *account, PurpleStatus *status) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2481 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2482 PurpleStatusType *type; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2483 PurplePresence *pres; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2484 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2485 guint status_code; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2486 const gchar *message; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2487 gchar *stripped; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2488 gchar *unrecognized_msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2489 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2490 session = (MsimSession *)account->gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2491 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2492 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2493 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2494 type = purple_status_get_type(status); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2495 pres = purple_status_get_presence(status); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2496 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2497 switch (purple_status_type_get_primitive(type)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2498 case PURPLE_STATUS_AVAILABLE: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2499 purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2500 MSIM_STATUS_CODE_ONLINE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2501 status_code = MSIM_STATUS_CODE_ONLINE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2502 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2503 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2504 case PURPLE_STATUS_INVISIBLE: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2505 purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2506 MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2507 status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2508 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2509 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2510 case PURPLE_STATUS_AWAY: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2511 purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2512 MSIM_STATUS_CODE_AWAY); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2513 status_code = MSIM_STATUS_CODE_AWAY; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2514 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2515 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2516 default: |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2517 purple_debug_info("msim", "msim_set_status: unknown " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2518 "status interpreting as online"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2519 status_code = MSIM_STATUS_CODE_ONLINE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2520 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2521 unrecognized_msg = g_strdup_printf("msim_set_status, unrecognized status type: %d\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2522 purple_status_type_get_primitive(type)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2523 msim_unrecognized(session, NULL, unrecognized_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2524 g_free(unrecognized_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2525 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2526 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2527 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2528 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2529 message = purple_status_get_attr_string(status, "message"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2530 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2531 /* Status strings are plain text. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2532 if (message != NULL) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2533 stripped = purple_markup_strip_html(message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2534 else |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2535 stripped = g_strdup(""); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2536 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2537 msim_set_status_code(session, status_code, stripped); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2538 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2539 /* If we should be idle, set that status. Time is irrelevant here. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2540 if (purple_presence_is_idle(pres) && status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2541 msim_set_idle(account->gc, 1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2542 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2543 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2544 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2545 * Go idle. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2546 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2547 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2548 msim_set_idle(PurpleConnection *gc, int time) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2549 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2550 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2551 PurpleStatus *status; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2552 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2553 g_return_if_fail(gc != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2554 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2555 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2556 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2557 g_return_if_fail(MSIM_SESSION_VALID(session)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2558 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2559 status = purple_account_get_active_status(session->account); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2560 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2561 if (time == 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2562 /* Going back from idle. In msim, idle is mutually exclusive |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2563 * from the other states (you can only be away or idle, but not |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2564 * both, for example), so by going non-idle I go back to what |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2565 * libpurple says I should be. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2566 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2567 msim_set_status(session->account, status); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2568 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2569 const gchar *message; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2570 gchar *stripped; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2571 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2572 /* Set the idle message to the status message from the real |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2573 * current status. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2574 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2575 message = purple_status_get_attr_string(status, "message"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2576 if (message != NULL) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2577 stripped = purple_markup_strip_html(message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2578 else |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2579 stripped = g_strdup(""); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2580 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2581 /* msim doesn't support idle time, so just go idle */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2582 msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, stripped); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2583 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2584 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2585 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2586 /** |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2587 * @return TRUE if everything was ok, FALSE if something went awry. |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2588 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2589 static gboolean |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2590 msim_update_blocklist_for_buddy(MsimSession *session, const char *name, gboolean allow, gboolean block) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2591 { |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2592 MsimMessage *msg; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2593 GList *list; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2594 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2595 list = NULL; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2596 list = g_list_prepend(list, allow ? "a+" : "a-"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2597 list = g_list_prepend(list, "<uid>"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2598 list = g_list_prepend(list, block ? "b+" : "b-"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2599 list = g_list_prepend(list, "<uid>"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2600 list = g_list_reverse(list); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2601 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2602 msg = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2603 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2604 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2605 /* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2606 /* "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2607 "idlist", MSIM_TYPE_LIST, list, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2608 NULL); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2609 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2610 if (!msim_postprocess_outgoing(session, msg, name, "idlist", NULL)) { |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2611 purple_debug_error("myspace", |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2612 "blocklist command failed for %s, allow=%d, block=%d\n", |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2613 name, allow, block); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2614 msim_msg_free(msg); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2615 return FALSE; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2616 } |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2617 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2618 msim_msg_free(msg); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2619 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2620 return TRUE; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2621 } |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2622 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2623 /** |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2624 * Add a buddy to user's buddy list. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2625 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2626 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2627 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2628 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2629 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2630 MsimMessage *msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2631 MsimMessage *msg_persist; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2632 MsimMessage *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2633 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2634 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2635 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2636 buddy->name, (group && group->name) ? group->name : "(no group)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2637 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2638 msg = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2639 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2640 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2641 /* "newprofileid" will be inserted here with uid. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2642 "reason", MSIM_TYPE_STRING, g_strdup(""), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2643 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2644 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2645 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2646 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2647 msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2648 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2649 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2650 msim_msg_free(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2651 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2652 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2653 * buddy list since Purple adds it locally. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2654 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2655 body = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2656 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2657 "GroupName", MSIM_TYPE_STRING, g_strdup(group->name), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2658 "Position", MSIM_TYPE_INTEGER, 1000, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2659 "Visibility", MSIM_TYPE_INTEGER, 1, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2660 "NickName", MSIM_TYPE_STRING, g_strdup(""), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2661 "NameSelect", MSIM_TYPE_INTEGER, 0, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2662 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2663 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2664 /* TODO: Update blocklist. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2665 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2666 msg_persist = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2667 "persist", MSIM_TYPE_INTEGER, 1, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2668 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2669 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2670 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2671 "uid", MSIM_TYPE_INTEGER, session->userid, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2672 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2673 /* TODO: Use msim_new_reply_callback to get rid. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2674 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2675 "body", MSIM_TYPE_DICTIONARY, body, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2676 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2677 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2678 if (!msim_postprocess_outgoing(session, msg_persist, buddy->name, "body", NULL)) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2679 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2680 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2681 msim_msg_free(msg_persist); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2682 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2683 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2684 msim_msg_free(msg_persist); |
24783
75ecd41a64ba
Fix a bug where if "Show our presence only to people on our buddy list"
Mark Doliner <mark@kingant.net>
parents:
24782
diff
changeset
|
2685 |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2686 /* Add to allow list, remove from block list */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2687 msim_update_blocklist_for_buddy(session, buddy->name, TRUE, FALSE); |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2688 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2689 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2690 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2691 * Remove a buddy from the user's buddy list. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2692 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2693 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2694 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2695 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2696 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2697 MsimMessage *delbuddy_msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2698 MsimMessage *persist_msg; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2699 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2700 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2701 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2702 delbuddy_msg = msim_msg_new( |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2703 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2704 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2705 /* 'delprofileid' with uid will be inserted here. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2706 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2707 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2708 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2709 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2710 msim_msg_free(delbuddy_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2711 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2712 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2713 msim_msg_free(delbuddy_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2714 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2715 persist_msg = msim_msg_new( |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2716 "persist", MSIM_TYPE_INTEGER, 1, |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2717 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2718 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2719 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2720 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2721 "uid", MSIM_TYPE_INTEGER, session->userid, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2722 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2723 /* <uid> will be replaced by postprocessing */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2724 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2725 NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2726 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2727 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2728 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2729 msim_msg_free(persist_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2730 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2731 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2732 msim_msg_free(persist_msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2733 |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2734 /* |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2735 * Remove from our approve list and from our block list (this |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2736 * doesn't seem like it would be necessary, but the official client |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2737 * does it) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2738 */ |
24885
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2739 if (!msim_update_blocklist_for_buddy(session, buddy->name, FALSE, FALSE)) { |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2740 purple_notify_error(NULL, NULL, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2741 _("Failed to remove buddy"), _("blocklist command failed")); |
24885
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2742 return; |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2743 } |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2744 if (buddy->proto_data) { |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2745 msim_user_free(buddy->proto_data); |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2746 buddy->proto_data = NULL; |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2747 } |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2748 } |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2749 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2750 /** |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2751 * Remove a buddy from the user's buddy list and add them to the block list. |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2752 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2753 static void |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2754 msim_add_deny(PurpleConnection *gc, const char *name) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2755 { |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2756 MsimSession *session; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2757 MsimMessage *msg, *body; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2758 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2759 session = (MsimSession *)gc->proto_data; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2760 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2761 /* Remove from buddy list */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2762 msg = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2763 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2764 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2765 /* 'delprofileid' with uid will be inserted here. */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2766 NULL); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2767 if (!msim_postprocess_outgoing(session, msg, name, "delprofileid", NULL)) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2768 purple_debug_error("myspace", "delbuddy command failed\n"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2769 msim_msg_free(msg); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2770 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2771 /* Remove from our approve list and add to our block list */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2772 msim_update_blocklist_for_buddy(session, name, FALSE, TRUE); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2773 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2774 /* |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2775 * Add the buddy to our list of blocked contacts, so we know they |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2776 * are blocked if we log in with another client |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2777 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2778 body = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2779 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2780 "Visibility", MSIM_TYPE_INTEGER, 2, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2781 NULL); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2782 msg = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2783 "persist", MSIM_TYPE_INTEGER, 1, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2784 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2785 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2786 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2787 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2788 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2789 "body", MSIM_TYPE_DICTIONARY, body, |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2790 NULL); |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2791 if (!msim_postprocess_outgoing(session, msg, name, "body", NULL)) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2792 purple_debug_error("myspace", "add to block list command failed\n"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2793 msim_msg_free(msg); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2794 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2795 /* |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2796 * TODO: MySpace doesn't allow blocked buddies on our buddy list, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2797 * do they? If not then we need to remove the buddy from |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2798 * libpurple's buddy list. |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2799 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2800 } |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2801 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2802 /** |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2803 * Remove a buddy from the user's block list. |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2804 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2805 static void |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2806 msim_rem_deny(PurpleConnection *gc, const char *name) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2807 { |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2808 MsimSession *session; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2809 MsimMessage *msg, *body; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2810 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2811 session = (MsimSession *)gc->proto_data; |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2812 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2813 /* |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2814 * Remove from our list of blocked contacts, so we know they |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2815 * are no longer blocked if we log in with another client |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2816 */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2817 body = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2818 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2819 NULL); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2820 msg = msim_msg_new( |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2821 "persist", MSIM_TYPE_INTEGER, 1, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2822 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2823 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2824 "dsn", MSIM_TYPE_INTEGER, MC_DELETE_CONTACT_INFO_DSN, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2825 "lid", MSIM_TYPE_INTEGER, MC_DELETE_CONTACT_INFO_LID, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2826 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2827 "body", MSIM_TYPE_DICTIONARY, body, |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2828 NULL); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2829 if (!msim_postprocess_outgoing(session, msg, name, "body", NULL)) |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2830 purple_debug_error("myspace", "remove from block list command failed\n"); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2831 msim_msg_free(msg); |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2832 |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2833 /* Remove from our approve list and our block list */ |
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
2834 msim_update_blocklist_for_buddy(session, name, FALSE, FALSE); |
19249
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2835 } |
9d921dde9d9f
First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19247
diff
changeset
|
2836 |
24885
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2837 static void |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2838 msim_buddy_free(PurpleBuddy *buddy) |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2839 { |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2840 msim_user_free(buddy->proto_data); |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2841 buddy->proto_data = NULL; |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2842 } |
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
2843 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2844 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2845 * Returns a string of a username in canonical form. Basically removes all the |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2846 * spaces, lowercases the string, and looks up user IDs to usernames. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2847 * Normalizing tom, TOM, Tom, and 6221 wil all return 'tom'. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2848 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2849 * Borrowed this code from oscar_normalize. Added checking for |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2850 * "if userid, get name before normalizing" |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2851 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2852 static const char *msim_normalize(const PurpleAccount *account, const char *str) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2853 static char normalized[BUF_LEN]; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2854 char *tmp1, *tmp2; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2855 int i, j; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2856 guint id; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2857 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2858 g_return_val_if_fail(str != NULL, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2859 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2860 if (msim_is_userid(str)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2861 /* Have user ID, we need to get their username first :) */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2862 const char *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2863 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2864 /* If the account does not exist, we can't look up the user. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2865 if (!account || !account->gc) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2866 return str; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2867 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2868 id = atol(str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2869 username = msim_uid2username_from_blist((PurpleAccount *)account, id); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2870 if (!username) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2871 /* Not in buddy list... scheisse... TODO: Manual Lookup! Bug #4631 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2872 /* Note: manual lookup using msim_lookup_user() is a problem inside |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2873 * msim_normalize(), because msim_lookup_user() calls a callback function |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2874 * when the user information has been looked up, but msim_normalize() expects |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2875 * the result immediately. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2876 strncpy(normalized, str, BUF_LEN); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2877 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2878 strncpy(normalized, username, BUF_LEN); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2879 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2880 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2881 /* Have username. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2882 strncpy(normalized, str, BUF_LEN); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2883 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2884 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2885 /* Strip spaces. */ |
24922
cead8692e35f
Terminate the loop on the first null-character.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24885
diff
changeset
|
2886 for (i=0, j=0; normalized[j]; j++) { |
cead8692e35f
Terminate the loop on the first null-character.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24885
diff
changeset
|
2887 if (normalized[j] != ' ') |
cead8692e35f
Terminate the loop on the first null-character.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24885
diff
changeset
|
2888 normalized[i++] = normalized[j]; |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2889 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2890 normalized[i] = '\0'; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2891 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2892 /* Lowercase and perform UTF-8 normalization. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2893 tmp1 = g_utf8_strdown(normalized, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2894 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2895 g_snprintf(normalized, sizeof(normalized), "%s", tmp2); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2896 g_free(tmp2); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2897 g_free(tmp1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2898 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2899 /* TODO: re-add caps and spacing back to what the user wanted. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2900 * User can format their own names, for example 'msimprpl' is shown |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2901 * as 'MsIm PrPl' in the official client. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2902 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2903 * TODO: file a ticket to add this enhancement. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2904 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2905 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2906 return normalized; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2907 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2908 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2909 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2910 * Return whether the buddy can be messaged while offline. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2911 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2912 * The protocol supports offline messages in just the same way as online |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2913 * messages. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2914 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2915 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2916 msim_offline_message(const PurpleBuddy *buddy) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
2917 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2918 return TRUE; |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
2919 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
2920 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2921 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2922 * Send raw data to the server, possibly with embedded NULs. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2923 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2924 * Used in prpl_info struct, so that plugins can have the most possible |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2925 * control of what is sent over the connection. Inside this prpl, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2926 * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2927 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2928 * @param gc PurpleConnection |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2929 * @param buf Buffer to send |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2930 * @param total_bytes Size of buffer to send |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2931 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2932 * @return Bytes successfully sent, or -1 on error. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2933 */ |
24778
5f8e8b89b143
Remove a bunch of calls to msim_msg_dump(). I find it really annoying
Mark Doliner <mark@kingant.net>
parents:
24771
diff
changeset
|
2934 /* |
5f8e8b89b143
Remove a bunch of calls to msim_msg_dump(). I find it really annoying
Mark Doliner <mark@kingant.net>
parents:
24771
diff
changeset
|
2935 * TODO: This needs to do non-blocking writes and use a watcher to check |
5f8e8b89b143
Remove a bunch of calls to msim_msg_dump(). I find it really annoying
Mark Doliner <mark@kingant.net>
parents:
24771
diff
changeset
|
2936 * when the fd is available to be written to. |
5f8e8b89b143
Remove a bunch of calls to msim_msg_dump(). I find it really annoying
Mark Doliner <mark@kingant.net>
parents:
24771
diff
changeset
|
2937 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2938 static int |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2939 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2940 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2941 int total_bytes_sent; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2942 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2943 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2944 g_return_val_if_fail(gc != NULL, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2945 g_return_val_if_fail(buf != NULL, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2946 g_return_val_if_fail(total_bytes >= 0, -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2947 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2948 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2949 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2950 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2951 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2952 /* Loop until all data is sent, or a failure occurs. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2953 total_bytes_sent = 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2954 do { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2955 int bytes_sent; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2956 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2957 bytes_sent = send(session->fd, buf + total_bytes_sent, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2958 total_bytes - total_bytes_sent, 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2959 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2960 if (bytes_sent < 0) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2961 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2962 buf, g_strerror(errno)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2963 return total_bytes_sent; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2964 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2965 total_bytes_sent += bytes_sent; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2966 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2967 } while(total_bytes_sent < total_bytes); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2968 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2969 return total_bytes_sent; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2970 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2971 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2972 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2973 * Send raw data (given as a NUL-terminated string) to the server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2974 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2975 * @param session |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2976 * @param msg The raw data to send, in a NUL-terminated string. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2977 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2978 * @return TRUE if succeeded, FALSE if not. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2979 * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2980 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2981 gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2982 msim_send_raw(MsimSession *session, const gchar *msg) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2983 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2984 size_t len; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2985 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2986 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2987 g_return_val_if_fail(msg != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2988 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2989 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2990 len = strlen(msg); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2991 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2992 return msim_send_really_raw(session->gc, msg, len) == len; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2993 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2994 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2995 static GHashTable * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2996 msim_get_account_text_table(PurpleAccount *unused) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2997 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2998 GHashTable *table; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
2999 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3000 table = g_hash_table_new(g_str_hash, g_str_equal); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3001 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3002 g_hash_table_insert(table, "login_label", (gpointer)_("Email Address...")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3003 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3004 return table; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3005 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3006 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3007 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3008 * Callbacks called by Purple, to access this plugin. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3009 */ |
20057 | 3010 static PurplePluginProtocolInfo prpl_info = { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3011 /* options */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3012 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3013 | OPT_PROTO_MAIL_CHECK, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3014 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3015 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3016 NULL, /* user_splits */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3017 NULL, /* protocol_options */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3018 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3019 msim_list_icon, /* list_icon */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3020 NULL, /* list_emblems */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3021 msim_status_text, /* status_text */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3022 msim_tooltip_text, /* tooltip_text */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3023 msim_status_types, /* status_types */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3024 msim_blist_node_menu, /* blist_node_menu */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3025 NULL, /* chat_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3026 NULL, /* chat_info_defaults */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3027 msim_login, /* login */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3028 msim_close, /* close */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3029 msim_send_im, /* send_im */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3030 NULL, /* set_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3031 msim_send_typing, /* send_typing */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3032 msim_get_info, /* get_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3033 msim_set_status, /* set_status */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3034 msim_set_idle, /* set_idle */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3035 NULL, /* change_passwd */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3036 msim_add_buddy, /* add_buddy */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3037 NULL, /* add_buddies */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3038 msim_remove_buddy, /* remove_buddy */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3039 NULL, /* remove_buddies */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3040 NULL, /* add_permit */ |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
3041 msim_add_deny, /* add_deny */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3042 NULL, /* rem_permit */ |
24785
5f93e67a8bd7
Add support for blocking buddies on MySpace
Mark Doliner <mark@kingant.net>
parents:
24783
diff
changeset
|
3043 msim_rem_deny, /* rem_deny */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3044 NULL, /* set_permit_deny */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3045 NULL, /* join_chat */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3046 NULL, /* reject chat invite */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3047 NULL, /* get_chat_name */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3048 NULL, /* chat_invite */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3049 NULL, /* chat_leave */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3050 NULL, /* chat_whisper */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3051 NULL, /* chat_send */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3052 NULL, /* keepalive */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3053 NULL, /* register_user */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3054 NULL, /* get_cb_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3055 NULL, /* get_cb_away */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3056 NULL, /* alias_buddy */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3057 NULL, /* group_buddy */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3058 NULL, /* rename_group */ |
24885
c6cadb7bdcf7
A couple of memory leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24805
diff
changeset
|
3059 msim_buddy_free, /* buddy_free */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3060 NULL, /* convo_closed */ |
22100
1226083ed7e2
Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21950
diff
changeset
|
3061 msim_normalize, /* normalize */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3062 NULL, /* set_buddy_icon */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3063 NULL, /* remove_group */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3064 NULL, /* get_cb_real_name */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3065 NULL, /* set_chat_topic */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3066 NULL, /* find_blist_chat */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3067 NULL, /* roomlist_get_list */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3068 NULL, /* roomlist_cancel */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3069 NULL, /* roomlist_expand_category */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3070 NULL, /* can_receive_file */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3071 NULL, /* send_file */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3072 NULL, /* new_xfer */ |
19243
a242e014ab8c
Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19242
diff
changeset
|
3073 msim_offline_message, /* offline_message */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3074 NULL, /* whiteboard_prpl_ops */ |
19243
a242e014ab8c
Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19242
diff
changeset
|
3075 msim_send_really_raw, /* send_raw */ |
a242e014ab8c
Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19242
diff
changeset
|
3076 NULL, /* roomlist_room_serialize */ |
19713
eabc8a32b1e4
Fix up an apparently bad merge with the reserved fields here.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
3077 NULL, /* unregister_user */ |
19243
a242e014ab8c
Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19242
diff
changeset
|
3078 msim_send_attention, /* send_attention */ |
a242e014ab8c
Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19242
diff
changeset
|
3079 msim_attention_types, /* attention_types */ |
23109
718a9c287839
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23105
diff
changeset
|
3080 |
718a9c287839
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23105
diff
changeset
|
3081 sizeof(PurplePluginProtocolInfo), /* struct_size */ |
23110
bb41bdce8981
Patch from Jaywalker to let prpls add some helpful text for some account
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23109
diff
changeset
|
3082 msim_get_account_text_table, /* get_account_text_table */ |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3083 }; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3084 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3085 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3086 * Load the plugin. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3087 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3088 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3089 msim_load(PurplePlugin *plugin) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3090 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3091 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3092 if (!purple_ciphers_find_cipher("rc4")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3093 purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3094 purple_notify_error(plugin, _("Missing Cipher"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3095 _("The RC4 cipher could not be found"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3096 _("Upgrade " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3097 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3098 "plugin will not be loaded.")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3099 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3100 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3101 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3102 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3103 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3104 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3105 * Called when friends have been imported to buddy list on server. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3106 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3107 static void |
24799
c044eb54b7ac
Fix a leak in myspace prpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24798
diff
changeset
|
3108 msim_import_friends_cb(MsimSession *session, const MsimMessage *reply, gpointer user_data) |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3109 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3110 MsimMessage *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3111 gchar *completed; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3112 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3113 /* Check if the friends were imported successfully. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3114 body = msim_msg_get_dictionary(reply, "body"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3115 g_return_if_fail(body != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3116 completed = msim_msg_get_string(body, "Completed"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3117 g_return_if_fail(body != NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3118 msim_msg_free(body); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3119 if (!g_str_equal(completed, "True")) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3120 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3121 purple_debug_info("msim_import_friends_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3122 "failed to import friends: %s", completed); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3123 purple_notify_error(session->account, _("Add friends from MySpace.com"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3124 _("Importing friends failed"), NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3125 g_free(completed); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3126 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3127 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3128 g_free(completed); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3129 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3130 purple_debug_info("msim_import_friends_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3131 "added friends to server-side buddy list, requesting new contacts from server"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3132 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3133 msim_get_contact_list(session, MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3134 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3135 /* TODO: show, X friends have been added */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3136 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3137 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3138 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3139 * Import friends from myspace.com. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3140 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3141 static void msim_import_friends(PurplePluginAction *action) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3142 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3143 PurpleConnection *gc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3144 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3145 gchar *group_name; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3146 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3147 gc = (PurpleConnection *)action->context; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3148 session = (MsimSession *)gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3149 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3150 group_name = "MySpace Friends"; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3151 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3152 g_return_if_fail(msim_send(session, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3153 "persist", MSIM_TYPE_INTEGER, 1, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3154 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3155 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3156 "dsn", MSIM_TYPE_INTEGER, MC_IMPORT_ALL_FRIENDS_DSN, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3157 "lid", MSIM_TYPE_INTEGER, MC_IMPORT_ALL_FRIENDS_LID, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3158 "uid", MSIM_TYPE_INTEGER, session->userid, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3159 "rid", MSIM_TYPE_INTEGER, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3160 msim_new_reply_callback(session, msim_import_friends_cb, NULL), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3161 "body", MSIM_TYPE_STRING, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3162 g_strdup_printf("GroupName=%s", group_name), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3163 NULL)); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3164 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3165 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3166 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3167 * Actions menu for account. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3168 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3169 static GList * |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3170 msim_actions(PurplePlugin *plugin, gpointer context) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3171 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3172 PurpleConnection *gc; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3173 GList *menu; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3174 PurplePluginAction *act; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3175 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3176 gc = (PurpleConnection *)context; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3177 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3178 menu = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3179 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3180 #if 0 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3181 /* TODO: find out how */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3182 act = purple_plugin_action_new(_("Find people..."), msim_); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3183 menu = g_list_append(menu, act); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3184 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3185 act = purple_plugin_action_new(_("Change IM name..."), NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3186 menu = g_list_append(menu, act); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3187 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3188 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3189 act = purple_plugin_action_new(_("Add friends from MySpace.com"), msim_import_friends); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3190 menu = g_list_append(menu, act); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3191 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3192 return menu; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3193 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3194 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3195 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3196 * Based on MSN's plugin info comments. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3197 */ |
19721
b2d213681176
Protocol's (and other plugin's) PurplePluginInfo structs should really be
Etan Reisner <pidgin@unreliablesource.net>
parents:
19714
diff
changeset
|
3198 static PurplePluginInfo info = { |
23109
718a9c287839
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23105
diff
changeset
|
3199 PURPLE_PLUGIN_MAGIC, |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3200 PURPLE_MAJOR_VERSION, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3201 PURPLE_MINOR_VERSION, |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3202 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3203 NULL, /**< ui_requirement */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3204 0, /**< flags */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3205 NULL, /**< dependencies */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3206 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3207 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3208 "prpl-myspace", /**< id */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3209 "MySpaceIM", /**< name */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3210 MSIM_PRPL_VERSION_STRING, /**< version */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3211 /** summary */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3212 "MySpaceIM Protocol Plugin", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3213 /** description */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3214 "MySpaceIM Protocol Plugin", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3215 "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3216 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3217 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3218 msim_load, /**< load */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3219 NULL, /**< unload */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3220 NULL, /**< destroy */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3221 NULL, /**< ui_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3222 &prpl_info, /**< extra_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3223 NULL, /**< prefs_info */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3224 msim_actions, /**< msim_actions */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3225 NULL, /**< reserved1 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3226 NULL, /**< reserved2 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3227 NULL, /**< reserved3 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3228 NULL /**< reserved4 */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3229 }; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3230 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3231 #ifdef MSIM_SELF_TEST |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3232 /* |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3233 * Test functions. |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3234 * Used to test or try out the internal workings of msimprpl. If you're reading |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3235 * this code for the first time, these functions can be instructive in learning |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3236 * how msimprpl is architected. |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3237 */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3238 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3239 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3240 * Test MsimMessage for basic functionality. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3241 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3242 static int |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3243 msim_test_msg(void) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3244 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3245 MsimMessage *msg, *msg_cloned, *msg2; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3246 GList *list; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3247 gchar *packed, *packed_expected, *packed_cloned; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3248 guint failures; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3249 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3250 failures = 0; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3251 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3252 purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3253 msg = msim_msg_new(NULL); /* Create a new, empty message. */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3254 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3255 /* Append some new elements. */ |
20658
7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents:
20628
diff
changeset
|
3256 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len("XXX", 3)); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3257 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3258 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3259 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3260 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3261 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3262 msim_msg_dump("msg debug str=%s\n", msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3263 packed = msim_msg_pack(msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3264 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3265 purple_debug_info("msim", "msg packed=%s\n", packed); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3266 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3267 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3268 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3269 |
19428
1fa10842eb83
In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19427
diff
changeset
|
3270 if (!g_str_equal(packed, packed_expected)) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3271 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3272 ++failures, packed, packed_expected); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3273 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3274 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3275 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3276 msg_cloned = msim_msg_clone(msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3277 packed_cloned = msim_msg_pack(msg_cloned); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3278 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3279 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
19428
1fa10842eb83
In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19427
diff
changeset
|
3280 if (!g_str_equal(packed, packed_cloned)) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3281 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3282 ++failures, packed_cloned, packed); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3283 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3284 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3285 g_free(packed); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3286 g_free(packed_cloned); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3287 msim_msg_free(msg_cloned); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3288 msim_msg_free(msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3289 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3290 /* Try some of the more advanced functionality */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3291 list = NULL; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3292 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3293 list = g_list_prepend(list, "item3"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3294 list = g_list_prepend(list, "item2"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3295 list = g_list_prepend(list, "item1"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3296 list = g_list_prepend(list, "item0"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3297 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3298 msg = msim_msg_new(NULL); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3299 msg = msim_msg_append(msg, "string", MSIM_TYPE_STRING, g_strdup("string value")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3300 msg = msim_msg_append(msg, "raw", MSIM_TYPE_RAW, g_strdup("raw value")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3301 msg = msim_msg_append(msg, "integer", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(3140)); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3302 msg = msim_msg_append(msg, "boolean", MSIM_TYPE_BOOLEAN, GUINT_TO_POINTER(FALSE)); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3303 msg = msim_msg_append(msg, "list", MSIM_TYPE_LIST, list); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3304 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3305 msim_msg_dump("msg with list=%s\n", msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3306 purple_debug_info("msim", "msg with list packed=%s\n", msim_msg_pack(msg)); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3307 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3308 msg2 = msim_msg_new(NULL); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3309 msg2 = msim_msg_append(msg2, "outer", MSIM_TYPE_STRING, g_strdup("outer value")); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3310 msg2 = msim_msg_append(msg2, "body", MSIM_TYPE_DICTIONARY, msg); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3311 msim_msg_dump("msg with dict=%s\n", msg2); /* msg2 now 'owns' msg */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3312 purple_debug_info("msim", "msg with dict packed=%s\n", msim_msg_pack(msg2)); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3313 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3314 msim_msg_free(msg2); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3315 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3316 return failures; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3317 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3318 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3319 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3320 * Test protocol-level escaping/unescaping. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3321 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3322 static int |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3323 msim_test_escaping(void) |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3324 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3325 guint failures; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3326 gchar *raw, *escaped, *unescaped, *expected; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3327 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3328 failures = 0; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3329 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3330 purple_debug_info("msim", "\n\nTesting escaping\n"); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3331 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3332 raw = "hello/world\\hello/world"; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3333 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3334 escaped = msim_escape(raw); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3335 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3336 expected = "hello/1world/2hello/1world"; |
19428
1fa10842eb83
In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19427
diff
changeset
|
3337 if (!g_str_equal(escaped, expected)) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3338 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3339 ++failures, escaped, expected); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3340 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3341 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3342 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3343 unescaped = msim_unescape(escaped); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3344 g_free(escaped); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3345 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
19428
1fa10842eb83
In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19427
diff
changeset
|
3346 if (!g_str_equal(raw, unescaped)) { |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3347 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3348 ++failures, raw, unescaped); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3349 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3350 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3351 return failures; |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3352 } |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3353 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3354 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3355 msim_test_all(void) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3356 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3357 guint failures; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3358 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3359 failures = 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3360 failures += msim_test_msg(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3361 failures += msim_test_escaping(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3362 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3363 if (failures) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3364 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3365 } else { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3366 purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3367 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3368 exit(0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3369 } |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3370 #endif |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3371 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3372 #ifdef MSIM_CHECK_NEWER_VERSION |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3373 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3374 * Callback for when a currentversion.txt has been downloaded. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3375 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3376 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3377 msim_check_newer_version_cb(PurpleUtilFetchUrlData *url_data, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3378 gpointer user_data, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3379 const gchar *url_text, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3380 gsize len, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3381 const gchar *error_message) |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3382 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3383 GKeyFile *keyfile; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3384 GError *error; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3385 GString *data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3386 gchar *newest_filever; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3387 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3388 if (!url_text) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3389 purple_debug_info("msim_check_newer_version_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3390 "got error: %s\n", error_message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3391 return; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3392 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3393 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3394 purple_debug_info("msim_check_newer_version_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3395 "url_text=%s\n", url_text ? url_text : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3396 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3397 /* Prepend [group] so that GKeyFile can parse it (requires a group). */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3398 data = g_string_new(url_text); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3399 purple_debug_info("msim", "data=%s\n", data->str |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3400 ? data->str : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3401 data = g_string_prepend(data, "[group]\n"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3402 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3403 purple_debug_info("msim", "data=%s\n", data->str |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3404 ? data->str : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3405 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3406 /* url_text is variable=data\n...†*/ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3407 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3408 /* Check FILEVER, 1.0.716.0. 716 is build, MSIM_CLIENT_VERSION */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3409 /* New (english) version can be downloaded from SETUPURL+SETUPFILE */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3410 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3411 error = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3412 keyfile = g_key_file_new(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3413 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3414 /* Default list seperator is ;, but currentversion.txt doesn't have |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3415 * these, so set to an unused character to avoid parsing problems. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3416 g_key_file_set_list_separator(keyfile, '\0'); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3417 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3418 g_key_file_load_from_data(keyfile, data->str, data->len, |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3419 G_KEY_FILE_NONE, &error); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3420 g_string_free(data, TRUE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3421 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3422 if (error != NULL) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3423 purple_debug_info("msim_check_newer_version_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3424 "couldn't parse, error: %d %d %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3425 error->domain, error->code, error->message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3426 g_error_free(error); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3427 return; |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3428 } |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3429 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3430 gchar **ks; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3431 guint n; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3432 ks = g_key_file_get_keys(keyfile, "group", &n, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3433 purple_debug_info("msim", "n=%d\n", n); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3434 guint i; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3435 for (i = 0; ks[i] != NULL; ++i) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3436 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3437 purple_debug_info("msim", "%d=%s\n", i, ks[i]); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3438 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3439 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3440 newest_filever = g_key_file_get_string(keyfile, "group", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3441 "FILEVER", &error); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3442 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3443 purple_debug_info("msim_check_newer_version_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3444 "newest filever: %s\n", newest_filever ? |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3445 newest_filever : "(NULL)"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3446 if (error != NULL) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3447 purple_debug_info("msim_check_newer_version_cb", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3448 "error: %d %d %s\n", |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3449 error->domain, error->code, error->message); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3450 g_error_free(error); |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3451 } |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3452 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3453 g_key_file_free(keyfile); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3454 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3455 exit(0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3456 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3457 #endif |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3458 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3459 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3460 Handle a myim:addContact command, after username has been looked up. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3461 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3462 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3463 msim_uri_handler_addContact_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3464 { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3465 MsimMessage *body; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3466 gchar *username; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3467 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3468 body = msim_msg_get_dictionary(userinfo, "body"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3469 username = msim_msg_get_string(body, "UserName"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3470 msim_msg_free(body); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3471 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3472 if (!username) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3473 guint uid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3474 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3475 uid = msim_msg_get_integer(userinfo, "UserID"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3476 g_return_if_fail(uid != 0); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3477 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3478 username = g_strdup_printf("%d", uid); |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3479 } |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3480 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3481 purple_blist_request_add_buddy(session->account, username, _("Buddies"), NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3482 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3483 g_free(username); |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3484 } |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3485 |
19441
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3486 /* TODO: move uid->username resolving to IM sending and buddy adding functions, |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3487 * so that user can manually add or IM by userid and username automatically |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3488 * looked up if possible? */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3489 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3490 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3491 * Handle a myim:sendIM URI command, after username has been looked up. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3492 */ |
19441
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3493 static void |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3494 msim_uri_handler_sendIM_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3495 { |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3496 PurpleConversation *conv; |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3497 MsimMessage *body; |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3498 gchar *username; |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3499 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3500 body = msim_msg_get_dictionary(userinfo, "body"); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3501 username = msim_msg_get_string(body, "UserName"); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3502 msim_msg_free(body); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3503 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3504 if (!username) { |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3505 guint uid; |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3506 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3507 uid = msim_msg_get_integer(userinfo, "UserID"); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3508 g_return_if_fail(uid != 0); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3509 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3510 username = g_strdup_printf("%d", uid); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3511 } |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3512 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3513 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3514 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, session->account); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3515 if (!conv) { |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3516 purple_debug_info("msim_uri_handler", "creating new conversation for %s\n", username); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3517 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, session->account, username); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3518 } |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3519 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3520 /* Just open the window so the user can send an IM. */ |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3521 purple_conversation_present(conv); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3522 |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3523 g_free(username); |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3524 } |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3525 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3526 static gboolean |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3527 msim_uri_handler(const gchar *proto, const gchar *cmd, GHashTable *params) |
19441
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3528 { |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3529 PurpleAccount *account; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3530 MsimSession *session; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3531 GList *l; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3532 gchar *uid_str, *cid_str; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3533 guint uid, cid; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3534 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3535 if (g_ascii_strcasecmp(proto, "myim")) |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3536 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3537 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3538 /* Parameters are case-insensitive. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3539 uid_str = g_hash_table_lookup(params, "uid"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3540 cid_str = g_hash_table_lookup(params, "cid"); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3541 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3542 uid = uid_str ? atol(uid_str) : 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3543 cid = cid_str ? atol(cid_str) : 0; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3544 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3545 /* Need a contact. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3546 g_return_val_if_fail(cid != 0, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3547 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3548 /* TODO: if auto=true, "Add all the people on this page to my IM List!", on |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3549 * http://collect.myspace.com/index.cfm?fuseaction=im.friendslist. Don't need a cid. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3550 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3551 /* Convert numeric contact ID back to a string. Needed for looking up. Don't just |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3552 * directly use cid directly from parameters, because it might not be numeric. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3553 * It is trivial to change this to allow cID to be a username, but that's not how |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3554 * the official MySpaceIM client works, so don't provide that functionality. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3555 cid_str = g_strdup_printf("%d", cid); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3556 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3557 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3558 /* Find our account with specified user id, or use first connected account if uid=0. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3559 account = NULL; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3560 l = purple_accounts_get_all(); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3561 while (l) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3562 if (purple_account_is_connected(l->data) && |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3563 (uid == 0 || purple_account_get_int(l->data, "uid", 0) == uid)) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3564 account = l->data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3565 break; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3566 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3567 l = l->next; |
19441
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3568 } |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3569 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3570 if (!account) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3571 purple_notify_error(NULL, _("myim URL handler"), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3572 _("No suitable MySpaceIM account could be found to open this myim URL."), |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3573 _("Enable the proper MySpaceIM account and try again.")); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3574 g_free(cid_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3575 return FALSE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3576 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3577 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3578 session = (MsimSession *)account->gc->proto_data; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3579 g_return_val_if_fail(session != NULL, FALSE); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3580 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3581 /* Lookup userid to username. TODO: push this down, to IM sending/contact |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3582 * adding functions. */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3583 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3584 /* myim:sendIM?uID=USERID&cID=CONTACTID */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3585 if (!g_ascii_strcasecmp(cmd, "sendIM")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3586 msim_lookup_user(session, cid_str, (MSIM_USER_LOOKUP_CB)msim_uri_handler_sendIM_cb, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3587 g_free(cid_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3588 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3589 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3590 /* myim:addContact?uID=USERID&cID=CONTACTID */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3591 } else if (!g_ascii_strcasecmp(cmd, "addContact")) { |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3592 msim_lookup_user(session, cid_str, (MSIM_USER_LOOKUP_CB)msim_uri_handler_addContact_cb, NULL); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3593 g_free(cid_str); |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3594 return TRUE; |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3595 } |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3596 |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3597 return FALSE; |
19441
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3598 } |
bbb205c49228
For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19439
diff
changeset
|
3599 |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3600 /** |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3601 * Initialize plugin. |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3602 */ |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3603 static void |
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3604 init_plugin(PurplePlugin *plugin) |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3605 { |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3606 #ifdef MSIM_SELF_TEST |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3607 msim_test_all(); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3608 exit(0); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3609 #endif /* MSIM_SELF_TEST */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3610 |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3611 PurpleAccountOption *option; |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3612 static gboolean initialized = FALSE; |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3613 |
19598
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3614 #ifdef MSIM_CHECK_NEWER_VERSION |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3615 /* PROBLEM: MySpace's servers always return Content-Location, and |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3616 * libpurple redirects to it, infinitely, even though it is the same |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3617 * location we requested! */ |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3618 purple_util_fetch_url("http://im.myspace.com/nsis/currentversion.txt", |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3619 FALSE, /* not full URL */ |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3620 "MSIMAutoUpdateAgent", /* user agent */ |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3621 TRUE, /* use HTTP/1.1 */ |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3622 msim_check_newer_version_cb, NULL); |
339c7c8c0e08
If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19597
diff
changeset
|
3623 #endif |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3624 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3625 /* TODO: default to automatically try different ports. Make the user be |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3626 * able to set the first port to try (like LastConnectedPort in Windows client). */ |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3627 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3628 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3629 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3630 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3631 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3632 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3633 #ifdef MSIM_USER_WANTS_TO_CONFIGURE_STATUS_TEXT |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3634 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3635 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3636 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3637 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3638 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3639 #endif |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3640 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3641 #ifdef MSIM_USER_WANTS_TO_DISABLE_EMOTICONS |
19734
0844b0638f0b
The 'Send Emoticons' preferences (which is only configurable if MSIM_USER_WANTS_TO_DISABLE_EMOTICONS is defined) defaults to TRUE when used, a reasonable default. The preference, if MSIM_USER_WANTS_TO_DISABLE_EMOTICONS is defined, should do the same.
Evan Schoenberg <evan.s@dreskin.net>
parents:
19721
diff
changeset
|
3642 option = purple_account_option_bool_new(_("Send emoticons"), "emoticons", TRUE); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3643 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3644 #endif |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3645 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3646 #ifdef MSIM_USER_REALLY_CARES_ABOUT_PRECISE_FONT_SIZES |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3647 option = purple_account_option_int_new(_("Screen resolution (dots per inch)"), "dpi", MSIM_DEFAULT_DPI); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3648 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3649 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3650 option = purple_account_option_int_new(_("Base font size (points)"), "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3651 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3652 #endif |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3653 |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3654 /* Code below only runs once. Based on oscar.c's oscar_init(). */ |
24767
295464ae2d2a
No functionality change--just cleanup.
Mark Doliner <mark@kingant.net>
parents:
24764
diff
changeset
|
3655 if (initialized) |
19436
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3656 return; |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3657 |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3658 initialized = TRUE; |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3659 |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3660 purple_signal_connect(purple_get_core(), "uri-handler", &initialized, |
a62c9b9c4596
Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19435
diff
changeset
|
3661 PURPLE_CALLBACK(msim_uri_handler), NULL); |
19242
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3662 } |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3663 |
f60192409e7f
merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
diff
changeset
|
3664 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |