diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2012-07-31 11:58:09 +0200 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2012-07-31 11:58:09 +0200 |
commit | 622a5c0d167556188c38fcde40a42a0dfad9c625 (patch) | |
tree | 04f27be7f2a54779e17029ede2554e39c3464aa0 /daemon/gvfsjobcreatemonitor.c | |
parent | a494b809eaf82994108bfbbe5d950fed1a0a8c7c (diff) | |
download | gvfs-622a5c0d167556188c38fcde40a42a0dfad9c625.tar.gz |
gdbus: Core daemon and client port
Port of most of the gvfs core, few bits still missing. Lot of debug prints around,
will be removed in further commits. Same amount of TODOs and FIXMEs.
Notes:
* kill serials?
* get rid of mainloops where applicable (copy/move progress callback, enumerator)
* fix keyring integration
* use gdbus builtin fd passing within gvfsdaemon.c, kill the extra_fd stuff
Diffstat (limited to 'daemon/gvfsjobcreatemonitor.c')
-rw-r--r-- | daemon/gvfsjobcreatemonitor.c | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/daemon/gvfsjobcreatemonitor.c b/daemon/gvfsjobcreatemonitor.c index e788ee43..4e3d772e 100644 --- a/daemon/gvfsjobcreatemonitor.c +++ b/daemon/gvfsjobcreatemonitor.c @@ -28,19 +28,16 @@ #include <sys/un.h> #include <glib.h> -#include <dbus/dbus.h> #include <glib/gi18n.h> #include "gvfsjobcreatemonitor.h" -#include "gvfsdbusutils.h" -#include "gvfsdaemonutils.h" G_DEFINE_TYPE (GVfsJobCreateMonitor, g_vfs_job_create_monitor, G_VFS_TYPE_JOB_DBUS) static void run (GVfsJob *job); static gboolean try (GVfsJob *job); -static DBusMessage *create_reply (GVfsJob *job, - DBusConnection *connection, - DBusMessage *message); +static void create_reply (GVfsJob *job, + GVfsDBusMount *object, + GDBusMethodInvocation *invocation); static void g_vfs_job_create_monitor_finalize (GObject *object) @@ -75,50 +72,59 @@ g_vfs_job_create_monitor_init (GVfsJobCreateMonitor *job) { } -GVfsJob * -g_vfs_job_create_monitor_new (DBusConnection *connection, - DBusMessage *message, - GVfsBackend *backend, - gboolean is_directory) + +static gboolean +create_monitor_new_handle (GVfsDBusMount *object, + GDBusMethodInvocation *invocation, + const gchar *arg_path_data, + guint arg_flags, + GVfsBackend *backend, + gboolean is_directory) { GVfsJobCreateMonitor *job; - DBusMessage *reply; - DBusMessageIter iter; - DBusError derror; - char *path; - guint32 flags; - - dbus_error_init (&derror); - dbus_message_iter_init (message, &iter); - - path = NULL; - if (!_g_dbus_message_iter_get_args (&iter, &derror, - G_DBUS_TYPE_CSTRING, &path, - DBUS_TYPE_UINT32, &flags, - 0)) - { - g_free (path); - reply = dbus_message_new_error (message, - derror.name, - derror.message); - dbus_error_free (&derror); - - dbus_connection_send (connection, reply, NULL); - dbus_message_unref (reply); - return NULL; - } + if (g_vfs_backend_invocation_first_handler (object, invocation, backend)) + return TRUE; + job = g_object_new (G_VFS_TYPE_JOB_CREATE_MONITOR, - "message", message, - "connection", connection, - NULL); - + "object", object, + "invocation", invocation, + NULL); + job->is_directory = is_directory; - job->filename = path; + job->filename = g_strdup (arg_path_data); job->backend = backend; - job->flags = flags; + job->flags = arg_flags; + + g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (backend), G_VFS_JOB (job)); + g_object_unref (job); + + return TRUE; +} + +gboolean +g_vfs_job_create_file_monitor_new_handle (GVfsDBusMount *object, + GDBusMethodInvocation *invocation, + const gchar *arg_path_data, + guint arg_flags, + GVfsBackend *backend) +{ + g_print ("called CreateFileMonitor()\n"); - return G_VFS_JOB (job); + return create_monitor_new_handle (object, invocation, arg_path_data, arg_flags, backend, FALSE); +} + + +gboolean +g_vfs_job_create_directory_monitor_new_handle (GVfsDBusMount *object, + GDBusMethodInvocation *invocation, + const gchar *arg_path_data, + guint arg_flags, + GVfsBackend *backend) +{ + g_print ("called CreateDirectoryMonitor()\n"); + + return create_monitor_new_handle (object, invocation, arg_path_data, arg_flags, backend, TRUE); } void @@ -217,18 +223,14 @@ unref_monitor_timeout (gpointer data) } /* Might be called on an i/o thread */ -static DBusMessage * +static void create_reply (GVfsJob *job, - DBusConnection *connection, - DBusMessage *message) + GVfsDBusMount *object, + GDBusMethodInvocation *invocation) { GVfsJobCreateMonitor *op_job = G_VFS_JOB_CREATE_MONITOR (job); - DBusMessage *reply; - DBusMessageIter iter; const char *obj_path; - reply = dbus_message_new_method_return (message); - /* Keep the monitor alive for at least 5 seconds to allow for a subscribe call to come in and bump the refcount */ @@ -238,10 +240,9 @@ create_reply (GVfsJob *job, op_job->monitor); obj_path = g_vfs_monitor_get_object_path (op_job->monitor); - dbus_message_iter_init_append (reply, &iter); - _g_dbus_message_append_args (reply, - DBUS_TYPE_OBJECT_PATH, &obj_path, - 0); - return reply; + if (op_job->is_directory) + gvfs_dbus_mount_complete_create_directory_monitor (object, invocation, obj_path); + else + gvfs_dbus_mount_complete_create_file_monitor (object, invocation, obj_path); } |