diff options
author | Marcus Lundblad <malu@pidgin.im> | 2009-09-30 21:31:04 +0000 |
---|---|---|
committer | Marcus Lundblad <malu@pidgin.im> | 2009-09-30 21:31:04 +0000 |
commit | 2d61f514e340dd64d17da2e226961914d5f543d3 (patch) | |
tree | 4cc5ce68552e4bd47cb3e3fe7e94d6bd1ae3792b | |
parent | 2b16546ffd178b04f61bab66e9f6c3025c049051 (diff) | |
download | pidgin-2d61f514e340dd64d17da2e226961914d5f543d3.tar.gz |
Keep track of more than one relay request at a time (this is probably not
likely to happen, but you never know...)
-rw-r--r-- | libpurple/protocols/jabber/google.c | 33 | ||||
-rw-r--r-- | libpurple/protocols/jabber/jabber.c | 20 | ||||
-rw-r--r-- | libpurple/protocols/jabber/jabber.h | 2 |
3 files changed, 42 insertions, 13 deletions
diff --git a/libpurple/protocols/jabber/google.c b/libpurple/protocols/jabber/google.c index bf6ded119a..f778a52048 100644 --- a/libpurple/protocols/jabber/google.c +++ b/libpurple/protocols/jabber/google.c @@ -379,6 +379,21 @@ jabber_google_relay_parse_response(const gchar *response, gchar **ip, } 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 @@ jabber_google_relay_response_session_initiate_cb(PurpleUtilFetchUrlData *url_dat 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 @@ static void 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 @@ jabber_google_do_relay_request(JabberStream *js, GoogleSession *session, 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 @@ jabber_google_relay_response_session_handle_initiate_cb( 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", diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c index dc0265d391..d23e031ad8 100644 --- a/libpurple/protocols/jabber/jabber.c +++ b/libpurple/protocols/jabber/jabber.c @@ -844,7 +844,7 @@ jabber_stream_new(PurpleAccount *account) 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 @@ void jabber_close(PurpleConnection *gc) /* 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); diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h index d56889ecb0..7b02d8a7b3 100644 --- a/libpurple/protocols/jabber/jabber.h +++ b/libpurple/protocols/jabber/jabber.h @@ -276,7 +276,7 @@ struct _JabberStream /* 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 */ }; |