Mercurial > pidgin.yaz
changeset 26207:a773b465935e
Remove static sessions variable from google.c.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Wed, 25 Feb 2009 04:59:22 +0000 |
parents | f10034e0321b |
children | 23816d2e380f |
files | libpurple/protocols/jabber/google.c |
diffstat | 1 files changed, 20 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/google.c Wed Feb 25 03:48:34 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Wed Feb 25 04:59:22 2009 +0000 @@ -57,19 +57,6 @@ char *remote_jid; } GoogleSession; -GHashTable *sessions = NULL; - -static guint -google_session_id_hash(gconstpointer key) -{ - GoogleSessionId *id = (GoogleSessionId*)key; - - guint id_hash = g_str_hash(id->id); - guint init_hash = g_str_hash(id->initiator); - - return 23 * id_hash + init_hash; -} - static gboolean google_session_id_equal(gconstpointer a, gconstpointer b) { @@ -82,8 +69,6 @@ static void google_session_destroy(GoogleSession *session) { - if (sessions != NULL) - g_hash_table_remove(sessions, &(session->id)); g_free(session->id.id); g_free(session->id.initiator); g_free(session->remote_jid); @@ -310,6 +295,8 @@ purple_media_manager_get(), js->gc, "fsrtpconference", session->remote_jid, TRUE); + purple_media_set_prpl_data(session->media, session); + params = jabber_google_session_get_params(js, &num_params); if (purple_media_add_stream(session->media, "google-voice", @@ -327,10 +314,6 @@ g_signal_connect(G_OBJECT(session->media), "state-changed", G_CALLBACK(google_session_state_changed_cb), session); - if (sessions == NULL) - sessions = g_hash_table_new(google_session_id_hash, - google_session_id_equal); - g_hash_table_insert(sessions, &(session->id), session); g_free(params); return session->media; @@ -355,6 +338,8 @@ session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc, "fsrtpconference", session->remote_jid, FALSE); + purple_media_set_prpl_data(session->media, session); + params = jabber_google_session_get_params(js, &num_params); if (purple_media_add_stream(session->media, "google-voice", session->remote_jid, @@ -501,12 +486,14 @@ jabber_google_session_parse(JabberStream *js, xmlnode *packet) { #ifdef USE_VV - GoogleSession *session; + GoogleSession *session = NULL; GoogleSessionId id; xmlnode *session_node; xmlnode *desc_node; + GList *iter = NULL; + if (strcmp(xmlnode_get_attrib(packet, "type"), "set")) return; @@ -522,9 +509,19 @@ if (!id.initiator) return; - if (sessions == NULL) - sessions = g_hash_table_new(google_session_id_hash, google_session_id_equal); - session = (GoogleSession*)g_hash_table_lookup(sessions, &id); + iter = purple_media_manager_get_media_by_connection( + purple_media_manager_get(), js->gc); + for (; iter; iter = g_list_delete_link(iter, iter)) { + GoogleSession *gsession = + purple_media_get_prpl_data(iter->data); + if (google_session_id_equal(&(gsession->id), &id)) { + session = gsession; + break; + } + } + if (iter != NULL) { + g_list_free(iter); + } if (session) { google_session_parse_iq(js, session, packet); @@ -543,7 +540,6 @@ session->state = UNINIT; session->js = js; session->remote_jid = g_strdup(session->id.initiator); - g_hash_table_insert(sessions, &(session->id), session); google_session_parse_iq(js, session, packet); #else