summaryrefslogtreecommitdiff
path: root/daemon/gvfsdaemon.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 10:37:59 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 10:37:59 +0000
commit3eb2c102c1d95a7cd205267754a38799792a66c2 (patch)
tree20295aa5604b5de82ad167607d842d9083bbfccf /daemon/gvfsdaemon.c
parent31d8952c4e4e97018537902993889dcd5299c991 (diff)
downloadgvfs-3eb2c102c1d95a7cd205267754a38799792a66c2.tar.gz
New model to handle uris. All uri -> dbus mapping is done client side.
The mappings will be specified in a config file the client reads Original git commit by Alexander Larsson <alex@greebo.(none)> at 1165844556 +0100 svn path=/trunk/; revision=222
Diffstat (limited to 'daemon/gvfsdaemon.c')
-rw-r--r--daemon/gvfsdaemon.c147
1 files changed, 1 insertions, 146 deletions
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index 26bb0f20..2cbadfa2 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -14,7 +14,6 @@
#include <gvfsdaemonprotocol.h>
#include <gvfsdaemonutils.h>
#include <gvfsjobopenforread.h>
-#include <gvfsmountpoint.h>
G_DEFINE_TYPE (GVfsDaemon, g_vfs_daemon, G_TYPE_OBJECT);
@@ -28,12 +27,6 @@ typedef struct {
gpointer data;
} RegisteredPath;
-typedef struct {
- char *owner;
- char *path;
- GVfsMountpoint *mountpoint;
-} MountpointData;
-
struct _GVfsDaemonPrivate
{
GMutex *lock;
@@ -46,7 +39,6 @@ struct _GVfsDaemonPrivate
GQueue *jobs;
guint queued_job_start;
GList *job_sources;
- GList *tracked_mountpoints; /* Only accessed from main thread */
};
typedef struct {
@@ -209,22 +201,6 @@ g_vfs_daemon_new (gboolean main_daemon, gboolean replace)
}
- if (main_daemon)
- {
- dbus_bus_add_match (conn,
- "interface='"G_VFS_DBUS_MOUNTPOINT_INTERFACE"',"
- "member='"G_VFS_DBUS_ANNOUNCE_MOUNTPOINT"'",
- &error);
- if (dbus_error_is_set (&error))
- {
- g_printerr ("Failed to connect to add dbus match: %s\n",
- error.message);
- dbus_error_free (&error);
- return NULL;
- }
- }
-
-
dbus_connection_setup_with_g_main (conn, NULL);
daemon = g_object_new (G_TYPE_VFS_DAEMON, NULL);
@@ -818,47 +794,9 @@ daemon_message_func (DBusConnection *conn,
gpointer data)
{
GVfsDaemon *daemon = data;
- GList *l, *next;
RegisteredPath *registered_path;
- MountpointData *mount_data;
const char *path;
- if (daemon->priv->main_daemon &&
- dbus_message_is_signal (message, G_VFS_DBUS_MOUNTPOINT_INTERFACE,
- G_VFS_DBUS_ANNOUNCE_MOUNTPOINT))
- {
- const char *path = dbus_message_get_path (message);
- const char *sender = dbus_message_get_sender (message);
- DBusMessageIter iter;
-
- for (l = daemon->priv->tracked_mountpoints; l != NULL; l = l->next)
- {
- mount_data = l->data;
- if (strcmp (mount_data->owner, sender) == 0 &&
- strcmp (mount_data->path, path) == 0)
- break;
- }
-
- if (l == NULL)
- {
- GVfsMountpoint *mountpoint;
-
- if (dbus_message_iter_init (message, &iter) &&
- (mountpoint = g_vfs_mountpoint_from_dbus (&iter)) != NULL)
- {
- mount_data = g_new0 (MountpointData, 1);
- mount_data->mountpoint = mountpoint;
- mount_data->owner = g_strdup (sender);
- mount_data->path = g_strdup (path);
-
- g_print ("Added mountpoint: %s, %s, %s\n", mount_data->owner, mount_data->path, mount_data->mountpoint->method);
-
- daemon->priv->tracked_mountpoints =
- g_list_prepend (daemon->priv->tracked_mountpoints, mount_data);
- }
- }
- }
-
if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
{
char *name, *from, *to;
@@ -872,97 +810,14 @@ daemon_message_func (DBusConnection *conn,
g_print ("NameOwnerChanged %s %s->%s (my name: %s)\n", name, from, to, my_name);
+ /* TODO: We should use NameLost here */
if (strcmp (name, G_VFS_DBUS_DAEMON_NAME) == 0)
{
/* Someone else got the name (i.e. someone used --replace), exit */
if (daemon->priv->main_daemon &&
strcmp (to, my_name) != 0)
exit (1);
-
- if (*to != 0)
- {
- GList *l;
-
- /* New owner, tell all backends to re-register */
- g_mutex_lock (daemon->priv->lock);
- for (l = daemon->priv->job_sources; l != NULL; l = l->next)
- {
- GVfsJobSource *source = l->data;
- g_vfs_job_source_reset (source);
- }
- g_mutex_unlock (daemon->priv->lock);
- }
- }
-
- if (*name == ':' && *to == 0)
- {
- /* Sender died */
-
- l = daemon->priv->tracked_mountpoints;
- while (l != NULL)
- {
- mount_data = l->data;
- next = l->next;
-
- if (strcmp (mount_data->owner, name) == 0)
- {
- g_print ("Removed mountpoint: %s, %s, %s\n", mount_data->owner, mount_data->path, mount_data->mountpoint->method);
- g_vfs_mountpoint_free (mount_data->mountpoint);
- g_free (mount_data->owner);
- g_free (mount_data->path);
- g_free (mount_data);
- daemon->priv->tracked_mountpoints =
- g_list_delete_link (daemon->priv->tracked_mountpoints, l);
- }
-
- l = next;
- }
- }
- }
- }
-
- if (daemon->priv->main_daemon &&
- dbus_message_is_method_call (message,
- G_VFS_DBUS_MOUNTPOINT_TRACKER_INTERFACE,
- G_VFS_DBUS_LIST_MOUNT_POINTS))
- {
- DBusMessage *reply;
- DBusMessageIter iter, array, struct_iter;
-
- reply = dbus_message_new_method_return (message);
-
- dbus_message_iter_init_append (reply, &iter);
-
-
- if (dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
- DBUS_STRUCT_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- G_VFS_MOUNTPOINT_SIGNATURE
- DBUS_STRUCT_END_CHAR_AS_STRING,
- &array))
- {
- for (l = daemon->priv->tracked_mountpoints; l != NULL; l = l->next)
- {
- mount_data = l->data;
-
- if (dbus_message_iter_open_container (&array, DBUS_TYPE_STRUCT,
- NULL, /* for struct */
- &struct_iter))
- {
- dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING,
- &mount_data->owner);
- dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING,
- &mount_data->path);
- g_vfs_mountpoint_to_dbus (mount_data->mountpoint, &struct_iter);
- dbus_message_iter_close_container (&array, &struct_iter);
- }
}
-
- dbus_message_iter_close_container (&iter, &array);
-
- dbus_connection_send (conn, reply, NULL);
- dbus_message_unref (reply);
}
}