]> git.0d.be Git - empathy.git/commitdiff
Added empathy_offer_file function and updated accept_file. (Jonny Lamb)
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 21 Nov 2008 16:17:03 +0000 (16:17 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 21 Nov 2008 16:17:03 +0000 (16:17 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1788

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

index 5c23ccb5c4a4c333cdcee90a3b7d0e23863d6f27..c295b53e6f2613c4b6fe97c8613a34c7ebb29cd6 100644 (file)
@@ -365,6 +365,8 @@ update_ft_row (EmpathyFTManager *ft_manager,
     {
       case EMP_FILE_TRANSFER_STATE_REMOTE_PENDING:
       case EMP_FILE_TRANSFER_STATE_OPEN:
+      case EMP_FILE_TRANSFER_STATE_ACCEPTED:
+      case EMP_FILE_TRANSFER_STATE_NOT_OFFERED:
         if (empathy_tp_file_get_incoming (tp_file))
           /* translators: first %s is filename, second %s is the contact name */
           first_line_format = _("Receiving \"%s\" from %s");
@@ -374,7 +376,8 @@ update_ft_row (EmpathyFTManager *ft_manager,
 
         first_line = g_strdup_printf (first_line_format, filename, contact_name);
 
-        if (state == EMP_FILE_TRANSFER_STATE_OPEN)
+        if (state == EMP_FILE_TRANSFER_STATE_OPEN
+            || state == EMP_FILE_TRANSFER_STATE_ACCEPTED)
           {
             gchar *total_size_str;
             gchar *transferred_bytes_str;
@@ -1064,7 +1067,7 @@ ft_manager_save_dialog_response_cb (GtkDialog *widget,
           filename = g_file_get_basename (file);
           empathy_tp_file_set_filename (response_data->tp_file, filename);
 
-          empathy_tp_file_accept (response_data->tp_file);
+          empathy_tp_file_accept (response_data->tp_file, 0);
 
           ft_manager_add_tp_file_to_list (response_data->ft_manager,
               response_data->tp_file);
index c64c0e2f8655d534dce6f720d3a07650eddadf69..0d1a47a396e1f295ca99bcb1351c0e81f3bd3d90 100644 (file)
@@ -621,7 +621,8 @@ _get_local_socket (EmpathyTpFile *tp_file)
  * EMP_FILE_TRANSFER_STATE_LOCAL_PENDING).
  */
 void
-empathy_tp_file_accept (EmpathyTpFile *tp_file)
+empathy_tp_file_accept (EmpathyTpFile *tp_file,
+                        guint64 offset)
 {
   EmpathyTpFilePriv *priv;
   GValue *address;
@@ -641,11 +642,46 @@ empathy_tp_file_accept (EmpathyTpFile *tp_file)
 
   if (!emp_cli_channel_type_file_run_accept_file (TP_PROXY (priv->channel),
       -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
-      &nothing, &address, &error, NULL))
+      &nothing, offset, &address, &error, NULL))
     {
       DEBUG ("Accept error: %s",
           error ? error->message : "No message given");
       g_clear_error (&error);
+      return;
+    }
+
+  if (priv->unix_socket_path)
+    g_free (priv->unix_socket_path);
+
+  priv->unix_socket_path = g_value_dup_string (address);
+  g_value_unset (address);
+
+  DEBUG ("Got unix socket path: %s", priv->unix_socket_path);
+}
+
+void
+empathy_tp_file_offer (EmpathyTpFile *tp_file)
+{
+  EmpathyTpFilePriv *priv;
+  GValue *address;
+  GError *error = NULL;
+  GValue nothing = { 0 };
+
+  g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
+
+  priv = GET_PRIV (tp_file);
+
+  g_value_init (&nothing, G_TYPE_STRING);
+  g_value_set_string (&nothing, "");
+
+  if (!emp_cli_channel_type_file_run_offer_file (TP_PROXY (priv->channel),
+      -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
+      &nothing, &address, &error, NULL))
+    {
+      DEBUG ("OfferFile error: %s",
+          error ? error->message : "No message given");
+      g_clear_error (&error);
+      return;
     }
 
   if (priv->unix_socket_path)
index 213948c933d367eb77be56fe7edf344aabaab005..5ba1f1d478648387d512d9482a13698410845fc8 100644 (file)
@@ -65,8 +65,9 @@ GType empathy_tp_file_get_type (void) G_GNUC_CONST;
 EmpathyTpFile *empathy_tp_file_new (McAccount *account, TpChannel *channel);
 
 TpChannel *empathy_tp_file_get_channel (EmpathyTpFile *tp_file);
-void empathy_tp_file_accept (EmpathyTpFile *tp_file);
+void empathy_tp_file_accept (EmpathyTpFile *tp_file, guint64 offset);
 void empathy_tp_file_cancel (EmpathyTpFile *tp_file);
+void empathy_tp_file_offer (EmpathyTpFile *tp_file);
 
 const gchar *empathy_tp_file_get_id (EmpathyTpFile *tp_file);
 guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
index 1a33328a43d8d938b2e3120feca626125dc05225..b17d18a5216c240097373637dca50d6269072e0d 100644 (file)
@@ -867,6 +867,8 @@ empathy_send_file (EmpathyContact *contact,
                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);