[Telepathy-commits] [telepathy-gabble/master] improving jingle code readability
Senko Rasic
senko at phyrexia.lan
Tue Dec 2 04:34:04 PST 2008
---
src/jingle-content.c | 6 +++---
src/jingle-factory.h | 8 ++++++--
src/jingle-media-rtp.c | 1 +
src/jingle-session.c | 14 +++++++++-----
src/jingle-transport-google.c | 4 ++--
src/jingle-transport-iface.c | 1 +
src/media-channel.c | 2 +-
7 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index d352b9d..e5bd2fa 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -597,7 +597,7 @@ gabble_jingle_content_parse_accept (GabbleJingleContent *c,
}
/* GTalk mode and old Gabble both don't really mind this */
- if (dialect <= JINGLE_DIALECT_V015)
+ if (JINGLE_IS_GOOGLE_DIALECT (dialect) || (dialect == JINGLE_DIALECT_V015))
{
DEBUG ("gtalk or old gabble detected, settings senders = both");
}
@@ -618,7 +618,6 @@ gabble_jingle_content_parse_accept (GabbleJingleContent *c,
g_object_notify ((GObject *) c, "senders");
- // If all went well, it means the content is finally ackd
priv->state = JINGLE_CONTENT_STATE_ACKNOWLEDGED;
g_object_notify ((GObject *) c, "state");
}
@@ -692,6 +691,7 @@ gabble_jingle_content_parse_transport_info (GabbleJingleContent *self,
gabble_jingle_transport_iface_parse_candidates (priv->transport, trans_node, error);
}
+/* Takes in a list of slice-allocated JingleCandidate structs */
void
gabble_jingle_content_add_candidates (GabbleJingleContent *self, GList *li)
{
@@ -843,7 +843,7 @@ gabble_jingle_content_change_direction (GabbleJingleContent *c,
g_object_get (c->session, "dialect", &dialect, NULL);
- if (dialect <= JINGLE_DIALECT_GTALK4)
+ if (JINGLE_IS_GOOGLE_DIALECT (dialect))
{
DEBUG ("ignoring direction change request for GTalk stream");
return FALSE;
diff --git a/src/jingle-factory.h b/src/jingle-factory.h
index 093c64a..5371bc4 100644
--- a/src/jingle-factory.h
+++ b/src/jingle-factory.h
@@ -39,13 +39,17 @@ typedef enum {
JINGLE_DIALECT_V032
} JingleDialect;
+#define JINGLE_IS_GOOGLE_DIALECT(d)\
+ ((d == JINGLE_DIALECT_GTALK3) || (d == JINGLE_DIALECT_GTALK4))
+
typedef enum {
JINGLE_STATE_PENDING_CREATED,
JINGLE_STATE_PENDING_INITIATE_SENT,
JINGLE_STATE_PENDING_INITIATED,
JINGLE_STATE_PENDING_ACCEPT_SENT,
JINGLE_STATE_PENDING_ACTIVE,
- JINGLE_STATE_ENDED
+ JINGLE_STATE_ENDED,
+ MAX_JINGLE_STATES
} JingleState;
typedef enum {
@@ -61,7 +65,7 @@ typedef enum {
JINGLE_ACTION_SESSION_INITIATE,
JINGLE_ACTION_SESSION_TERMINATE,
JINGLE_ACTION_TRANSPORT_INFO,
- JINGLE_ACTION_TRANSPORT_ACCEPT,
+ JINGLE_ACTION_TRANSPORT_ACCEPT
} JingleAction;
typedef enum {
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 21a6431..014383c 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -449,6 +449,7 @@ produce_description (GabbleJingleContent *obj, LmMessageNode *content_node)
}
}
+/* Takes in a list of slice-allocated JingleCodec structs */
void
jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self, GList *codecs)
{
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 3b3bdee..08867b2 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -93,7 +93,10 @@ typedef struct {
JingleAction *actions;
} JingleStateActions;
-static JingleAction allowed_actions[6][11] = {
+/* gcc should be able to figure this out from the table below, but.. */
+#define MAX_ACTIONS_PER_STATE 11
+
+static JingleAction allowed_actions[MAX_JINGLE_STATES][MAX_ACTIONS_PER_STATE] = {
/* JS_STATE_PENDING_CREATED */
{ JINGLE_ACTION_SESSION_INITIATE, JINGLE_ACTION_UNKNOWN },
/* JS_STATE_PENDING_INITIATE_SENT */
@@ -698,7 +701,7 @@ _each_content_accept (GabbleJingleSession *sess, GabbleJingleContent *c,
}
gabble_jingle_content_parse_accept (c, content_node,
- (priv->dialect <= JINGLE_DIALECT_GTALK4), error);
+ JINGLE_IS_GOOGLE_DIALECT (priv->dialect), error);
}
static void
@@ -710,8 +713,9 @@ on_session_initiate (GabbleJingleSession *sess, LmMessageNode *node,
/* we can't call ourselves at the moment */
if (priv->local_initiator)
{
- // FIXME: terminate session here, plzkthxbai
- // jingle_session_terminate (sess, FALSE, JINGLE_REASON_BUSY);
+ /* We ignore initiate from us, and terminate the session immediately
+ * afterwards */
+ _terminate_delayed (sess);
return;
}
@@ -831,7 +835,7 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
/* FIXME: we need to do dialect detection here!!! */
- if (priv->dialect <= JINGLE_DIALECT_GTALK4)
+ if (JINGLE_IS_GOOGLE_DIALECT (priv->dialect))
{
/* GTalk has only one content anyways */
GList *cs = g_hash_table_get_values (priv->contents);
diff --git a/src/jingle-transport-google.c b/src/jingle-transport-google.c
index 6d918cd..5c03ec1 100644
--- a/src/jingle-transport-google.c
+++ b/src/jingle-transport-google.c
@@ -125,7 +125,7 @@ gabble_jingle_transport_google_dispose (GObject *object)
DEBUG ("dispose called");
priv->dispose_has_run = TRUE;
- _free_candidates (priv->remote_candidates); // FIXME: huge bug, malloc/free hell
+ _free_candidates (priv->remote_candidates);
priv->remote_candidates = NULL;
_free_candidates (priv->local_candidates);
@@ -497,6 +497,7 @@ transmit_candidates (GabbleJingleTransportGoogle *transport, GList *candidates)
_gabble_connection_send (priv->content->conn, msg, NULL);
}
+/* Takes in a list of slice-allocated JingleCandidate structs */
static void
add_candidates (GabbleJingleTransportIface *obj, GList *new_candidates)
{
@@ -561,7 +562,6 @@ transport_iface_init (gpointer g_iface, gpointer iface_data)
GabbleJingleTransportIfaceClass *klass = (GabbleJingleTransportIfaceClass *) g_iface;
klass->parse_candidates = parse_candidates;
- // FIXME: klass->produce = produce_candidates;
klass->add_candidates = add_candidates;
klass->retransmit_candidates = retransmit_candidates;
klass->get_remote_candidates = get_remote_candidates;
diff --git a/src/jingle-transport-iface.c b/src/jingle-transport-iface.c
index ce7267e..68f9c2e 100644
--- a/src/jingle-transport-iface.c
+++ b/src/jingle-transport-iface.c
@@ -49,6 +49,7 @@ gabble_jingle_transport_iface_produce (GabbleJingleTransportIface *self,
return virtual_method (self, node);
}
+/* Takes in a list of slice-allocated JingleCandidate structs */
void
gabble_jingle_transport_iface_add_candidates (GabbleJingleTransportIface *self,
GList *candidates)
diff --git a/src/media-channel.c b/src/media-channel.c
index d6aec1b..f675923 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -1336,7 +1336,7 @@ _gabble_media_channel_request_streams (GabbleMediaChannel *chan,
if (dialect != JINGLE_DIALECT_ERROR)
{
/* is a google call... we have no other option */
- if (dialect <= JINGLE_DIALECT_GTALK4)
+ if (JINGLE_IS_GOOGLE_DIALECT (dialect))
{
DEBUG ("already in Google mode; can't add new stream");
--
1.5.6.5
More information about the Telepathy-commits
mailing list