Mercurial > pidgin.yaz
changeset 25648:16543025aed1
Moved jingle.c global variable "sessions" into JabberStream.
Allows media sessions between two accounts in the same client.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Sat, 24 May 2008 01:40:34 +0000 |
parents | e1c8ec1259de |
children | 6bf2dfb350c0 |
files | libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/jingle.c libpurple/protocols/jabber/jingle.h |
diffstat | 4 files changed, 29 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c Fri May 23 02:42:32 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Sat May 24 01:40:34 2008 +0000 @@ -632,6 +632,10 @@ js->keepalive_timeout = -1; js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user->domain); +#ifdef USE_FARSIGHT + js->sessions = NULL; +#endif + if(!js->user) { purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, @@ -1244,12 +1248,15 @@ #ifdef USE_FARSIGHT /* Close all of the open media sessions on this stream */ - GList *iter = jabber_jingle_session_find_by_js(js); + GList *values = g_hash_table_get_values(js->sessions); + GList *iter = values; for (; iter; iter = iter->next) { JingleSession *session = (JingleSession *)iter->data; purple_media_hangup(session->media); } + + g_list_free(values); #endif /* Don't perform any actions on the ssl connection @@ -2625,7 +2632,7 @@ xmlnode *content = xmlnode_get_child(jingle, "content"); const char *sid = xmlnode_get_attrib(jingle, "sid"); const char *action = xmlnode_get_attrib(jingle, "action"); - JingleSession *session = jabber_jingle_session_find_by_id(sid); + JingleSession *session = jabber_jingle_session_find_by_id(js, sid); GList *remote_codecs = NULL; GList *remote_transports = NULL; GList *codec_intersection; @@ -2706,7 +2713,7 @@ JabberIq *result = jabber_iq_new(js, JABBER_IQ_SET); xmlnode *jingle = xmlnode_get_child(packet, "jingle"); const char *sid = xmlnode_get_attrib(jingle, "sid"); - JingleSession *session = jabber_jingle_session_find_by_id(sid); + JingleSession *session = jabber_jingle_session_find_by_id(js, sid); xmlnode_set_attrib(result->node, "to", jabber_jingle_session_get_remote_jid(session)); @@ -2732,7 +2739,7 @@ xmlnode *transport = xmlnode_get_child(content, "transport"); GList *remote_candidates = jabber_jingle_get_candidates(transport); const char *sid = xmlnode_get_attrib(jingle, "sid"); - JingleSession *session = jabber_jingle_session_find_by_id(sid); + JingleSession *session = jabber_jingle_session_find_by_id(js, sid); if(!session) purple_debug_error("jabber", "jabber_handle_session_candidates couldn't find session\n"); @@ -2757,7 +2764,7 @@ { xmlnode *jingle = xmlnode_get_child(packet, "jingle"); const char *sid = xmlnode_get_attrib(jingle, "sid"); - JingleSession *session = jabber_jingle_session_find_by_id(sid); + JingleSession *session = jabber_jingle_session_find_by_id(js, sid); if (!jabber_jingle_session_is_initiator(session) && session->session_started) { JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT); @@ -2799,7 +2806,7 @@ sid = xmlnode_get_attrib(jingle, "sid"); initiator = xmlnode_get_attrib(jingle, "initiator"); - if (jabber_jingle_session_find_by_id(sid)) { + if (jabber_jingle_session_find_by_id(js, sid)) { /* This should only happen if you start a session with yourself */ purple_debug_error("jabber", "Jingle session with id={%s} already exists\n", sid); return;
--- a/libpurple/protocols/jabber/jabber.h Fri May 23 02:42:32 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.h Sat May 24 01:40:34 2008 +0000 @@ -203,6 +203,11 @@ /* A purple timeout tag for the keepalive */ int keepalive_timeout; + +#ifdef USE_FARSIGHT + /* keep a hash table of JingleSessions */ + GHashTable *sessions; +#endif }; typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *shortname, const gchar *namespace);
--- a/libpurple/protocols/jabber/jingle.c Fri May 23 02:42:32 2008 +0000 +++ b/libpurple/protocols/jabber/jingle.c Sat May 24 01:40:34 2008 +0000 @@ -30,9 +30,6 @@ #include <gst/farsight/fs-candidate.h> -/* keep a hash table of JingleSessions */ -static GHashTable *sessions = NULL; - static gboolean jabber_jingle_session_equal(gconstpointer a, gconstpointer b) { @@ -58,13 +55,13 @@ } /* insert it into the hash table */ - if (!sessions) { + if (!js->sessions) { purple_debug_info("jingle", "Creating hash table for sessions\n"); - sessions = g_hash_table_new(g_str_hash, g_str_equal); + js->sessions = g_hash_table_new(g_str_hash, g_str_equal); } purple_debug_info("jingle", "inserting session with key: %s into table\n", sess->id); - g_hash_table_insert(sessions, sess->id, sess); + g_hash_table_insert(js->sessions, sess->id, sess); sess->session_started = FALSE; @@ -102,43 +99,25 @@ void jabber_jingle_session_destroy(JingleSession *sess) { - g_hash_table_remove(sessions, sess->id); + g_hash_table_remove(sess->js->sessions, sess->id); g_free(sess->id); g_free(sess); } JingleSession * -jabber_jingle_session_find_by_id(const char *id) +jabber_jingle_session_find_by_id(JabberStream *js, const char *id) { purple_debug_info("jingle", "find_by_id %s\n", id); - purple_debug_info("jingle", "hash table: %p\n", sessions); + purple_debug_info("jingle", "hash table: %p\n", js->sessions); purple_debug_info("jingle", "hash table size %d\n", - g_hash_table_size(sessions)); - purple_debug_info("jingle", "lookup: %p\n", g_hash_table_lookup(sessions, id)); - return (JingleSession *) g_hash_table_lookup(sessions, id); -} - -GList * -jabber_jingle_session_find_by_js(JabberStream *js) -{ - GList *values = g_hash_table_get_values(sessions); - GList *iter = values; - GList *found = NULL; - - for (; iter; iter = iter->next) { - JingleSession *session = (JingleSession *)iter->data; - if (session->js == js) { - found = g_list_prepend(found, session); - } - } - - g_list_free(values); - return found; + g_hash_table_size(js->sessions)); + purple_debug_info("jingle", "lookup: %p\n", g_hash_table_lookup(js->sessions, id)); + return (JingleSession *) g_hash_table_lookup(js->sessions, id); } JingleSession *jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid) { - GList *values = g_hash_table_get_values(sessions); + GList *values = g_hash_table_get_values(js->sessions); GList *iter = values; for (; iter; iter = iter->next) {
--- a/libpurple/protocols/jabber/jingle.h Fri May 23 02:42:32 2008 +0000 +++ b/libpurple/protocols/jabber/jingle.h Sat May 24 01:40:34 2008 +0000 @@ -47,8 +47,7 @@ void jabber_jingle_session_destroy(JingleSession *sess); -JingleSession *jabber_jingle_session_find_by_id(const char *id); -GList *jabber_jingle_session_find_by_js(JabberStream *js); +JingleSession *jabber_jingle_session_find_by_id(JabberStream *js, const char *id); JingleSession *jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid); PurpleMedia *jabber_jingle_session_get_media(const JingleSession *sess);