Mercurial > pidgin
changeset 30506:e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
likely to happen, but you never know...)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Wed, 30 Sep 2009 21:31:04 +0000 |
parents | f9c28f28a4a8 |
children | 093c79fa01c7 d760797a3528 |
files | libpurple/protocols/jabber/google.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h |
diffstat | 3 files changed, 42 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/google.c Wed Sep 30 18:53:47 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Wed Sep 30 21:31:04 2009 +0000 @@ -379,6 +379,21 @@ } static void +jabber_google_relay_remove_url_data(JabberStream *js, + PurpleUtilFetchUrlData *url_data) +{ + GList *iter = js->google_relay_requests; + + while (iter) { + if (iter->data == url_data) { + js->google_relay_requests = + g_list_delete_link(js->google_relay_requests, iter); + break; + } + } +} + +static void jabber_google_relay_response_session_initiate_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) @@ -394,7 +409,9 @@ gchar *relay_username = NULL; gchar *relay_password = NULL; - js->google_relay_request = NULL; + if (url_data) { + jabber_google_relay_remove_url_data(js, url_data); + } purple_debug_info("jabber", "got response on HTTP request to relay server\n"); @@ -449,6 +466,7 @@ jabber_google_do_relay_request(JabberStream *js, GoogleSession *session, PurpleUtilFetchUrlCallback cb) { + PurpleUtilFetchUrlData *url_data = NULL; gchar *url = g_strdup_printf("http://%s", js->google_relay_host); gchar *request = g_strdup_printf("GET /create_session HTTP/1.0\r\n" @@ -458,9 +476,16 @@ js->google_relay_host, js->google_relay_token, js->google_relay_token); purple_debug_info("jabber", "sending Google relay request %s to %s\n", request, url); - js->google_relay_request = + url_data = purple_util_fetch_url_request(url, FALSE, NULL, FALSE, request, FALSE, cb, session); + if (url_data) { + js->google_relay_requests = + g_list_prepend(js->google_relay_requests, url_data); + } else { + purple_debug_error("jabber", "unable to create Google relay request\n"); + cb(NULL, session, NULL, 0, NULL); + } g_free(url); g_free(request); } @@ -542,7 +567,9 @@ GList *codecs = NULL; JabberIq *result; - js->google_relay_request = NULL; + if (url_data) { + jabber_google_relay_remove_url_data(js, url_data); + } if (url_text && len > 0) { purple_debug_info("jabber", "got Google relay request response:\n%s\n",
--- a/libpurple/protocols/jabber/jabber.c Wed Sep 30 18:53:47 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed Sep 30 21:31:04 2009 +0000 @@ -844,7 +844,7 @@ js->stun_query = NULL; js->google_relay_token = NULL; js->google_relay_host = NULL; - js->google_relay_request = NULL; + js->google_relay_requests = NULL; /* if we are idle, set idle-ness on the stream (this could happen if we get disconnected and the reconnects while being idle. I don't think it makes @@ -1569,14 +1569,16 @@ /* remove Google relay-related stuff */ g_free(js->google_relay_token); g_free(js->google_relay_host); - if (js->google_relay_request) { - purple_util_fetch_url_cancel(js->google_relay_request); - js->google_relay_request = NULL; - } - - if (js->google_relay_request != NULL) { - purple_util_fetch_url_cancel(js->google_relay_request); - js->google_relay_request = NULL; + if (js->google_relay_requests) { + while (js->google_relay_requests) { + PurpleUtilFetchUrlData *url_data = + (PurpleUtilFetchUrlData *) js->google_relay_requests->data; + purple_util_fetch_url_cancel(url_data); + g_free(url_data); + js->google_relay_requests = + g_list_delete_link(js->google_relay_requests, + js->google_relay_requests); + } } g_free(js);
--- a/libpurple/protocols/jabber/jabber.h Wed Sep 30 18:53:47 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.h Wed Sep 30 21:31:04 2009 +0000 @@ -276,7 +276,7 @@ /* stuff for Google's relay handling */ gchar *google_relay_token; gchar *google_relay_host; - PurpleUtilFetchUrlData *google_relay_request; /* the HTTP request to get */ + GList *google_relay_requests; /* the HTTP requests to get */ /* relay info */ };