[telepathy-gabble/master] Add a utility function to change the direction to sending from out side

Sjoerd Simons sjoerd.simons at collabora.co.uk
Mon Dec 14 06:53:00 PST 2009


---
 src/jingle-content.c |   37 +++++++++++++++++++++++++++++++++++++
 src/jingle-content.h |    3 +++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/jingle-content.c b/src/jingle-content.c
index 863a84a..f592beb 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -1118,3 +1118,40 @@ gabble_jingle_content_receiving (GabbleJingleContent *self)
 {
   return jingle_content_has_direction (self, FALSE);
 }
+
+void
+gabble_jingle_content_set_sending (GabbleJingleContent *self,
+  gboolean send)
+{
+  GabbleJingleContentPrivate *priv = self->priv;
+  JingleContentSenders senders;
+  gboolean initiated_by_us;
+
+  if (send == jingle_content_has_direction (self, TRUE))
+    return;
+
+  g_object_get (self->session, "local-initiator",
+    &initiated_by_us, NULL);
+
+  if (send)
+    {
+      if (priv->senders == JINGLE_CONTENT_SENDERS_NONE)
+        senders = (initiated_by_us ? JINGLE_CONTENT_SENDERS_INITIATOR :
+          JINGLE_CONTENT_SENDERS_RESPONDER);
+      else
+        senders = JINGLE_CONTENT_SENDERS_BOTH;
+    }
+  else
+    {
+      if (priv->senders == JINGLE_CONTENT_SENDERS_BOTH)
+        senders = (initiated_by_us ? JINGLE_CONTENT_SENDERS_RESPONDER :
+          JINGLE_CONTENT_SENDERS_INITIATOR);
+      else
+        senders = JINGLE_CONTENT_SENDERS_NONE;
+    }
+
+  if (senders == JINGLE_CONTENT_SENDERS_NONE)
+    gabble_jingle_content_remove (self, TRUE);
+  else
+    gabble_jingle_content_change_direction (self, senders);
+}
diff --git a/src/jingle-content.h b/src/jingle-content.h
index 9cbf810..2efe47a 100644
--- a/src/jingle-content.h
+++ b/src/jingle-content.h
@@ -141,5 +141,8 @@ void gabble_jingle_content_maybe_send_description (GabbleJingleContent *self);
 gboolean gabble_jingle_content_sending (GabbleJingleContent *self);
 gboolean gabble_jingle_content_receiving (GabbleJingleContent *self);
 
+void gabble_jingle_content_set_sending (GabbleJingleContent *self,
+  gboolean send);
+
 #endif /* __JINGLE_CONTENT_H__ */
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list