]> git.0d.be Git - empathy.git/commitdiff
Moved empathy_send_file to EmpathyDispatcher and renamed it. (Jonny Lamb)
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 21 Nov 2008 16:20:00 +0000 (16:20 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 21 Nov 2008 16:20:00 +0000 (16:20 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1835

libempathy-gtk/empathy-ft-manager.c
libempathy-gtk/empathy-ui-utils.c
libempathy/empathy-dispatcher.c
libempathy/empathy-dispatcher.h
libempathy/empathy-tp-file.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index 3e798c380771f314c572d31f911532c7e0b6c561..5814d14fe41c226465ebd61e750d40bcadd81377 100644 (file)
@@ -50,8 +50,7 @@
 /**
  * SECTION:empathy-ft-manager
  * @short_description: File transfer dialog
- * @see_also: #EmpathyTpFile, empathy_send_file(),
- * empathy_send_file_from_stream()
+ * @see_also: #EmpathyTpFile, empathy_dispatcher_send_file()
  * @include: libempthy-gtk/empathy-ft-manager.h
  *
  * The #EmpathyFTManager object represents the file transfer dialog,
index 388f4c716d15bfec6d48a5d5f504cea0c2482bd2..20eab6098de2256ee01934b61a47ac550acaff5b 100644 (file)
@@ -47,6 +47,7 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-dispatcher.h>
 
 struct SizeData {
        gint     width;
@@ -1472,7 +1473,7 @@ file_manager_send_file_response_cb (GtkDialog      *widget,
                        gfile = g_file_new_for_uri (uri);
 
                        DEBUG ("\t%s", uri);
-                       empathy_send_file (contact, gfile);
+                       empathy_dispatcher_send_file (contact, gfile);
 
                        manager = gtk_recent_manager_get_default ();
                        gtk_recent_manager_add_item (manager, uri);
index 5f26eeeedd74dfd39db3a0d504884ee4e3442b59..a110a2f94f455b5aa3a8b525066d02ffe1e9d5c8 100644 (file)
@@ -927,3 +927,102 @@ empathy_dispatcher_chat_with_contact_id (McAccount   *account,
        g_object_unref (factory);
 }
 
+EmpathyTpFile *
+empathy_dispatcher_send_file (EmpathyContact *contact,
+                             GFile          *gfile)
+{
+       GFileInfo      *info;
+       guint64         size;
+       GInputStream   *in_stream = NULL;
+       MissionControl *mc;
+       McAccount      *account;
+       TpConnection   *connection;
+       guint           handle;
+       gchar          *object_path;
+       TpChannel      *channel;
+       EmpathyTpFile  *tp_file;
+       GError         *error = NULL;
+       GValue          value = { 0 };
+       gchar          *filename;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+       g_return_val_if_fail (G_IS_FILE (gfile), NULL);
+
+       info = g_file_query_info (gfile,
+                                 G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+                                 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                 0, NULL, NULL);
+       size = info ? g_file_info_get_size (info) : EMPATHY_TP_FILE_UNKNOWN_SIZE;
+       filename = g_file_get_basename (gfile);
+       in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, NULL));
+       mc = empathy_mission_control_new ();
+       account = empathy_contact_get_account (contact);
+       connection = mission_control_get_tpconnection (mc, account, NULL);
+       tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
+       handle = empathy_contact_get_handle (contact);
+
+       DEBUG ("Sending %s from a stream to %s (size %llu, content-type %s)",
+              filename, empathy_contact_get_name (contact), size,
+              g_file_info_get_content_type (info));
+
+       if (!tp_cli_connection_run_request_channel (connection, -1,
+                                                   EMP_IFACE_CHANNEL_TYPE_FILE,
+                                                   TP_HANDLE_TYPE_CONTACT,
+                                                   handle,
+                                                   TRUE,
+                                                   &object_path,
+                                                   &error,
+                                                   NULL)) {
+               DEBUG ("Couldn't request channel: %s",
+                      error ? error->message : "No error given");
+               g_clear_error (&error);
+               g_object_unref (mc);
+               g_object_unref (connection);
+               return NULL;
+       }
+
+       channel = tp_channel_new (connection,
+                                 object_path,
+                                 EMP_IFACE_CHANNEL_TYPE_FILE,
+                                 TP_HANDLE_TYPE_CONTACT,
+                                 handle,
+                                 NULL);
+
+       /* FIXME: this should go in CreateChannel in the new requests API */
+
+       g_value_init (&value, G_TYPE_STRING);
+       g_value_set_string (&value, g_filename_display_basename (filename));
+       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
+               EMP_IFACE_CHANNEL_TYPE_FILE, "Filename",
+               &value, NULL, NULL, NULL, NULL);
+       g_value_reset (&value);
+
+       g_value_set_string (&value, g_file_info_get_content_type (info));
+       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
+               EMP_IFACE_CHANNEL_TYPE_FILE, "ContentType",
+               &value, NULL, NULL, NULL, NULL);
+
+       g_value_unset (&value);
+
+       g_value_init (&value, G_TYPE_UINT64);
+       g_value_set_uint64 (&value, size);
+       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
+               EMP_IFACE_CHANNEL_TYPE_FILE, "Size",
+               &value, NULL, NULL, NULL, NULL);
+       g_value_unset (&value);
+
+       tp_file = empathy_tp_file_new (channel);
+
+       if (tp_file) {
+               empathy_tp_file_set_input_stream (tp_file, in_stream);
+       }
+
+       empathy_tp_file_offer (tp_file);
+
+       g_object_unref (mc);
+       g_object_unref (connection);
+       g_object_unref (channel);
+       g_free (object_path);
+
+       return tp_file;
+}
index b14a460e41d737664e4fde725d558899ca5d305d..491089d30c3936f5abbe43325878447d1fbab8ca 100644 (file)
@@ -27,6 +27,7 @@
 #include <telepathy-glib/channel.h>
 
 #include "empathy-contact.h"
+#include "empathy-tp-file.h"
 
 G_BEGIN_DECLS
 
@@ -72,6 +73,8 @@ void                   empathy_dispatcher_call_with_contact_id (McAccount
 void                   empathy_dispatcher_chat_with_contact_id (McAccount             *account,
                                                                const gchar           *contact_id);
 void                   empathy_dispatcher_chat_with_contact    (EmpathyContact        *contact);
+EmpathyTpFile *        empathy_dispatcher_send_file            (EmpathyContact        *contact,
+                                                               GFile                 *gfile);
 
 G_END_DECLS
 
index a56b8cfe321050de366b5aa496107c5f5ab662fb..bfc5e71a66c54fc1d8568ca535a5214983455db2 100644 (file)
@@ -49,7 +49,7 @@
 /**
  * SECTION:empathy-tp-file
  * @short_description: File channel
- * @see_also: #EmpathyTpFile, #EmpathyContact, empathy_send_file()
+ * @see_also: #EmpathyTpFile, #EmpathyContact, empathy_dispatcher_send_file()
  * @include: libempthy/empathy-tp-file.h
  *
  * The #EmpathyTpFile object represents a Telepathy file channel.
index ecccb04a181b215d53d278a3daca50d31993692e..c80b75cceeb9622bfddbf1ded690b367b22bb4f1 100644 (file)
@@ -778,103 +778,3 @@ empathy_connection_request_channel (TpConnection *connection,
                                                weak_object);
 }
 
-EmpathyTpFile *
-empathy_send_file (EmpathyContact *contact,
-                  GFile          *gfile)
-{
-       GFileInfo      *info;
-       guint64         size;
-       GInputStream   *in_stream = NULL;
-       MissionControl *mc;
-       McAccount      *account;
-       TpConnection   *connection;
-       guint           handle;
-       gchar          *object_path;
-       TpChannel      *channel;
-       EmpathyTpFile  *tp_file;
-       GError         *error = NULL;
-       GValue          value = { 0 };
-       gchar          *filename;
-
-       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-       g_return_val_if_fail (G_IS_FILE (gfile), NULL);
-
-       info = g_file_query_info (gfile,
-                                 G_FILE_ATTRIBUTE_STANDARD_SIZE ","
-                                 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-                                 0, NULL, NULL);
-       size = info ? g_file_info_get_size (info) : EMPATHY_TP_FILE_UNKNOWN_SIZE;
-       filename = g_file_get_basename (gfile);
-       in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, NULL));
-       mc = empathy_mission_control_new ();
-       account = empathy_contact_get_account (contact);
-       connection = mission_control_get_tpconnection (mc, account, NULL);
-       tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
-       handle = empathy_contact_get_handle (contact);
-
-       DEBUG ("Sending %s from a stream to %s (size %llu, content-type %s)",
-              filename, empathy_contact_get_name (contact), size,
-              g_file_info_get_content_type (info));
-
-       if (!tp_cli_connection_run_request_channel (connection, -1,
-                                                   EMP_IFACE_CHANNEL_TYPE_FILE,
-                                                   TP_HANDLE_TYPE_CONTACT,
-                                                   handle,
-                                                   TRUE,
-                                                   &object_path,
-                                                   &error,
-                                                   NULL)) {
-               DEBUG ("Couldn't request channel: %s",
-                      error ? error->message : "No error given");
-               g_clear_error (&error);
-               g_object_unref (mc);
-               g_object_unref (connection);
-               return NULL;
-       }
-
-       channel = tp_channel_new (connection,
-                                 object_path,
-                                 EMP_IFACE_CHANNEL_TYPE_FILE,
-                                 TP_HANDLE_TYPE_CONTACT,
-                                 handle,
-                                 NULL);
-
-       /* FIXME: this should go in CreateChannel in the new requests API */
-
-       g_value_init (&value, G_TYPE_STRING);
-       g_value_set_string (&value, g_filename_display_basename (filename));
-       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
-               EMP_IFACE_CHANNEL_TYPE_FILE, "Filename",
-               &value, NULL, NULL, NULL, NULL);
-       g_value_reset (&value);
-
-       g_value_set_string (&value, g_file_info_get_content_type (info));
-       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
-               EMP_IFACE_CHANNEL_TYPE_FILE, "ContentType",
-               &value, NULL, NULL, NULL, NULL);
-
-       g_value_unset (&value);
-
-       g_value_init (&value, G_TYPE_UINT64);
-       g_value_set_uint64 (&value, size);
-       tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1,
-               EMP_IFACE_CHANNEL_TYPE_FILE, "Size",
-               &value, NULL, NULL, NULL, NULL);
-       g_value_unset (&value);
-
-       tp_file = empathy_tp_file_new (channel);
-
-       if (tp_file) {
-               empathy_tp_file_set_input_stream (tp_file, in_stream);
-       }
-
-       empathy_tp_file_offer (tp_file);
-
-       g_object_unref (mc);
-       g_object_unref (connection);
-       g_object_unref (channel);
-       g_free (object_path);
-
-       return tp_file;
-}
-
index 9a57679ef5a6213ce66a980e28ec61c44c77fb9b..83c19e1c4e6ab6c6e9480059943bd69d24bc0371 100644 (file)
@@ -37,7 +37,6 @@
 #include <libmissioncontrol/mission-control.h>
 
 #include "empathy-contact.h"
-#include "empathy-tp-file.h"
 
 G_BEGIN_DECLS
 
@@ -124,15 +123,6 @@ void empathy_connection_request_channel (TpConnection *proxy,
                                         gpointer user_data,
                                         GDestroyNotify destroy,
                                         GObject *weak_object);
-EmpathyFile *  empathy_send_file_from_stream        (EmpathyContact  *contact,
-                                                     GInputStream    *in_stream,
-                                                     const gchar     *filename,
-                                                     guint64          size);
-EmpathyFile *  empathy_send_file                    (EmpathyContact  *contact,
-                                                     GFile           *file);
-/* File transfer */
-EmpathyTpFile *empathy_send_file                      (EmpathyContact  *contact,
-                                                      GFile           *file);
 
 G_END_DECLS