summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2015-01-25 21:37:31 +0100
committerAlexander Larsson <alexl@redhat.com>2015-01-26 13:27:28 +0100
commit623d6fd8e9912ccc0003fad97578d24f5a5e773a (patch)
tree8d1fe4f09ed2064a15cbe0f17a140fc055110254 /monitor
parentbe1191f1b2f3972441b2e8947d9a2ac71160a375 (diff)
downloadgvfs-623d6fd8e9912ccc0003fad97578d24f5a5e773a.tar.gz
Move proxy monitor implementation listing to common
Also add some to/from_dbus helpers. This is in preparation for moving the reading of the monitor files to the gvfs daemon, which is needed for the sandboxed case where the monitor files are not necessarily the same as the host installed ones.
Diffstat (limited to 'monitor')
-rw-r--r--monitor/proxy/gproxyvolumemonitor.c110
1 files changed, 12 insertions, 98 deletions
diff --git a/monitor/proxy/gproxyvolumemonitor.c b/monitor/proxy/gproxyvolumemonitor.c
index 7f05b398..ee8818c9 100644
--- a/monitor/proxy/gproxyvolumemonitor.c
+++ b/monitor/proxy/gproxyvolumemonitor.c
@@ -42,6 +42,7 @@
#include "gproxydrive.h"
#include "gproxymountoperation.h"
#include "gvfsvolumemonitordbus.h"
+#include "gvfsmonitorimpl.h"
G_LOCK_DEFINE_STATIC(proxy_vm);
@@ -1428,9 +1429,7 @@ g_proxy_volume_monitor_unload_cleanup (void)
void
g_proxy_volume_monitor_register (GIOModule *module)
{
- GDir *dir;
- GError *error;
- const char *monitors_dir;
+ GList *impls, *l;
/* first register the abstract base type... */
g_proxy_volume_monitor_register_type (G_TYPE_MODULE (module));
@@ -1446,102 +1445,17 @@ g_proxy_volume_monitor_register (GIOModule *module)
* - and if so the priority
*/
- monitors_dir = g_getenv ("GVFS_MONITOR_DIR");
- if (monitors_dir == NULL || *monitors_dir == 0)
- monitors_dir = REMOTE_VOLUME_MONITORS_DIR;
-
- error = NULL;
- dir = g_dir_open (monitors_dir, 0, &error);
- if (dir == NULL)
- {
- g_warning ("cannot open directory %s: %s", monitors_dir, error->message);
- g_error_free (error);
- }
- else
+ impls = g_vfs_list_monitor_implementations ();
+ for (l = impls; l != NULL; l = l->next)
{
- const char *name;
+ GVfsMonitorImplementation *impl = l->data;
- while ((name = g_dir_read_name (dir)) != NULL)
- {
- GKeyFile *key_file;
- char *type_name;
- char *path;
- char *dbus_name;
- gboolean is_native;
- int native_priority;
-
- type_name = NULL;
- key_file = NULL;
- dbus_name = NULL;
- path = NULL;
-
- if (!g_str_has_suffix (name, ".monitor"))
- goto cont;
-
- path = g_build_filename (monitors_dir, name, NULL);
-
- key_file = g_key_file_new ();
- error = NULL;
- if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error))
- {
- g_warning ("error loading key-value file %s: %s", path, error->message);
- g_error_free (error);
- goto cont;
- }
-
- type_name = g_key_file_get_string (key_file, "RemoteVolumeMonitor", "Name", &error);
- if (error != NULL)
- {
- g_warning ("error extracting Name key from %s: %s", path, error->message);
- g_error_free (error);
- goto cont;
- }
-
- dbus_name = g_key_file_get_string (key_file, "RemoteVolumeMonitor", "DBusName", &error);
- if (error != NULL)
- {
- g_warning ("error extracting DBusName key from %s: %s", path, error->message);
- g_error_free (error);
- goto cont;
- }
-
- is_native = g_key_file_get_boolean (key_file, "RemoteVolumeMonitor", "IsNative", &error);
- if (error != NULL)
- {
- g_warning ("error extracting IsNative key from %s: %s", path, error->message);
- g_error_free (error);
- goto cont;
- }
-
- if (is_native)
- {
- native_priority = g_key_file_get_integer (key_file, "RemoteVolumeMonitor", "NativePriority", &error);
- if (error != NULL)
- {
- g_warning ("error extracting NativePriority key from %s: %s", path, error->message);
- g_error_free (error);
- goto cont;
- }
- }
- else
- {
- native_priority = 0;
- }
-
- register_volume_monitor (G_TYPE_MODULE (module),
- type_name,
- dbus_name,
- is_native,
- native_priority);
-
- cont:
-
- g_free (type_name);
- g_free (dbus_name);
- g_free (path);
- if (key_file != NULL)
- g_key_file_free (key_file);
- }
- g_dir_close (dir);
+ register_volume_monitor (G_TYPE_MODULE (module),
+ impl->type_name,
+ impl->dbus_name,
+ impl->is_native,
+ impl->native_priority);
}
+
+ g_list_free_full (impls, (GDestroyNotify)g_vfs_monitor_implementation_free);
}