comparison libpurple/protocols/yahoo/yahoo_aliases.c @ 21284:6de09629f091

propagate from branch 'im.pidgin.pidgin.next.minor' (head 0c9637482b845cc65e95a26e144697391c51133f) to branch 'im.pidgin.pidgin' (head e3a6991e78dac328f13804950fee54dfb8afc3c5)
author Ka-Hing Cheung <khc@hxbc.us>
date Sat, 10 Nov 2007 04:52:20 +0000
parents af40f2766881 abd768f06e7b
children b0ed2ce8514d 4ab154a14e55
comparison
equal deleted inserted replaced
21283:406aa3be6b32 21284:6de09629f091
61 struct yahoo_data *yd = gc->proto_data; 61 struct yahoo_data *yd = gc->proto_data;
62 62
63 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 63 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
64 64
65 if (len == 0) { 65 if (len == 0) {
66 purple_debug_info("yahoo","No Aliases to process\n"); 66 purple_debug_info("yahoo", "No Aliases to process.%s%s\n",
67 error_message ? " Error:" : "", error_message ? error_message : "");
67 } else { 68 } else {
68 const char *yid, *full_name, *nick_name, *alias, *id, *fn, *ln, *nn; 69 const char *yid, *full_name, *nick_name, *alias, *id, *fn, *ln, *nn;
69 PurpleBuddy *b = NULL; 70 PurpleBuddy *b = NULL;
70 xmlnode *item, *contacts; 71 xmlnode *item, *contacts;
71 72
136 void 137 void
137 yahoo_fetch_aliases(PurpleConnection *gc) 138 yahoo_fetch_aliases(PurpleConnection *gc)
138 { 139 {
139 struct yahoo_data *yd = gc->proto_data; 140 struct yahoo_data *yd = gc->proto_data;
140 struct callback_data *cb; 141 struct callback_data *cb;
141 char *url, *request, *webpage, *webaddress, *strtmp; 142 const char *url = YAHOO_ALIAS_FETCH_URL;
142 int inttmp; 143 char *request, *webpage, *webaddress;
143 PurpleUtilFetchUrlData *url_data; 144 PurpleUtilFetchUrlData *url_data;
144 145
145 /* Using callback_data so I have access to gc in the callback function */ 146 /* Using callback_data so I have access to gc in the callback function */
146 cb = g_new0(struct callback_data, 1); 147 cb = g_new0(struct callback_data, 1);
147 cb->gc = gc; 148 cb->gc = gc;
148 149
149 /* Build all the info to make the web request */ 150 /* Build all the info to make the web request */
150 url = g_strdup(YAHOO_ALIAS_FETCH_URL); 151 purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL);
151 purple_url_parse(url, &webaddress, &inttmp, &webpage, &strtmp, &strtmp);
152 request = g_strdup_printf("GET /%s HTTP/1.1\r\n" 152 request = g_strdup_printf("GET /%s HTTP/1.1\r\n"
153 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" 153 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
154 "Cookie: T=%s; Y=%s\r\n" 154 "Cookie: T=%s; Y=%s\r\n"
155 "Host: %s\r\n" 155 "Host: %s\r\n"
156 "Cache-Control: no-cache\r\n\r\n", 156 "Cache-Control: no-cache\r\n\r\n",
158 158
159 /* We have a URL and some header information, let's connect and get some aliases */ 159 /* We have a URL and some header information, let's connect and get some aliases */
160 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); 160 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb);
161 if (url_data != NULL) { 161 if (url_data != NULL) {
162 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 162 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
163 } else { 163 }
164 g_free(cb); 164
165 } 165 g_free(webaddress);
166 166 g_free(webpage);
167 g_free(url);
168 g_free(request); 167 g_free(request);
169 } 168 }
170 169
171 /************************************************************************** 170 /**************************************************************************
172 * Alias Update Functions 171 * Alias Update Functions
181 struct yahoo_data *yd; 180 struct yahoo_data *yd;
182 181
183 yd = gc->proto_data; 182 yd = gc->proto_data;
184 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 183 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
185 184
185 if (len == 0 || error_message != NULL) {
186 purple_debug_info("yahoo", "Error updating alias: %s\n",
187 error_message ? error_message : "");
188 g_free(cb->id);
189 g_free(cb);
190 return;
191 }
192
186 result = xmlnode_from_str(url_text, -1); 193 result = xmlnode_from_str(url_text, -1);
187 194
188 purple_debug_info("yahoo", "ID: %s, Return data: %s\n",cb->id, url_text); 195 purple_debug_info("yahoo", "ID: %s, Return data: %s\n",cb->id, url_text);
189 196
190 if (result == NULL) { 197 if (result == NULL) {
191 purple_debug_error("yahoo","Alias update faild: Badly formed response\n"); 198 purple_debug_error("yahoo","Alias update failed: Badly formed response\n");
199 g_free(cb->id);
200 g_free(cb);
192 return; 201 return;
193 } 202 }
194 203
195 if ((node = xmlnode_get_child(result, "ct"))) { 204 if ((node = xmlnode_get_child(result, "ct"))) {
196 if (g_ascii_strncasecmp(xmlnode_get_attrib(node, "id"), cb->id, strlen(cb->id))==0) 205 if (g_ascii_strncasecmp(xmlnode_get_attrib(node, "id"), cb->id, strlen(cb->id))==0)
257 266
258 /* We have a URL and some header information, let's connect and update the alias */ 267 /* We have a URL and some header information, let's connect and update the alias */
259 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); 268 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb);
260 if (url_data != NULL) { 269 if (url_data != NULL) {
261 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 270 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
262 } else {
263 g_free(cb->id);
264 g_free(cb);
265 } 271 }
266 272
267 g_free(content); 273 g_free(content);
268 g_free(url); 274 g_free(url);
269 g_free(request); 275 g_free(request);