[gvfs] monitor: handle show-unmount-progress signal



commit 8c61a01d9b143842fceb641e9ee03cb30bebb4ef
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jul 9 21:20:19 2012 -0400

    monitor: handle show-unmount-progress signal
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676111

 monitor/proxy/dbus-interfaces.xml            |    7 +++
 monitor/proxy/gproxymountoperation.c         |   29 +++++++++++++
 monitor/proxy/gproxymountoperation.h         |    5 ++
 monitor/proxy/gproxyvolumemonitor.c          |   29 +++++++++++++
 monitor/proxy/gvfsproxyvolumemonitordaemon.c |   56 ++++++++++++++++++++++++++
 5 files changed, 126 insertions(+), 0 deletions(-)
---
diff --git a/monitor/proxy/dbus-interfaces.xml b/monitor/proxy/dbus-interfaces.xml
index 49af8c7..7ea8a8d 100644
--- a/monitor/proxy/dbus-interfaces.xml
+++ b/monitor/proxy/dbus-interfaces.xml
@@ -108,6 +108,13 @@
       <arg type='ai' name='pid'/>
       <arg type='as' name='choices'/>
     </signal>
+    <signal name="MountOpShowUnmountProgress">
+      <arg type='s' name='dbus_name'/>
+      <arg type='s' name='id'/>
+      <arg type='s' name='message_to_show'/>
+      <arg type='t' name='time_left'/>
+      <arg type='t' name='bytes_left'/>
+    </signal>
     <signal name="MountOpAborted">
       <arg type='s' name='dbus_name'/>
       <arg type='s' name='id'/>
diff --git a/monitor/proxy/gproxymountoperation.c b/monitor/proxy/gproxymountoperation.c
index 5253d59..c21e991 100644
--- a/monitor/proxy/gproxymountoperation.c
+++ b/monitor/proxy/gproxymountoperation.c
@@ -307,6 +307,35 @@ g_proxy_mount_operation_handle_show_processes (const gchar        *wrapped_id,
 /* ---------------------------------------------------------------------------------------------------- */
 
 void
+g_proxy_mount_operation_handle_show_unmount_progress (const gchar *wrapped_id,
+                                                      const gchar *message,
+                                                      guint64      time_left,
+                                                      guint64      bytes_left)
+{
+  ProxyMountOpData *data;
+
+  g_return_if_fail (wrapped_id != NULL);
+
+  if (id_to_op == NULL)
+    return;
+  
+  G_LOCK (proxy_op);
+  data = g_hash_table_lookup (id_to_op, wrapped_id);
+  G_UNLOCK (proxy_op);
+
+  if (data == NULL)
+    return;
+
+  g_signal_emit_by_name (data->op,
+                         "show-unmount-progress",
+                         message,
+                         time_left,
+                         bytes_left);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+void
 g_proxy_mount_operation_handle_aborted (const gchar *wrapped_id)
 {
   ProxyMountOpData *data;
diff --git a/monitor/proxy/gproxymountoperation.h b/monitor/proxy/gproxymountoperation.h
index a7d51b8..854a102 100644
--- a/monitor/proxy/gproxymountoperation.h
+++ b/monitor/proxy/gproxymountoperation.h
@@ -49,6 +49,11 @@ void  g_proxy_mount_operation_handle_show_processes (const gchar        *wrapped
                                                      GVariant           *pids,
                                                      const gchar *const *choices);
 
+void  g_proxy_mount_operation_handle_show_unmount_progress (const gchar *wrapped_id,
+                                                            const gchar *message,
+                                                            guint64      time_left,
+                                                            guint64      bytes_left);
+
 void  g_proxy_mount_operation_handle_aborted        (const gchar      *wrapped_id);
 
 void  g_proxy_mount_operation_destroy               (const gchar      *wrapped_id);
diff --git a/monitor/proxy/gproxyvolumemonitor.c b/monitor/proxy/gproxyvolumemonitor.c
index 6aab4dc..eb7a187 100644
--- a/monitor/proxy/gproxyvolumemonitor.c
+++ b/monitor/proxy/gproxyvolumemonitor.c
@@ -726,6 +726,34 @@ mount_op_show_processes (GVfsRemoteVolumeMonitor *object,
 }
 
 static void
+mount_op_show_unmount_progress (GVfsRemoteVolumeMonitor *object,
+                                const gchar *arg_dbus_name,
+                                const gchar *arg_id,
+                                const gchar *arg_message_to_show,
+                                guint64      arg_time_left,
+                                guint64      arg_bytes_left,
+                                gpointer user_data)
+{
+  GProxyVolumeMonitor *monitor = G_PROXY_VOLUME_MONITOR (user_data);
+  GProxyVolumeMonitorClass *klass;
+
+  G_LOCK (proxy_vm);
+
+  klass = G_PROXY_VOLUME_MONITOR_CLASS (G_OBJECT_GET_CLASS (monitor));
+
+  if (strcmp (arg_dbus_name, klass->dbus_name) != 0)
+    goto not_for_us;
+  
+  g_proxy_mount_operation_handle_show_unmount_progress (arg_id,
+                                                        arg_message_to_show,
+                                                        arg_time_left,
+                                                        arg_bytes_left);
+
+  not_for_us:
+   G_UNLOCK (proxy_vm);
+}
+
+static void
 volume_added (GVfsRemoteVolumeMonitor *object,
               const gchar *arg_dbus_name,
               const gchar *arg_id,
@@ -962,6 +990,7 @@ g_proxy_volume_monitor_constructor (GType                  type,
   g_signal_connect (monitor->proxy, "mount-op-ask-password", G_CALLBACK (mount_op_ask_password), monitor);
   g_signal_connect (monitor->proxy, "mount-op-ask-question", G_CALLBACK (mount_op_ask_question), monitor);
   g_signal_connect (monitor->proxy, "mount-op-show-processes", G_CALLBACK (mount_op_show_processes), monitor);
+  g_signal_connect (monitor->proxy, "mount-op-show-unmount-progress", G_CALLBACK (mount_op_show_unmount_progress), monitor);
   g_signal_connect (monitor->proxy, "mount-pre-unmount", G_CALLBACK (mount_pre_unmount), monitor);
   g_signal_connect (monitor->proxy, "mount-removed", G_CALLBACK (mount_removed), monitor);
   g_signal_connect (monitor->proxy, "volume-added", G_CALLBACK (volume_added), monitor);
diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.c b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
index 713250c..daa8a5f 100644
--- a/monitor/proxy/gvfsproxyvolumemonitordaemon.c
+++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
@@ -125,6 +125,15 @@ g_proxy_mount_operation_show_processes (GMountOperation *op,
 }
 
 static void
+g_proxy_mount_operation_show_unmount_progress (GMountOperation *op,
+                                               const gchar     *message,
+                                               guint64          time_left,
+                                               guint64          bytes_left)
+{
+  /* do nothing */
+}
+
+static void
 g_proxy_mount_operation_class_init (GProxyMountOperationClass *klass)
 {
   GMountOperationClass *mount_op_class;
@@ -134,6 +143,7 @@ g_proxy_mount_operation_class_init (GProxyMountOperationClass *klass)
   mount_op_class->ask_password   = g_proxy_mount_operation_ask_password;
   mount_op_class->ask_question   = g_proxy_mount_operation_ask_question;
   mount_op_class->show_processes = g_proxy_mount_operation_show_processes;
+  mount_op_class->show_unmount_progress = g_proxy_mount_operation_show_unmount_progress;
 }
 
 static void
@@ -304,6 +314,51 @@ show_processes_cb (GMountOperation          *mount_operation,
 }
 
 static void
+show_unmount_progress_cb (GMountOperation *mount_operation,
+                          const gchar *message_to_show,
+                          guint64 time_left,
+                          guint64 bytes_left,
+                          GVfsRemoteVolumeMonitor *monitor)
+{
+  const gchar *mount_op_id;
+  const gchar *mount_op_owner;
+  GDBusConnection *connection;
+  GError *error;
+
+  print_debug ("in show_unmount_progress_cb %s", message_to_show);
+
+  mount_op_id = g_object_get_data (G_OBJECT (mount_operation), "mount_op_id");
+  mount_op_owner = g_object_get_data (G_OBJECT (mount_operation), "mount_op_owner");
+
+  print_debug ("  owner =  '%s'", mount_op_owner);
+
+  if (message_to_show == NULL)
+    message_to_show = "";
+
+  connection = g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (monitor));
+  g_assert (connection != NULL);
+  
+  error = NULL;
+  if (!g_dbus_connection_emit_signal (connection,
+                                      mount_op_owner,
+                                      "/org/gtk/Private/RemoteVolumeMonitor",
+                                      "org.gtk.Private.RemoteVolumeMonitor",
+                                      "MountOpShowUnmountProgress",
+                                      g_variant_new ("(ssstt)",
+                                                     the_dbus_name,
+                                                     mount_op_id,
+                                                     message_to_show,
+                                                     time_left,
+                                                     bytes_left),
+                                      &error))
+    {
+      g_printerr ("Error emitting signal: %s (%s, %d)\n",
+                  error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+    }
+}
+
+static void
 aborted_cb (GMountOperation         *mount_operation,
             GVfsRemoteVolumeMonitor *monitor)
 {
@@ -356,6 +411,7 @@ wrap_mount_op (const gchar *mount_op_id,
   g_signal_connect (op, "ask-password", G_CALLBACK (ask_password_cb), monitor);
   g_signal_connect (op, "ask-question", G_CALLBACK (ask_question_cb), monitor);
   g_signal_connect (op, "show-processes", G_CALLBACK (show_processes_cb), monitor);
+  g_signal_connect (op, "show-unmount-progress", G_CALLBACK (show_unmount_progress_cb), monitor);
   g_signal_connect (op, "aborted", G_CALLBACK (aborted_cb), monitor);
   g_object_set_data_full (G_OBJECT (op), "mount_op_id", g_strdup (mount_op_id), g_free);
   g_object_set_data_full (G_OBJECT (op), "mount_op_owner", g_strdup (mount_op_owner), g_free);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]