Thu, 17 Jan 2008 05:53:12 +0000
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
1 | /* |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
2 | * purple |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
3 | * |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
6 | * source distribution. |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
7 | * |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
11 | * (at your option) any later version. |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
12 | * |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
16 | * GNU General Public License for more details. |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
17 | * |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
21 | * |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
22 | */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
23 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
24 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
25 | #include "internal.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
26 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
27 | #include "account.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
28 | #include "accountopt.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
29 | #include "blist.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
30 | #include "debug.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
31 | #include "util.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
32 | #include "version.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
33 | #include "yahoo.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
34 | #include "yahoo_aliases.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
35 | #include "yahoo_packet.h" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
36 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
37 | /* I hate hardcoding this stuff, but Yahoo never sends us anything to use. Someone in the know may be able to tweak this URL */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
38 | #define YAHOO_ALIAS_FETCH_URL "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
39 | #define YAHOO_ALIAS_UPDATE_URL "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252" |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
40 | #define YAHOOJP_ALIAS_FETCH_URL "http://address.yahoo.co.jp/yab/jp?v=XM&prog=ymsgr&.intl=jp&diffs=1&t=0&tags=short&rt=0&prog-ver=7.0.0.7" |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
41 | #define YAHOOJP_ALIAS_UPDATE_URL "http://address.yahoo.co.jp/yab/jp?v=XM&prog=ymsgr&.intl=jp&sync=1&tags=short&noclear=1" |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
42 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
43 | void yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
44 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
45 | /** |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
46 | * Stuff we want passed to the callback function |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
47 | */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
48 | struct callback_data { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
49 | PurpleConnection *gc; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
50 | char *id; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
51 | }; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
52 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
53 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
54 | /************************************************************************** |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
55 | * Alias Fetch Functions |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
56 | **************************************************************************/ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
57 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
58 | static void |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
59 | yahoo_fetch_aliases_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,const gchar *url_text, size_t len, const gchar *error_message) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
60 | { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
61 | struct callback_data *cb = user_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
62 | PurpleConnection *gc = cb->gc; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
63 | struct yahoo_data *yd = gc->proto_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
64 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
65 | yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
66 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
67 | if (len == 0) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
68 | purple_debug_info("yahoo", "No Aliases to process.%s%s\n", |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
69 | error_message ? " Error:" : "", error_message ? error_message : ""); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
70 | } else { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
71 | const char *yid, *full_name, *nick_name, *alias, *id, *fn, *ln, *nn; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
72 | PurpleBuddy *b = NULL; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
73 | xmlnode *item, *contacts; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
74 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
75 | /* Put our web response into a xmlnode for easy management */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
76 | contacts = xmlnode_from_str(url_text, -1); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
77 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
78 | if (contacts == NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
79 | purple_debug_error("yahoo_aliases","Badly formed XML\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
80 | return; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
81 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
82 | purple_debug_info("yahoo", "Fetched %i bytes of alias data\n", len); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
83 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
84 | /* Loop around and around and around until we have gone through all the received aliases */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
85 | for(item = xmlnode_get_child(contacts, "ct"); item; item = xmlnode_get_next_twin(item)) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
86 | /* Yahoo replies with two types of contact (ct) record, we are only interested in the alias ones */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
87 | if ((yid = xmlnode_get_attrib(item, "yi"))) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
88 | /* Grab all the bits of information we can */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
89 | fn = xmlnode_get_attrib(item,"fn"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
90 | ln = xmlnode_get_attrib(item,"ln"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
91 | nn = xmlnode_get_attrib(item,"nn"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
92 | id = xmlnode_get_attrib(item,"id"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
93 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
94 | /* Yahoo stores first and last names separately, lets put them together into a full name */ |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
95 | if (yd->jp) |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
96 | full_name = g_strstrip(g_strdup_printf("%s %s", (ln != NULL ? ln : "") , (fn != NULL ? fn : ""))); |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
97 | else |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
98 | full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
99 | nick_name = (nn != NULL ? g_strstrip(g_strdup_printf("%s", nn)) : NULL); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
100 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
101 | if (nick_name != NULL) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
102 | alias = nick_name; /* If we have a nickname from Yahoo, let's use it */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
103 | else if (strlen(full_name) != 0) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
104 | alias = full_name; /* If no Yahoo nickname, we can use the full_name created above */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
105 | else |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
106 | alias = NULL; /* No nickname, first name or last name, then you get no alias !! */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
107 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
108 | /* Find the local buddy that matches */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
109 | b = purple_find_buddy(cb->gc->account, yid); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
110 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
111 | /* If we don't find a matching buddy, ignore the alias !! */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
112 | if (b != NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
113 | /* Create an object that we can attach to the buddies proto_data pointer */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
114 | struct YahooUser *yu; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
115 | yu = g_new0(struct YahooUser, 1); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
116 | yu->id = g_strdup(id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
117 | yu->firstname = g_strdup(fn); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
118 | yu->lastname = g_strdup(ln); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
119 | yu->nickname = g_strdup(nn); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
120 | b->proto_data=yu; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
121 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
122 | /* Finally, if we received an alias, we better update the buddy list */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
123 | if (alias != NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
124 | serv_got_alias(cb->gc, yid, alias); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
125 | purple_debug_info("yahoo","Fetched alias '%s' (%s)\n",alias,id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
126 | } else if (b->alias != alias && strcmp(b->alias, "") != 0) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
127 | /* Or if we have an alias that Yahoo doesn't, send it up */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
128 | yahoo_update_alias(cb->gc, yid, b->alias); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
129 | purple_debug_info("yahoo","Sent alias '%s'\n", b->alias); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
130 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
131 | } else { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
132 | purple_debug_info("yahoo", "Bizarre, received alias for %s, but they are not on your list...\n", yid); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
133 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
134 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
135 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
136 | xmlnode_free(contacts); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
137 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
138 | g_free(cb->id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
139 | g_free(cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
140 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
141 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
142 | void |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
143 | yahoo_fetch_aliases(PurpleConnection *gc) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
144 | { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
145 | struct yahoo_data *yd = gc->proto_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
146 | struct callback_data *cb; |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
147 | const char *url; |
|
21092
d6fb00bf6524
Another patch from Andrew Gaul that plugs a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
20277
diff
changeset
|
148 | char *request, *webpage, *webaddress; |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
149 | PurpleUtilFetchUrlData *url_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
150 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
151 | /* Using callback_data so I have access to gc in the callback function */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
152 | cb = g_new0(struct callback_data, 1); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
153 | cb->gc = gc; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
154 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
155 | /* Build all the info to make the web request */ |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
156 | url = yd->jp ? YAHOOJP_ALIAS_FETCH_URL : YAHOO_ALIAS_FETCH_URL; |
|
21092
d6fb00bf6524
Another patch from Andrew Gaul that plugs a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
20277
diff
changeset
|
157 | purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL); |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
158 | request = g_strdup_printf("GET /%s HTTP/1.1\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
159 | "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
160 | "Cookie: T=%s; Y=%s\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
161 | "Host: %s\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
162 | "Cache-Control: no-cache\r\n\r\n", |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
163 | webpage, yd->cookie_t,yd->cookie_y, webaddress); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
164 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
165 | /* We have a URL and some header information, let's connect and get some aliases */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
166 | url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
167 | if (url_data != NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
168 | yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
169 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
170 | |
|
21092
d6fb00bf6524
Another patch from Andrew Gaul that plugs a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
20277
diff
changeset
|
171 | g_free(webaddress); |
|
d6fb00bf6524
Another patch from Andrew Gaul that plugs a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
20277
diff
changeset
|
172 | g_free(webpage); |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
173 | g_free(request); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
174 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
175 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
176 | /************************************************************************** |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
177 | * Alias Update Functions |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
178 | **************************************************************************/ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
179 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
180 | static void |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
181 | yahoo_update_alias_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,const gchar *url_text, size_t len, const gchar *error_message) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
182 | { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
183 | xmlnode *node, *result; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
184 | struct callback_data *cb = user_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
185 | PurpleConnection *gc = cb->gc; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
186 | struct yahoo_data *yd; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
187 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
188 | yd = gc->proto_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
189 | yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
190 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
191 | if (len == 0 || error_message != NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
192 | purple_debug_info("yahoo", "Error updating alias: %s\n", |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
193 | error_message ? error_message : ""); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
194 | g_free(cb->id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
195 | g_free(cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
196 | return; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
197 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
198 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
199 | result = xmlnode_from_str(url_text, -1); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
200 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
201 | purple_debug_info("yahoo", "ID: %s, Return data: %s\n",cb->id, url_text); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
202 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
203 | if (result == NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
204 | purple_debug_error("yahoo","Alias update failed: Badly formed response\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
205 | g_free(cb->id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
206 | g_free(cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
207 | return; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
208 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
209 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
210 | if ((node = xmlnode_get_child(result, "ct"))) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
211 | if (g_ascii_strncasecmp(xmlnode_get_attrib(node, "id"), cb->id, strlen(cb->id))==0) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
212 | purple_debug_info("yahoo", "Alias update succeeded\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
213 | else |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
214 | purple_debug_error("yahoo", "Alias update failed (Contact record return mismatch)\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
215 | } else { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
216 | purple_debug_info("yahoo", "Alias update failed (No contact record returned)\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
217 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
218 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
219 | g_free(cb->id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
220 | g_free(cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
221 | xmlnode_free(result); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
222 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
223 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
224 | void |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
225 | yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias) |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
226 | { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
227 | struct yahoo_data *yd; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
228 | struct YahooUser *yu; |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
229 | char *content, *url, *request, *webpage, *webaddress, *strtmp; |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
230 | int inttmp; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
231 | struct callback_data *cb; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
232 | PurpleBuddy *buddy; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
233 | PurpleUtilFetchUrlData *url_data; |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
234 | char *alias_jp, *converted_alias_jp; |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
235 | |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
236 | g_return_if_fail(alias != NULL); |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
237 | g_return_if_fail(who != NULL); |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
238 | g_return_if_fail(gc != NULL); |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
239 | |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
240 | purple_debug_info("yahoo", "Sending '%s' as new alias for user '%s'.\n",alias, who); |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
241 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
242 | buddy = purple_find_buddy(gc->account, who); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
243 | if (buddy == NULL || buddy->proto_data == NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
244 | purple_debug_info("yahoo", "Missing proto_data (get_yahoo_aliases must have failed), bailing out\n"); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
245 | return; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
246 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
247 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
248 | yd = gc->proto_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
249 | yu = buddy->proto_data; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
250 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
251 | /* Using callback_data so I have access to gc in the callback function */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
252 | cb = g_new0(struct callback_data, 1); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
253 | cb->id = g_strdup(yu->id); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
254 | cb->gc = gc; |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
255 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
256 | /* Build all the info to make the web request */ |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
257 | url = yd->jp? YAHOOJP_ALIAS_UPDATE_URL: YAHOO_ALIAS_UPDATE_URL; |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
258 | purple_url_parse(url, &webaddress, &inttmp, &webpage, &strtmp, &strtmp); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
259 | |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
260 | if (yd->jp) { |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
261 | alias_jp = g_convert(alias, strlen(alias), "EUC-JP", "UTF-8", NULL, NULL, NULL); |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
262 | converted_alias_jp = yahoo_convert_to_numeric(alias_jp); |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
263 | content = g_strdup_printf("<ab k=\"%s\" cc=\"1\">\n" |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
264 | "<ct e=\"1\" yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n", |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
265 | gc->account->username, who, yu->id, converted_alias_jp); |
|
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
266 | free(converted_alias_jp); |
|
22242
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
267 | g_free(alias_jp); |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
268 | } |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
269 | else { |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
270 | content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n" |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
271 | "<ct e=\"1\" yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n", |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
272 | gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); |
|
f2efb6941859
Patch from Yusuke Odate, modified by me, to support retrieving the full
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21453
diff
changeset
|
273 | } |
|
20277
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
274 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
275 | request = g_strdup_printf("POST /%s HTTP/1.1\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
276 | "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
277 | "Cookie: T=%s; Y=%s\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
278 | "Host: %s\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
279 | "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
280 | "Cache-Control: no-cache\r\n\r\n" |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
281 | "%s", |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
282 | webpage, yd->cookie_t,yd->cookie_y, webaddress, |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
283 | strlen(content), content); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
284 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
285 | /* We have a URL and some header information, let's connect and update the alias */ |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
286 | url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
287 | if (url_data != NULL) { |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
288 | yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
289 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
290 | |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
291 | g_free(content); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
292 | g_free(request); |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
293 | } |
|
e10c0e405cdd
applied changes from b8d509fbf120a8eb57e6dfa96005e3c0312c2096
Daniel Atallah <datallah@pidgin.im>
parents:
20228
diff
changeset
|
294 |