]> git.0d.be Git - empathy.git/commitdiff
Added a wait for file channels so outgoing transfers are only added to the manager...
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 21 Nov 2008 16:20:12 +0000 (16:20 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 21 Nov 2008 16:20:12 +0000 (16:20 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1838

src/empathy.c

index 56da3c7c49b28671a3a40ead1427ffd645ee57ab..bc89d451e689c16f546e6d73003a66f8cd18ec93 100644 (file)
 
 static BaconMessageConnection *connection = NULL;
 
+static void
+file_channel_add_to_file_manager (TpChannel *channel)
+{
+       EmpathyTpFile *tp_file;
+       EmpathyFTManager *ft_manager;
+
+       ft_manager = empathy_ft_manager_get_default ();
+       tp_file = empathy_tp_file_new (channel);
+       empathy_ft_manager_add_tp_file (ft_manager, tp_file);
+
+       g_object_unref (channel);
+}
+
+static void
+file_channel_state_changed_cb (TpProxy *proxy,
+                              guint    state,
+                              guint    reason,
+                              gpointer user_data,
+                              GObject *weak_object)
+{
+       /* Only deal with the channel being offered */
+       if (state == EMP_FILE_TRANSFER_STATE_REMOTE_PENDING) {
+               file_channel_add_to_file_manager (TP_CHANNEL (proxy));
+       }
+}
+
+static void
+file_channel_get_state_cb (TpProxy      *proxy,
+                          const GValue *state_value,
+                          const GError *error,
+                          gpointer      user_data,
+                          GObject      *weak_object)
+{
+       EmpFileTransferState state;
+       state = g_value_get_uint (state_value);
+
+       if (state == EMP_FILE_TRANSFER_STATE_REMOTE_PENDING
+           || state == EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) {
+               file_channel_add_to_file_manager (TP_CHANNEL (proxy));
+               return;
+       }
+
+       emp_cli_channel_type_file_connect_to_file_transfer_state_changed (
+               proxy, file_channel_state_changed_cb, NULL, NULL, NULL, NULL);
+}
+
 static void
 dispatch_channel_cb (EmpathyDispatcher *dispatcher,
                     TpChannel         *channel,
@@ -106,13 +152,10 @@ dispatch_channel_cb (EmpathyDispatcher *dispatcher,
                empathy_call_window_new (channel);
        }
        else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_FILE)) {
-               EmpathyTpFile *tp_file;
-               EmpathyFTManager *ft_manager;
-
-               ft_manager = empathy_ft_manager_get_default ();
-               tp_file = empathy_tp_file_new (channel);
-
-               empathy_ft_manager_add_tp_file (ft_manager, tp_file);
+               tp_cli_dbus_properties_call_get (g_object_ref (channel), -1,
+                       EMP_IFACE_CHANNEL_TYPE_FILE,
+                       "State", file_channel_get_state_cb,
+                       NULL, NULL, NULL);
        }
 
        g_free (channel_type);