]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-ft-factory.c
Updated Swedish translation
[empathy.git] / libempathy / empathy-ft-factory.c
index 7ae9ad100710550f5d45baef3b908f3125a67394..f15f9fb6d7a5442a3d7d97a3dab3b6571e61090e 100644 (file)
 
 /* empathy-ft-factory.c */
 
-#include <glib.h>
+#include "config.h"
+#include "empathy-ft-factory.h"
 
-#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
 
-#include "empathy-ft-factory.h"
-#include "empathy-ft-handler.h"
-#include "empathy-marshal.h"
+#include "empathy-request-util.h"
 #include "empathy-utils.h"
 
 /**
@@ -70,19 +69,33 @@ do_constructor (GType type,
     guint n_props,
     GObjectConstructParam *props)
 {
-       GObject *retval;
+  GObject *retval;
 
-       if (factory_singleton != NULL) {
-               retval = g_object_ref (factory_singleton);
-       } else {
-               retval = G_OBJECT_CLASS (empathy_ft_factory_parent_class)->constructor
-                       (type, n_props, props);
+  if (factory_singleton != NULL)
+    {
+      retval = g_object_ref (factory_singleton);
+    }
+  else
+    {
+      retval = G_OBJECT_CLASS (empathy_ft_factory_parent_class)->constructor
+        (type, n_props, props);
 
-               factory_singleton = EMPATHY_FT_FACTORY (retval);
-               g_object_add_weak_pointer (retval, (gpointer *) &factory_singleton);
-       }
+      factory_singleton = EMPATHY_FT_FACTORY (retval);
+      g_object_add_weak_pointer (retval, (gpointer *) &factory_singleton);
+    }
 
-       return retval;
+  return retval;
+}
+
+static void
+empathy_ft_factory_dispose (GObject *object)
+{
+  EmpathyFTFactory *self = (EmpathyFTFactory *) object;
+  EmpathyFTFactoryPriv *priv = GET_PRIV (self);
+
+  tp_clear_object (&priv->handler);
+
+  (G_OBJECT_CLASS (empathy_ft_factory_parent_class)->dispose) (object);
 }
 
 static void
@@ -93,6 +106,7 @@ empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass)
   g_type_class_add_private (klass, sizeof (EmpathyFTFactoryPriv));
 
   object_class->constructor = do_constructor;
+  object_class->dispose = empathy_ft_factory_dispose;
 
   /**
    * EmpathyFTFactory::new-ft-handler
@@ -110,7 +124,7 @@ empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass)
       G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0,
       NULL, NULL,
-      _empathy_marshal_VOID__OBJECT_POINTER,
+      g_cclosure_marshal_generic,
       G_TYPE_NONE, 2, EMPATHY_TYPE_FT_HANDLER, G_TYPE_POINTER);
 
   /**
@@ -133,7 +147,7 @@ empathy_ft_factory_class_init (EmpathyFTFactoryClass *klass)
       G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0,
       NULL, NULL,
-      _empathy_marshal_VOID__OBJECT_POINTER,
+      g_cclosure_marshal_generic,
       G_TYPE_NONE, 2, EMPATHY_TYPE_FT_HANDLER, G_TYPE_POINTER);
 }
 
@@ -163,22 +177,16 @@ handle_channels_cb (TpSimpleHandler *handler,
   for (l = channels; l != NULL; l = g_list_next (l))
     {
       TpChannel *channel = l->data;
-      EmpathyTpFile *tp_file;
 
       if (tp_proxy_get_invalidated (channel) != NULL)
         continue;
 
-      if (tp_channel_get_channel_type_id (channel) !=
-          TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
+      if (!TP_IS_FILE_TRANSFER_CHANNEL (channel))
         continue;
 
-      tp_file = empathy_tp_file_new (channel);
-
       /* We handle only incoming FT */
-      empathy_ft_handler_new_incoming (tp_file, ft_handler_incoming_ready_cb,
-          self);
-
-      g_object_unref (tp_file);
+      empathy_ft_handler_new_incoming ((TpFileTransferChannel *) channel,
+          ft_handler_incoming_ready_cb, self);
     }
 
 
@@ -190,21 +198,14 @@ empathy_ft_factory_init (EmpathyFTFactory *self)
 {
   EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
     EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv);
-  TpDBusDaemon *dbus;
-  GError *error = NULL;
+  TpAccountManager *am;
 
   self->priv = priv;
 
-  dbus = tp_dbus_daemon_dup (&error);
-  if (dbus == NULL)
-    {
-      g_warning ("Failed to get TpDBusDaemon: %s", error->message);
-      g_error_free (error);
-      return;
-    }
+  am = tp_account_manager_dup ();
 
-  priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
-      "Empathy.FileTransfer", FALSE, handle_channels_cb, self, NULL);
+  priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE,
+      EMPATHY_FT_TP_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, self, NULL);
 
   tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
         TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
@@ -215,7 +216,7 @@ empathy_ft_factory_init (EmpathyFTFactory *self)
         TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, FALSE,
         NULL));
 
-  g_object_unref (dbus);
+  g_object_unref (am);
 }
 
 static void
@@ -223,9 +224,11 @@ ft_handler_outgoing_ready_cb (EmpathyFTHandler *handler,
     GError *error,
     gpointer user_data)
 {
-  EmpathyFTFactory *factory = user_data;
+  EmpathyFTFactory *factory = EMPATHY_FT_FACTORY (user_data);
 
   g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, error);
+
+  g_object_unref (factory);
 }
 
 /* public methods */
@@ -256,14 +259,15 @@ empathy_ft_factory_dup_singleton (void)
 void
 empathy_ft_factory_new_transfer_outgoing (EmpathyFTFactory *factory,
     EmpathyContact *contact,
-    GFile *source)
+    GFile *source,
+    gint64 action_time)
 {
   g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory));
   g_return_if_fail (EMPATHY_IS_CONTACT (contact));
   g_return_if_fail (G_IS_FILE (source));
 
-  empathy_ft_handler_new_outgoing (contact, source,
-      ft_handler_outgoing_ready_cb, factory);
+  empathy_ft_handler_new_outgoing (contact, source, action_time,
+      ft_handler_outgoing_ready_cb, g_object_ref (factory));
 }
 
 /**