Mercurial > pidgin.yaz
annotate libpurple/protocols/yahoo/yahoo_aliases.c @ 20128:57e9d1ecefff
Rename PURPLE_REASON_INVALID_USERNAME to PURPLE_REASON_INVALID_SETTINGS, so it
can be used when a server parameter is required but not supplied (for example).
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Tue, 02 Oct 2007 17:16:16 +0000 |
parents | 44b4e8bd759b |
children | 0484c20b138a |
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; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 const char *id; |
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 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 if (len == 0) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 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
|
61 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 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
|
63 struct callback_data *cb = user_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 PurpleBuddy *b = NULL; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 xmlnode *item, *contacts; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 /* 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
|
68 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
|
69 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 if (contacts == NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 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
|
72 return; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 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
|
75 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 /* 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
|
77 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
|
78 /* 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
|
79 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
|
80 /* 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 /* 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
|
87 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
|
88 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
|
89 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 if (nick_name != NULL) |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 else |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 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
|
96 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 /* 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
|
98 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
|
99 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 /* 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
|
101 if (b != NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 /* 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
|
103 struct YahooUser *yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 b->proto_data=yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 /* 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
|
112 if (alias != NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 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
|
114 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
|
115 } 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
|
116 /* 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
|
117 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
|
118 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
|
119 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 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
|
122 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 } |
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 xmlnode_free(contacts); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 g_free(cb); |
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 void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 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
|
132 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 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
|
134 struct callback_data *cb; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 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
|
136 int inttmp; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 /* 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
|
139 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
|
140 cb->gc = gc; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 /* 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
|
143 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
|
144 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
|
145 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
|
146 "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
|
147 "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
|
148 "Host: %s\r\n" |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 "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
|
150 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
|
151 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 /* We have a URL and some header information, let's connect and get some aliases */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 g_free(url); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 g_free(request); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 } |
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 /************************************************************************** |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 * Alias Update Functions |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 **************************************************************************/ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 static void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 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
|
165 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 xmlnode *node, *result; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 struct callback_data *cb = user_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 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
|
170 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 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
|
172 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 if (result == NULL) { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 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
|
175 return; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 } |
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 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
|
179 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
|
180 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
|
181 else |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 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
|
183 } else { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 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
|
185 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 g_free(cb); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 xmlnode_free(result); |
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 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 void |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 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
|
193 { |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 struct yahoo_data *yd; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 struct YahooUser *yu; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 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
|
197 int inttmp; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 struct callback_data *cb; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 PurpleBuddy *buddy; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 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
|
206 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 return; |
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 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 yd = gc->proto_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 yu = buddy->proto_data; |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 /* 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
|
217 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
|
218 cb->id = g_strdup(yu->id); |
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 /* 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
|
221 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
|
222 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
|
223 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 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
|
225 "<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
|
226 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
|
227 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 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
|
229 "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
|
230 "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
|
231 "Host: %s\r\n" |
18767
95529e8d3bb2
Get rid of this compile warning:
Mark Doliner <mark@kingant.net>
parents:
18763
diff
changeset
|
232 "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
|
233 "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
|
234 "%s", |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 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
|
236 strlen(content), content); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 /* We have a URL and some header information, let's connect and update the alias */ |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 g_free(content); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 g_free(url); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 g_free(request); |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 } |
08a6a01b7ebe
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 |