]> git.0d.be Git - empathy.git/commitdiff
Reject approval if call was hung up during approval
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Mon, 14 Mar 2011 13:23:19 +0000 (13:23 +0000)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Thu, 9 Jun 2011 09:20:07 +0000 (10:20 +0100)
If an incoming call gets ENDED during our approval stage either we or
someone else closed it. In that case reject the approval (which will
claim and close the channel). A future improvement could be to show a
notification in case this happens

src/empathy-event-manager.c

index 3c6fd7985161fc9a04f73af0852740947aec2210..6d58a4ae90b2ed186404c98710a9ef5cfebf0d2e 100644 (file)
@@ -673,6 +673,21 @@ cdo_invalidated_cb (TpProxy *cdo,
   event_manager_approval_done (approval);
 }
 
+static void
+event_manager_call_state_changed_cb (TpyCallChannel *call,
+  TpyCallState state,
+  TpyCallFlags flags,
+   const GValueArray *call_state_reason,
+  GHashTable *call_state_details,
+  EventManagerApproval *approval)
+{
+  if (state == TPY_CALL_STATE_ENDED)
+    {
+      DEBUG ("Call ended, seems we missed it :/");
+      reject_approval (approval);
+    }
+}
+
 static void
 event_manager_call_channel_got_contact_cb (TpConnection *connection,
                                  EmpathyContact *contact,
@@ -687,6 +702,8 @@ event_manager_call_channel_got_contact_cb (TpConnection *connection,
   gchar *header;
   gboolean video;
 
+  call = TPY_CALL_CHANNEL (approval->handler_instance);
+
   if (error != NULL)
     {
       DEBUG ("Can't get the contact for the call.. Rejecting?");
@@ -694,11 +711,19 @@ event_manager_call_channel_got_contact_cb (TpConnection *connection,
       return;
     }
 
+  if (tpy_call_channel_get_state (call, NULL, NULL) == TPY_CALL_STATE_ENDED)
+    {
+      DEBUG ("Call already ended, seems we missed it :/");
+      reject_approval (approval);
+      return;
+    }
+
+  approval->handler = g_signal_connect (call, "state-changed",
+    G_CALLBACK (event_manager_call_state_changed_cb), approval);
+
   window = empathy_main_window_dup ();
   approval->contact = g_object_ref (contact);
 
-  call = TPY_CALL_CHANNEL (approval->handler_instance);
-
   g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
 
   header = g_strdup_printf (