]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-handler.c
Use a flat namespace for internal includes
[empathy.git] / src / empathy-call-handler.c
index 703ed3299b74f0a25981dca1a1689c7fb1e2aae5..28e8cda834de7430ff2446538a62004fedae3d58 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <telepathy-glib/account-channel-request.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
+#include "config.h"
 
 #include <telepathy-farstream/telepathy-farstream.h>
 
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-tp-contact-factory.h>
+#include "empathy-utils.h"
 
-#include <libempathy-gtk/empathy-call-utils.h>
+#include "empathy-call-utils.h"
 
 #include "empathy-call-handler.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 G_DEFINE_TYPE(EmpathyCallHandler, empathy_call_handler, G_TYPE_OBJECT)
 
@@ -179,6 +172,20 @@ on_call_state_changed_cb (TpCallChannel *call,
 {
   EmpathyCallHandlerPriv *priv = handler->priv;
 
+  /* Clean up the TfChannel before bubbling the state-change signal
+   * further up. This ensures that the conference-removed signal is
+   * emitted before state-changed so that the client gets a chance
+   * to remove the conference from the pipeline before resetting the
+   * pipeline itself.
+   */
+  if (state == TP_CALL_STATE_ENDED)
+    {
+      tp_channel_close_async (TP_CHANNEL (call), NULL, NULL);
+      priv->accept_when_initialised = FALSE;
+      tp_clear_object (&priv->call);
+      tp_clear_object (&priv->tfchannel);
+    }
+
   g_signal_emit (handler, signals[STATE_CHANGED], 0, state,
       reason->dbus_reason);
 
@@ -188,14 +195,6 @@ on_call_state_changed_cb (TpCallChannel *call,
       tp_call_channel_accept_async (priv->call, on_call_accepted_cb, NULL);
       priv->accept_when_initialised = FALSE;
     }
-
-  if (state == TP_CALL_STATE_ENDED)
-    {
-      tp_channel_close_async (TP_CHANNEL (call), NULL, NULL);
-      priv->accept_when_initialised = FALSE;
-      tp_clear_object (&priv->call);
-      tp_clear_object (&priv->tfchannel);
-    }
 }
 
 static void
@@ -911,11 +910,22 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler,
     {
       empathy_call_handler_start_tpfs (handler);
 
-      if (tp_call_channel_get_state (priv->call, NULL, NULL, NULL) ==
-          TP_CALL_STATE_INITIALISED)
-        tp_call_channel_accept_async (priv->call, on_call_accepted_cb, NULL);
+      if (tp_channel_get_requested (TP_CHANNEL (priv->call)))
+        {
+          /* accept outgoing channels immediately */
+          tp_call_channel_accept_async (priv->call,
+              on_call_accepted_cb, NULL);
+        }
       else
-        priv->accept_when_initialised = TRUE;
+        {
+          /* accepting incoming channels when they are INITIALISED */
+          if (tp_call_channel_get_state (priv->call, NULL, NULL, NULL) ==
+              TP_CALL_STATE_INITIALISED)
+            tp_call_channel_accept_async (priv->call,
+                on_call_accepted_cb, NULL);
+          else
+            priv->accept_when_initialised = TRUE;
+        }
 
       return;
     }
@@ -1040,3 +1050,9 @@ empathy_call_handler_get_video_local_candidate (
 
   return priv->video_local_candidate;
 }
+
+EmpathyContact *
+empathy_call_handler_get_contact (EmpathyCallHandler *self)
+{
+  return self->priv->contact;
+}