Blame SOURCES/0008-dbus-manager-Drop-copy-file-operation.patch

af40a0
From 474ed07f64df1381440b8692d7d500d26014c618 Mon Sep 17 00:00:00 2001
af40a0
From: Carlos Soriano <csoriano@redhat.com>
af40a0
Date: Tue, 7 Aug 2018 21:25:01 +0200
af40a0
Subject: [PATCH 08/11] dbus-manager: Drop copy file operation
af40a0
af40a0
It was truly unreliable and not working clearly. We have a more powerful
af40a0
and simpler API with CopyURIs, so there is no point to have this one.
af40a0
af40a0
This commits drops the DBus API. Note that the DBus version is not
af40a0
bumped, I believe this DBus API is not used by any external service
af40a0
given how broken was it.
af40a0
---
af40a0
 data/dbus-interfaces.xml       |  6 ---
af40a0
 src/nautilus-dbus-manager.c    | 69 ++++++++++++++--------------------
af40a0
 src/nautilus-file-operations.c | 41 --------------------
af40a0
 src/nautilus-file-operations.h |  7 ----
af40a0
 4 files changed, 29 insertions(+), 94 deletions(-)
af40a0
af40a0
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
af40a0
index 2133bb99c..20ffadde1 100644
af40a0
--- a/data/dbus-interfaces.xml
af40a0
+++ b/data/dbus-interfaces.xml
af40a0
@@ -29,12 +29,6 @@
af40a0
     </method>
af40a0
     <method name='EmptyTrash'>
af40a0
     </method>"
af40a0
-    <method name='CopyFile'>
af40a0
-      <arg type='s' name='SourceFileURI' direction='in'/>
af40a0
-      <arg type='s' name='SourceDisplayName' direction='in'/>
af40a0
-      <arg type='s' name='DestinationDirectoryURI' direction='in'/>
af40a0
-      <arg type='s' name='DestinationDisplayName' direction='in'/>
af40a0
-    </method>
af40a0
     <method name='TrashFiles'>
af40a0
       <arg type='as' name='URIs' direction='in'/>
af40a0
     </method>
af40a0
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
af40a0
index 0d5137292..1ac6e12c2 100644
af40a0
--- a/src/nautilus-dbus-manager.c
af40a0
+++ b/src/nautilus-dbus-manager.c
af40a0
@@ -61,40 +61,6 @@ nautilus_dbus_manager_dispose (GObject *object)
af40a0
     G_OBJECT_CLASS (nautilus_dbus_manager_parent_class)->dispose (object);
af40a0
 }
af40a0
 
af40a0
-static gboolean
af40a0
-handle_copy_file (NautilusDBusFileOperations *object,
af40a0
-                  GDBusMethodInvocation      *invocation,
af40a0
-                  const gchar                *source_uri,
af40a0
-                  const gchar                *source_display_name,
af40a0
-                  const gchar                *dest_dir_uri,
af40a0
-                  const gchar                *dest_name)
af40a0
-{
af40a0
-    GFile *source_file, *target_dir;
af40a0
-    const gchar *target_name = NULL, *source_name = NULL;
af40a0
-
af40a0
-    source_file = g_file_new_for_uri (source_uri);
af40a0
-    target_dir = g_file_new_for_uri (dest_dir_uri);
af40a0
-
af40a0
-    if (dest_name != NULL && dest_name[0] != '\0')
af40a0
-    {
af40a0
-        target_name = dest_name;
af40a0
-    }
af40a0
-
af40a0
-    if (source_display_name != NULL && source_display_name[0] != '\0')
af40a0
-    {
af40a0
-        source_name = source_display_name;
af40a0
-    }
af40a0
-
af40a0
-    nautilus_file_operations_copy_file (source_file, target_dir, source_name, target_name,
af40a0
-                                        NULL, NULL, NULL);
af40a0
-
af40a0
-    g_object_unref (source_file);
af40a0
-    g_object_unref (target_dir);
af40a0
-
af40a0
-    nautilus_dbus_file_operations_complete_copy_file (object, invocation);
af40a0
-    return TRUE; /* invocation was handled */
af40a0
-}
af40a0
-
af40a0
 static void
af40a0
 undo_redo_on_finished (gpointer user_data)
af40a0
 {
af40a0
@@ -173,9 +139,9 @@ handle_create_folder (NautilusDBusFileOperations *object,
af40a0
 }
af40a0
 
af40a0
 static void
af40a0
-copy_on_finished (GHashTable *debutting_uris,
af40a0
-                  gboolean    success,
af40a0
-                  gpointer    callback_data)
af40a0
+copy_move_on_finished (GHashTable *debutting_uris,
af40a0
+                       gboolean    success,
af40a0
+                       gpointer    callback_data)
af40a0
 {
af40a0
     g_application_release (g_application_get_default ());
af40a0
 }
af40a0
@@ -196,7 +162,30 @@ handle_copy_uris (NautilusDBusFileOperations  *object,
af40a0
 
af40a0
     g_application_hold (g_application_get_default ());
af40a0
     nautilus_file_operations_copy_move (source_files, destination,
af40a0
-                                        GDK_ACTION_COPY, NULL, copy_on_finished, NULL);
af40a0
+                                        GDK_ACTION_COPY, NULL, copy_move_on_finished, NULL);
af40a0
+
af40a0
+    g_list_free_full (source_files, g_free);
af40a0
+    nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
af40a0
+    return TRUE; /* invocation was handled */
af40a0
+}
af40a0
+
af40a0
+static gboolean
af40a0
+handle_move_uris (NautilusDBusFileOperations  *object,
af40a0
+                  GDBusMethodInvocation       *invocation,
af40a0
+                  const gchar                **sources,
af40a0
+                  const gchar                 *destination)
af40a0
+{
af40a0
+    GList *source_files = NULL;
af40a0
+    gint idx;
af40a0
+
af40a0
+    for (idx = 0; sources[idx] != NULL; idx++)
af40a0
+    {
af40a0
+        source_files = g_list_prepend (source_files, g_strdup (sources[idx]));
af40a0
+    }
af40a0
+
af40a0
+    g_application_hold (g_application_get_default ());
af40a0
+    nautilus_file_operations_copy_move (source_files, destination,
af40a0
+                                        GDK_ACTION_MOVE, NULL, copy_move_on_finished, NULL);
af40a0
 
af40a0
     g_list_free_full (source_files, g_free);
af40a0
     nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
af40a0
@@ -254,8 +243,8 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
af40a0
                       G_CALLBACK (handle_copy_uris),
af40a0
                       self);
af40a0
     g_signal_connect (self->file_operations,
af40a0
-                      "handle-copy-file",
af40a0
-                      G_CALLBACK (handle_copy_file),
af40a0
+                      "handle-move-uris",
af40a0
+                      G_CALLBACK (handle_move_uris),
af40a0
                       self);
af40a0
     g_signal_connect (self->file_operations,
af40a0
                       "handle-empty-trash",
af40a0
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
af40a0
index cf5e7f46b..e306e7eff 100644
af40a0
--- a/src/nautilus-file-operations.c
af40a0
+++ b/src/nautilus-file-operations.c
af40a0
@@ -5705,47 +5705,6 @@ copy_task_thread_func (GTask        *task,
af40a0
                 &source_info, &transfer_info);
af40a0
 }
af40a0
 
af40a0
-void
af40a0
-nautilus_file_operations_copy_file (GFile                *source_file,
af40a0
-                                    GFile                *target_dir,
af40a0
-                                    const gchar          *source_display_name,
af40a0
-                                    const gchar          *new_name,
af40a0
-                                    GtkWindow            *parent_window,
af40a0
-                                    NautilusCopyCallback  done_callback,
af40a0
-                                    gpointer              done_callback_data)
af40a0
-{
af40a0
-    GTask *task;
af40a0
-    CopyMoveJob *job;
af40a0
-
af40a0
-    job = op_job_new (CopyMoveJob, parent_window);
af40a0
-    job->done_callback = done_callback;
af40a0
-    job->done_callback_data = done_callback_data;
af40a0
-    job->files = g_list_append (NULL, g_object_ref (source_file));
af40a0
-    job->destination = g_object_ref (target_dir);
af40a0
-    /* Need to indicate the destination for the operation notification open
af40a0
-     * button. */
af40a0
-    nautilus_progress_info_set_destination (((CommonJob *) job)->progress, target_dir);
af40a0
-    job->target_name = g_strdup (new_name);
af40a0
-    job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
af40a0
-
af40a0
-    if (source_display_name != NULL)
af40a0
-    {
af40a0
-        gchar *path;
af40a0
-
af40a0
-        path = g_build_filename ("/", source_display_name, NULL);
af40a0
-        job->fake_display_source = g_file_new_for_path (path);
af40a0
-
af40a0
-        g_free (path);
af40a0
-    }
af40a0
-
af40a0
-    inhibit_power_manager ((CommonJob *) job, _("Copying Files"));
af40a0
-
af40a0
-    task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);
af40a0
-    g_task_set_task_data (task, job, NULL);
af40a0
-    g_task_run_in_thread (task, copy_task_thread_func);
af40a0
-    g_object_unref (task);
af40a0
-}
af40a0
-
af40a0
 void
af40a0
 nautilus_file_operations_copy (GList                *files,
af40a0
                                GFile                *target_dir,
af40a0
diff --git a/src/nautilus-file-operations.h b/src/nautilus-file-operations.h
af40a0
index e8c6ed393..2a9c6a6a0 100644
af40a0
--- a/src/nautilus-file-operations.h
af40a0
+++ b/src/nautilus-file-operations.h
af40a0
@@ -57,13 +57,6 @@ void nautilus_file_operations_copy_move   (const GList               *item_uris,
af40a0
 					   GtkWidget                 *parent_view,
af40a0
 					   NautilusCopyCallback       done_callback,
af40a0
 					   gpointer                   done_callback_data);
af40a0
-void nautilus_file_operations_copy_file (GFile *source_file,
af40a0
-					 GFile *target_dir,
af40a0
-					 const gchar *source_display_name,
af40a0
-					 const gchar *new_name,
af40a0
-					 GtkWindow *parent_window,
af40a0
-					 NautilusCopyCallback done_callback,
af40a0
-					 gpointer done_callback_data);
af40a0
 void nautilus_file_operations_empty_trash (GtkWidget                 *parent_view);
af40a0
 void nautilus_file_operations_new_folder  (GtkWidget                 *parent_view,
af40a0
 					   const char                *parent_dir_uri,
af40a0
-- 
af40a0
2.17.1
af40a0