]> git.0d.be Git - empathy.git/commitdiff
Handle new file channels regardless of direction in the dispatcher. (Jonny Lamb)
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 21 Nov 2008 16:19:56 +0000 (16:19 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 21 Nov 2008 16:19:56 +0000 (16:19 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1834

libempathy-gtk/empathy-ui-utils.c
src/empathy-event-manager.c
src/empathy.c

index 71aaf7ecae24a871b77ad7836bcbc1d1364e7c3b..388f4c716d15bfec6d48a5d5f504cea0c2482bd2 100644 (file)
@@ -1458,39 +1458,25 @@ file_manager_send_file_response_cb (GtkDialog      *widget,
        if (response_id == GTK_RESPONSE_OK) {
                GSList *list;
                GSList *l;
-               EmpathyFTManager *ft_manager;
 
                list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (widget));
-               ft_manager = empathy_ft_manager_get_default ();
 
                DEBUG ("File chooser selected files:");
 
                for (l = list; l; l = l->next) {
                        gchar            *uri;
                        GFile            *gfile;
-                       EmpathyTpFile    *tp_file;
                        GtkRecentManager *manager;
 
                        uri = l->data;
                        gfile = g_file_new_for_uri (uri);
 
                        DEBUG ("\t%s", uri);
-                       tp_file = empathy_send_file (contact,
-                                                    gfile);
-
-                       empathy_ft_manager_add_tp_file (ft_manager, tp_file);
+                       empathy_send_file (contact, gfile);
 
                        manager = gtk_recent_manager_get_default ();
                        gtk_recent_manager_add_item (manager, uri);
 
-                       if (tp_file) ;
-                               /* FIXME: This should be unrefed, but
-                                * it's not referenced anywhere else,
-                                * so the transfer just ends. Uncomment
-                                * this out when there is a file
-                                * transfer "manager".
-                               g_object_unref (file);
-                                */
                        g_object_unref (gfile);
                        g_free (uri);
                }
index 71840f0e0d5aad7bf6902d97ac569b5de4f6f932..9a2cf579dc0d7a790a3c1bea7efd782d0c243cd4 100644 (file)
@@ -27,6 +27,7 @@
 #include <telepathy-glib/util.h>
 
 #include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-tp-chat.h>
 #include <libempathy/empathy-tp-group.h>
@@ -177,59 +178,6 @@ event_manager_chat_message_received_cb (EmpathyTpChat       *tp_chat,
        g_free (msg);
 }
 
-static void
-event_channel_file_process_func (EventPriv *event)
-{
-       EmpathyFTManager *manager;
-       EmpathyTpFile    *tp_file = (EmpathyTpFile *) event->user_data;
-
-       manager = empathy_ft_manager_get_default ();
-       empathy_ft_manager_add_tp_file (manager, tp_file);
-       event_remove (event);
-}
-
-static void
-file_channel_state_cb (TpProxy      *proxy,
-                      const GValue *state,
-                      const GError *error,
-                      gpointer      user_data,
-                      GObject      *weak_object)
-{
-       TpChannel           *channel = (TpChannel *) weak_object;
-       EmpathyEventManager *manager = (EmpathyEventManager *) user_data;
-
-       if (error) {
-               DEBUG ("Error: %s", error->message);
-               return;
-       }
-
-       /* Only deal with incoming channels */
-       if (g_value_get_uint (state) ==
-           EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) {
-               EmpathyContact *contact;
-               gchar          *msg;
-               EmpathyTpFile  *tp_file;
-
-               tp_file = empathy_tp_file_new (channel);
-
-               contact = empathy_tp_file_get_contact (tp_file);
-               empathy_contact_run_until_ready (contact,
-                       EMPATHY_CONTACT_READY_NAME, NULL);
-
-               msg = g_strdup_printf (_("Incoming file transfer from %s"),
-                                      empathy_contact_get_name (contact));
-
-               event_manager_add (manager, contact,
-                                  EMPATHY_IMAGE_DOCUMENT_SEND,
-                                  msg,
-                                  channel,
-                                  event_channel_file_process_func,
-                                  tp_file);
-
-               g_free (msg);
-       }
-}
-
 static void
 event_manager_filter_channel_cb (EmpathyDispatcher   *dispatcher,
                                 TpChannel           *channel,
@@ -269,12 +217,33 @@ event_manager_filter_channel_cb (EmpathyDispatcher   *dispatcher,
                g_object_unref (tp_group);
        }
        else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_FILE)) {
-               tp_cli_dbus_properties_call_get (channel, -1,
-                                                EMP_IFACE_CHANNEL_TYPE_FILE,
-                                                "State",
-                                                file_channel_state_cb,
-                                                manager, NULL,
-                                                G_OBJECT (channel));
+               EmpathyContact        *contact;
+               gchar                 *msg;
+               TpHandle               handle;
+               McAccount             *account;
+               EmpathyContactFactory *factory;
+
+               factory = empathy_contact_factory_new ();
+               handle = tp_channel_get_handle (channel, NULL);
+               account = empathy_channel_get_account (channel);
+
+               contact = empathy_contact_factory_get_from_handle (factory,
+                                                                  account,
+                                                                  handle);
+
+               empathy_contact_run_until_ready (contact,
+                       EMPATHY_CONTACT_READY_NAME, NULL);
+
+               msg = g_strdup_printf (_("Incoming file transfer from %s"),
+                                      empathy_contact_get_name (contact));
+
+               event_manager_add (manager, contact,
+                                  EMPATHY_IMAGE_DOCUMENT_SEND,
+                                  msg, channel,
+                                  event_channel_process_func, NULL);
+
+               g_object_unref (factory);
+               g_object_unref (account);
        }
 
        g_free (channel_type);
index 0f8cce4044410935047149e8dbfc276f5595afed..56da3c7c49b28671a3a40ead1427ffd645ee57ab 100644 (file)
@@ -44,6 +44,7 @@
 #include <libempathy/empathy-tp-group.h>
 
 #include <libempathy-gtk/empathy-conf.h>
+#include <libempathy-gtk/empathy-ft-manager.h>
 
 #include <extensions/extensions.h>
 
@@ -104,6 +105,15 @@ dispatch_channel_cb (EmpathyDispatcher *dispatcher,
        else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) {
                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);
+       }
 
        g_free (channel_type);
 }