soc.2008.vv: 2f798ead: Moved jingle.c global variable "sessions...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Fri May 23 21:45:43 EDT 2008
-----------------------------------------------------------------
Revision: 2f798ead2a8ac504e35b2beee4c9f504537f5c59
Ancestor: fc6e10ef43f0dfaf9065bebff76a0e090460990f
Author: maiku at soc.pidgin.im
Date: 2008-05-24T01:40:34
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/2f798ead2a8ac504e35b2beee4c9f504537f5c59
Modified files:
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
libpurple/protocols/jabber/jingle.c
libpurple/protocols/jabber/jingle.h
ChangeLog:
Moved jingle.c global variable "sessions" into JabberStream.
Allows media sessions between two accounts in the same client.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 9ce5f316715cf074a44c11d571b3b23f217e730b
+++ libpurple/protocols/jabber/jabber.c 4ded5e041e185ef14223eb15984a217aa7214608
@@ -632,6 +632,10 @@ jabber_login(PurpleAccount *account)
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 @@ void jabber_close(PurpleConnection *gc)
#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 @@ jabber_handle_session_accept(JabberStrea
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 @@ jabber_handle_session_terminate(JabberSt
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 @@ jabber_handle_session_candidates(JabberS
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 @@ jabber_handle_session_content_replace(Ja
{
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 @@ jabber_handle_session_initiate(JabberStr
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;
============================================================
--- libpurple/protocols/jabber/jabber.h 25bbd79598b2f5b177fca9ae128b167664ee7861
+++ libpurple/protocols/jabber/jabber.h d8e1ae73dcb89fbf988c58ac4d6d456ceaa2be68
@@ -203,6 +203,11 @@ struct _JabberStream
/* 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);
============================================================
--- libpurple/protocols/jabber/jingle.c 5ea56e39742f641ca62cd551c502586ea30ad603
+++ libpurple/protocols/jabber/jingle.c b5b4a425f6b1587a72b739edae8c2316e9a0cf43
@@ -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 @@ jabber_jingle_session_create_internal(Ja
}
/* 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 @@ jabber_jingle_session_destroy(JingleSess
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);
+ 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);
}
-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;
-}
-
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) {
============================================================
--- libpurple/protocols/jabber/jingle.h 00b86acf0c892457226781f37d217c49463f19a5
+++ libpurple/protocols/jabber/jingle.h 5d618604c68b4a7ec2853f7770f3abfe31ef7f3e
@@ -47,8 +47,7 @@ void jabber_jingle_session_destroy(Jingl
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);
More information about the Commits
mailing list