Mercurial > pidgin.yaz
annotate libpurple/protocols/yahoo/yahoo_aliases.c @ 20768:48ee7ec3426d
Cleanup the SOAP SSL flag to be a gboolean for clarity. Various sanity checks, sanity checking and I think a couple leak fixes too for the offline IM code.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 04 Oct 2007 01:12:08 +0000 |
parents | 0484c20b138a |
children | b93e7be3847b e3d22d8ba9f0 |
rev | line source |
---|---|
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * purple |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * source distribution. |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18767
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "internal.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "account.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "accountopt.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "blist.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "debug.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "util.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "version.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "yahoo.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "yahoo_aliases.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "yahoo_packet.h" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
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 */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
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" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
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" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 void yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 /** |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 * Stuff we want passed to the callback function |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 struct callback_data { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 PurpleConnection *gc; |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
48 char *id; |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 }; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 /************************************************************************** |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 * Alias Fetch Functions |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 **************************************************************************/ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 static void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 yahoo_fetch_aliases_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,const gchar *url_text, size_t len, const gchar *error_message) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 { |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
59 struct callback_data *cb = user_data; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
60 PurpleConnection *gc = cb->gc; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
61 struct yahoo_data *yd = gc->proto_data; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
62 |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
63 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
64 |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 if (len == 0) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 purple_debug_info("yahoo","No Aliases to process\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 const char *yid, *full_name, *nick_name, *alias, *id, *fn, *ln, *nn; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 PurpleBuddy *b = NULL; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 xmlnode *item, *contacts; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 /* Put our web response into a xmlnode for easy management */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 contacts = xmlnode_from_str(url_text, -1); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 if (contacts == NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 purple_debug_error("yahoo_aliases","Badly formed XML\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 return; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 purple_debug_info("yahoo", "Fetched %i bytes of alias data\n", len); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 /* Loop around and around and around until we have gone through all the received aliases */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 for(item = xmlnode_get_child(contacts, "ct"); item; item = xmlnode_get_next_twin(item)) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 /* Yahoo replies with two types of contact (ct) record, we are only interested in the alias ones */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 if ((yid = xmlnode_get_attrib(item, "yi"))) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 /* Grab all the bits of information we can */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 fn = xmlnode_get_attrib(item,"fn"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 ln = xmlnode_get_attrib(item,"ln"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 nn = xmlnode_get_attrib(item,"nn"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 id = xmlnode_get_attrib(item,"id"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 /* Yahoo stores first and last names separately, lets put them together into a full name */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 nick_name = (nn != NULL ? g_strstrip(g_strdup_printf("%s", nn)) : NULL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 if (nick_name != NULL) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 alias = nick_name; /* If we have a nickname from Yahoo, let's use it */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 else if (strlen(full_name) != 0) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 alias = full_name; /* If no Yahoo nickname, we can use the full_name created above */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 else |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 alias = NULL; /* No nickname, first name or last name, then you get no alias !! */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 /* Find the local buddy that matches */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 b = purple_find_buddy(cb->gc->account, yid); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 /* If we don't find a matching buddy, ignore the alias !! */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 if (b != NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 /* Create an object that we can attach to the buddies proto_data pointer */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 struct YahooUser *yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 yu = g_new0(struct YahooUser, 1); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 yu->id = g_strdup(id); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 yu->firstname = g_strdup(fn); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 yu->lastname = g_strdup(ln); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 yu->nickname = g_strdup(nn); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 b->proto_data=yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 /* Finally, if we received an alias, we better update the buddy list */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 if (alias != NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 serv_got_alias(cb->gc, yid, alias); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 purple_debug_info("yahoo","Fetched alias '%s' (%s)\n",alias,id); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 } else if (g_strcasecmp((alias!=NULL?alias:""),(b->alias!=NULL?b->alias:"")) != 0) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 /* Or if we have an alias that Yahoo doesn't, send it up */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 yahoo_update_alias(cb->gc, yid, b->alias); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 purple_debug_info("yahoo","Sent alias '%s'\n", b->alias); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 purple_debug_info("yahoo", "Bizarre, received alias for %s, but they are not on your list...\n", yid); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 xmlnode_free(contacts); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 } |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
132 g_free(cb->id); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
133 g_free(cb); |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 yahoo_fetch_aliases(PurpleConnection *gc) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 struct yahoo_data *yd = gc->proto_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 struct callback_data *cb; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 char *url, *request, *webpage, *webaddress, *strtmp; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 int inttmp; |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
143 PurpleUtilFetchUrlData *url_data; |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 /* Using callback_data so I have access to gc in the callback function */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 cb = g_new0(struct callback_data, 1); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 cb->gc = gc; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 /* Build all the info to make the web request */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 url = g_strdup(YAHOO_ALIAS_FETCH_URL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 purple_url_parse(url, &webaddress, &inttmp, &webpage, &strtmp, &strtmp); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 request = g_strdup_printf("GET /%s HTTP/1.1\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 "Cookie: T=%s; Y=%s\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 "Host: %s\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 "Cache-Control: no-cache\r\n\r\n", |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 webpage, yd->cookie_t,yd->cookie_y, webaddress); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 /* We have a URL and some header information, let's connect and get some aliases */ |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
160 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
161 if (url_data != NULL) { |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
162 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
163 } else { |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
164 g_free(cb); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
165 } |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 g_free(url); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 g_free(request); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 /************************************************************************** |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 * Alias Update Functions |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 **************************************************************************/ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 static void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 yahoo_update_alias_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,const gchar *url_text, size_t len, const gchar *error_message) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 xmlnode *node, *result; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 struct callback_data *cb = user_data; |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
180 PurpleConnection *gc = cb->gc; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
181 struct yahoo_data *yd; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
182 |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
183 yd = gc->proto_data; |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
184 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 result = xmlnode_from_str(url_text, -1); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 purple_debug_info("yahoo", "ID: %s, Return data: %s\n",cb->id, url_text); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 if (result == NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 purple_debug_error("yahoo","Alias update faild: Badly formed response\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 return; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 if ((node = xmlnode_get_child(result, "ct"))) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 if (g_ascii_strncasecmp(xmlnode_get_attrib(node, "id"), cb->id, strlen(cb->id))==0) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 purple_debug_info("yahoo", "Alias update succeeded\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 else |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 purple_debug_error("yahoo", "Alias update failed (Contact record return mismatch)\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 purple_debug_info("yahoo", "Alias update failed (No contact record returned)\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
204 g_free(cb->id); |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 g_free(cb); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 xmlnode_free(result); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 struct yahoo_data *yd; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 struct YahooUser *yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 char *content, *url, *request, *webpage, *webaddress, *strtmp; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 int inttmp; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 struct callback_data *cb; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 PurpleBuddy *buddy; |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
218 PurpleUtilFetchUrlData *url_data; |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 g_return_if_fail(alias!= NULL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 g_return_if_fail(who!=NULL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 g_return_if_fail(gc!=NULL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 purple_debug_info("yahoo", "Sending '%s' as new alias for user '%s'.\n",alias, who); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 buddy = purple_find_buddy(gc->account, who); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 if (buddy->proto_data == NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 purple_debug_info("yahoo", "Missing proto_data (get_yahoo_aliases must have failed), bailing out\n"); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 return; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 yd = gc->proto_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 yu = buddy->proto_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 /* Using callback_data so I have access to gc in the callback function */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 cb = g_new0(struct callback_data, 1); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 cb->id = g_strdup(yu->id); |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
238 cb->gc = gc; |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 /* Build all the info to make the web request */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 url = g_strdup(YAHOO_ALIAS_UPDATE_URL); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 purple_url_parse(url, &webaddress, &inttmp, &webpage, &strtmp, &strtmp); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 "<ct e=\"1\" yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n", |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 request = g_strdup_printf("POST /%s HTTP/1.1\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 "Cookie: T=%s; Y=%s\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 "Host: %s\r\n" |
18767
95529e8d3bb2
Get rid of this compile warning:
Mark Doliner <mark@kingant.net>
parents:
18763
diff
changeset
|
252 "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 "Cache-Control: no-cache\r\n\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 "%s", |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 webpage, yd->cookie_t,yd->cookie_y, webaddress, |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 strlen(content), content); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 /* We have a URL and some header information, let's connect and update the alias */ |
20222
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
259 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
260 if (url_data != NULL) { |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
261 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
262 } else { |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
263 g_free(cb->id); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
264 g_free(cb); |
0484c20b138a
applied changes from ae2654a1c8a8119292950ba10857627abf2915f8
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
265 } |
18763
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 g_free(content); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 g_free(url); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 g_free(request); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 |