soc.2008.vv: 24d7ce74: Further decoupled Jingle code from jabbe...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Mon Jun 2 18:21:04 EDT 2008
-----------------------------------------------------------------
Revision: 24d7ce74e42b7c6a85ab2f84eef9df2e6a0d7d85
Ancestor: 2e652889513f0ea3dd9a66c1b8463c673fcb0d72
Author: maiku at soc.pidgin.im
Date: 2008-06-02T21:58:39
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/24d7ce74e42b7c6a85ab2f84eef9df2e6a0d7d85
Modified files:
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jingle.c
libpurple/protocols/jabber/jingle.h
ChangeLog:
Further decoupled Jingle code from jabber.c:
* Removed unnecessary Jingle functions from the header
* Moved JingleSession structure to jingle.c
* Created functions to remove jabber.c's dependence on JingleSession:
- jabber_jingle_session_terminate_session_media
- jabber_jingle_session_terminate_sessions
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c ed2fa2eeed0d27193fd2dbe4f66df24958dd4777
+++ libpurple/protocols/jabber/jabber.c 4dea19ae0b8cba6f75752000e968a0d7b9671cae
@@ -1254,16 +1254,8 @@ void jabber_close(PurpleConnection *gc)
JabberStream *js = gc->proto_data;
#ifdef USE_VV
- /* Close all of the open media sessions on this stream */
- 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);
+ /* Close all of the open Jingle sessions on this stream */
+ jabber_jingle_session_terminate_sessions(js);
#endif
/* Don't perform any actions on the ssl connection
@@ -1889,19 +1881,12 @@ void jabber_convo_closed(PurpleConnectio
JabberID *jid;
JabberBuddy *jb;
JabberBuddyResource *jbr;
-#ifdef USE_VV
- JingleSession *session;
-#endif
+
if(!(jid = jabber_id_new(who)))
return;
#ifdef USE_VV
- session = jabber_jingle_session_find_by_jid(js, who);
-
- if (session) {
- purple_media_hangup(session->media);
- }
-
+ jabber_jingle_session_terminate_session_media(js, who);
#endif
if((jb = jabber_buddy_find(js, who, TRUE)) &&
(jbr = jabber_buddy_find_resource(jb, jid->resource))) {
============================================================
--- libpurple/protocols/jabber/jingle.c 945f8c9f72e5ef30faf7d46eb9d26377c341dd67
+++ libpurple/protocols/jabber/jingle.c 9d6f7c4a1d43e5192ca0d3ba9368fd24f92be6ee
@@ -31,6 +31,16 @@
#include <gst/farsight/fs-candidate.h>
+typedef struct {
+ char *id;
+ JabberStream *js;
+ PurpleMedia *media;
+ char *remote_jid;
+ char *initiator;
+ gboolean is_initiator;
+ gboolean session_started;
+} JingleSession;
+
static gboolean
jabber_jingle_session_equal(gconstpointer a, gconstpointer b)
{
@@ -69,13 +79,13 @@ jabber_jingle_session_create_internal(Ja
return sess;
}
-JabberStream *
+static JabberStream *
jabber_jingle_session_get_js(const JingleSession *sess)
{
return sess->js;
}
-JingleSession *
+static JingleSession *
jabber_jingle_session_create(JabberStream *js)
{
JingleSession *sess = jabber_jingle_session_create_internal(js, NULL);
@@ -83,7 +93,7 @@ jabber_jingle_session_create(JabberStrea
return sess;
}
-JingleSession *
+static JingleSession *
jabber_jingle_session_create_by_id(JabberStream *js, const char *id)
{
JingleSession *sess = jabber_jingle_session_create_internal(js, id);
@@ -91,13 +101,13 @@ jabber_jingle_session_create_by_id(Jabbe
return sess;
}
-const char *
+static const char *
jabber_jingle_session_get_id(const JingleSession *sess)
{
return sess->id;
}
-void
+static void
jabber_jingle_session_destroy(JingleSession *sess)
{
g_hash_table_remove(sess->js->sessions, sess->id);
@@ -106,7 +116,7 @@ jabber_jingle_session_destroy(JingleSess
g_free(sess);
}
-JingleSession *
+static JingleSession *
jabber_jingle_session_find_by_id(JabberStream *js, const char *id)
{
purple_debug_info("jingle", "find_by_id %s\n", id);
@@ -117,7 +127,8 @@ jabber_jingle_session_find_by_id(JabberS
return (JingleSession *) g_hash_table_lookup(js->sessions, id);
}
-JingleSession *jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid)
+static JingleSession *
+jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid)
{
GList *values = g_hash_table_get_values(js->sessions);
GList *iter = values;
@@ -139,7 +150,7 @@ JingleSession *jabber_jingle_session_fin
return NULL;
}
-GList *
+static GList *
jabber_jingle_get_codecs(const xmlnode *description)
{
GList *codecs = NULL;
@@ -162,7 +173,7 @@ jabber_jingle_get_codecs(const xmlnode *
return codecs;
}
-GList *
+static GList *
jabber_jingle_get_candidates(const xmlnode *transport)
{
GList *candidates = NULL;
@@ -192,45 +203,45 @@ jabber_jingle_get_candidates(const xmlno
return candidates;
}
-PurpleMedia *
+static PurpleMedia *
jabber_jingle_session_get_media(const JingleSession *sess)
{
return sess->media;
}
-void
+static void
jabber_jingle_session_set_media(JingleSession *sess, PurpleMedia *media)
{
sess->media = media;
}
-const char *
+static const char *
jabber_jingle_session_get_remote_jid(const JingleSession *sess)
{
return sess->remote_jid;
}
-void
+static void
jabber_jingle_session_set_remote_jid(JingleSession *sess,
const char *remote_jid)
{
sess->remote_jid = strdup(remote_jid);
}
-const char *
+static const char *
jabber_jingle_session_get_initiator(const JingleSession *sess)
{
return sess->initiator;
}
-void
+static void
jabber_jingle_session_set_initiator(JingleSession *sess,
const char *initiator)
{
sess->initiator = g_strdup(initiator);
}
-gboolean
+static gboolean
jabber_jingle_session_is_initiator(const JingleSession *sess)
{
return sess->is_initiator;
@@ -254,7 +265,7 @@ jabber_jingle_session_create_jingle_elem
return jingle;
}
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_terminate(const JingleSession *sess,
const char *reasoncode,
const char *reasontext)
@@ -270,7 +281,7 @@ jabber_jingle_session_create_terminate(c
return jingle;
}
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_description(const JingleSession *sess)
{
GList *codecs = purple_media_get_local_audio_codecs(sess->media);
@@ -372,7 +383,7 @@ jabber_jingle_session_create_candidate_i
/* split into two separate methods, one to generate session-accept
(includes codecs) and one to generate transport-info (includes transports
candidates) */
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_session_accept(const JingleSession *sess)
{
xmlnode *jingle =
@@ -401,8 +412,7 @@ jabber_jingle_session_create_session_acc
return jingle;
}
-
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_transport_info(const JingleSession *sess)
{
xmlnode *jingle =
@@ -435,7 +445,7 @@ jabber_jingle_session_create_transport_i
return jingle;
}
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_content_replace(const JingleSession *sess,
FsCandidate *native_candidate,
FsCandidate *remote_candidate)
@@ -470,7 +480,7 @@ jabber_jingle_session_create_content_rep
return jingle;
}
-xmlnode *
+static xmlnode *
jabber_jingle_session_create_content_accept(const JingleSession *sess)
{
xmlnode *jingle =
@@ -750,6 +760,30 @@ void
}
void
+jabber_jingle_session_terminate_session_media(JabberStream *js, const gchar *who)
+{
+ JingleSession *session;
+
+ session = jabber_jingle_session_find_by_jid(js, who);
+
+ if (session)
+ purple_media_hangup(session->media);
+}
+
+void
+jabber_jingle_session_terminate_sessions(JabberStream *js)
+{
+ GList *values = g_hash_table_get_values(js->sessions);
+
+ for (; values; values = values->next) {
+ JingleSession *session = (JingleSession *)values->data;
+ purple_media_hangup(session->media);
+ }
+
+ g_list_free(values);
+}
+
+void
jabber_jingle_session_handle_content_replace(JabberStream *js, xmlnode *packet)
{
xmlnode *jingle = xmlnode_get_child(packet, "jingle");
============================================================
--- libpurple/protocols/jabber/jingle.h c20c28f4ddaeb3e76099f63fa4e33029f0c2fd69
+++ libpurple/protocols/jabber/jingle.h 676c3bfbe081f7ecd7c73ae29025daeec9d8d25e
@@ -24,71 +24,22 @@
#include <glib.h>
#include <glib-object.h>
+/*
+ * When Jingle content types other than voice and video are implemented,
+ * this #ifdef others surrounding Jingle code should be changed to just
+ * be around the voice and video specific parts.
+ */
#ifdef USE_VV
G_BEGIN_DECLS
-typedef struct {
- char *id;
- JabberStream *js;
- PurpleMedia *media;
- char *remote_jid;
- char *initiator;
- gboolean is_initiator;
- gboolean session_started;
-} JingleSession;
-
-JingleSession *jabber_jingle_session_create(JabberStream *js);
-JingleSession *jabber_jingle_session_create_by_id(JabberStream *js,
- const char *id);
-
-const char *jabber_jingle_session_get_id(const JingleSession *sess);
-JabberStream *jabber_jingle_session_get_js(const JingleSession *sess);
-
-void jabber_jingle_session_destroy(JingleSession *sess);
-
-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);
-void jabber_jingle_session_set_media(JingleSession *sess, PurpleMedia *media);
-
-const char *jabber_jingle_session_get_remote_jid(const JingleSession *sess);
-
-gboolean jabber_jingle_session_is_initiator(const JingleSession *sess);
-
-void jabber_jingle_session_set_remote_jid(JingleSession *sess,
- const char *remote_jid);
-
-const char *jabber_jingle_session_get_initiator(const JingleSession *sess);
-void jabber_jingle_session_set_initiator(JingleSession *sess,
- const char *initiator);
-
-xmlnode *jabber_jingle_session_create_terminate(const JingleSession *sess,
- const char *reasoncode,
- const char *reasontext);
-xmlnode *jabber_jingle_session_create_session_accept(const JingleSession *sess);
-xmlnode *jabber_jingle_session_create_transport_info(const JingleSession *sess);
-xmlnode *jabber_jingle_session_create_content_replace(const JingleSession *sess,
- FsCandidate *native_candidate,
- FsCandidate *remote_candidate);
-xmlnode *jabber_jingle_session_create_content_accept(const JingleSession *sess);
-xmlnode *jabber_jingle_session_create_description(const JingleSession *sess);
-
-/**
- * Gets a list of Farsight codecs from a Jingle <description> tag
- *
- * @param description
- * @return A GList of FarsightCodecS
-*/
-GList *jabber_jingle_get_codecs(const xmlnode *description);
-
-GList *jabber_jingle_get_candidates(const xmlnode *transport);
-
PurpleMedia *jabber_jingle_session_initiate_media(PurpleConnection *gc,
const char *who,
PurpleMediaStreamType type);
+void jabber_jingle_session_terminate_session_media(JabberStream *js, const gchar *who);
+void jabber_jingle_session_terminate_sessions(JabberStream *js);
+
/* Jingle message handlers */
void jabber_jingle_session_handle_content_replace(JabberStream *js, xmlnode *packet);
void jabber_jingle_session_handle_session_accept(JabberStream *js, xmlnode *packet);
More information about the Commits
mailing list