[gvfs/wip/udisks2] udisks2: Add empty volume monitor skeleton



commit 1b9ffa0e23dfcbd58ad2711dfd94d2234607f3a9
Author: David Zeuthen <davidz redhat com>
Date:   Mon Sep 26 11:39:09 2011 -0400

    udisks2: Add empty volume monitor skeleton
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 configure.ac                                       |    1 +
 monitor/Makefile.am                                |    4 +
 monitor/udisks2/Makefile.am                        |   53 ++++++
 monitor/udisks2/gvfsudisks2volumemonitor.c         |  189 ++++++++++++++++++++
 monitor/udisks2/gvfsudisks2volumemonitor.h         |   51 ++++++
 ...org.gtk.Private.UDisks2VolumeMonitor.service.in |    3 +
 monitor/udisks2/udisks2.monitor                    |    5 +
 monitor/udisks2/udisks2volumemonitordaemon.c       |   46 +++++
 8 files changed, 352 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 36830d3..764d7d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -751,6 +751,7 @@ monitor/Makefile
 monitor/proxy/Makefile
 monitor/hal/Makefile
 monitor/gdu/Makefile
+monitor/udisks2/Makefile
 monitor/gphoto2/Makefile
 monitor/afc/Makefile
 programs/Makefile
diff --git a/monitor/Makefile.am b/monitor/Makefile.am
index 1dc984f..0abe0e9 100644
--- a/monitor/Makefile.am
+++ b/monitor/Makefile.am
@@ -9,6 +9,10 @@ if USE_GDU
 SUBDIRS += gdu
 endif
 
+if USE_UDISKS2
+SUBDIRS += udisks2
+endif
+
 if USE_GPHOTO2
 SUBDIRS += gphoto2
 endif
diff --git a/monitor/udisks2/Makefile.am b/monitor/udisks2/Makefile.am
new file mode 100644
index 0000000..5c0ed40
--- /dev/null
+++ b/monitor/udisks2/Makefile.am
@@ -0,0 +1,53 @@
+
+NULL =
+
+libexec_PROGRAMS = gvfs-udisks2-volume-monitor
+
+#	gvfsudisks2drive.c		gvfsudisks2drive.h		\
+#	gvfsudisks2volume.c		gvfsudisks2volume.h		\
+#	gvfsudisks2mount.c		gvfsudisks2mount.h		\
+#
+
+gvfs_udisks2_volume_monitor_SOURCES =					\
+	udisks2volumemonitordaemon.c					\
+	gvfsudisks2volumemonitor.c	gvfsudisks2volumemonitor.h	\
+	$(NULL)
+
+gvfs_udisks2_volume_monitor_CFLAGS =		\
+	-DG_LOG_DOMAIN=\"GVFS-UDisks2\"		\
+	-I$(top_srcdir)/common                  \
+	-I$(top_srcdir)/monitor/proxy           \
+	$(GLIB_CFLAGS)                          \
+	$(UDISKS2_CFLAGS)                       \
+	$(GUDEV_CFLAGS)                         \
+	-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"	\
+	-DGVFS_LOCALEDIR=\""$(localedir)"\"	\
+	-DG_DISABLE_DEPRECATED			\
+	-DUDISKS_API_IS_SUBJECT_TO_CHANGE	\
+	$(NULL)
+
+gvfs_udisks2_volume_monitor_LDFLAGS =	\
+	$(NULL)
+
+gvfs_udisks2_volume_monitor_LDADD  =		     			      	\
+	$(GLIB_LIBS)                                 			      	\
+	$(UDISKS2_LIBS)                                  			\
+	$(GUDEV_LIBS)                                  			      	\
+	$(top_builddir)/common/libgvfscommon.la 			      	\
+	$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la 	\
+	$(NULL)
+
+remote_volume_monitorsdir = $(datadir)/gvfs/remote-volume-monitors
+remote_volume_monitors_DATA = udisks2.monitor
+
+servicedir       = $(datadir)/dbus-1/services
+service_in_files = org.gtk.Private.UDisks2VolumeMonitor.service.in
+service_DATA     = $(service_in_files:.service.in=.service)
+
+$(service_DATA): $(service_in_files) Makefile
+	$(AM_V_GEN) $(SED) -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
+
+clean-local:
+	rm -f *~ *.loT $(BUILT_SOURCES) $(service_DATA)
+
+EXTRA_DIST = $(service_in_files) udisks2.monitor
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
new file mode 100644
index 0000000..078fb60
--- /dev/null
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -0,0 +1,189 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* gvfs - extensions for gio
+ *
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include <config.h>
+
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
+
+#include "gvfsudisks2volumemonitor.h"
+
+static GVfsUDisks2VolumeMonitor *the_volume_monitor = NULL;
+
+typedef struct _GVfsUDisks2VolumeMonitorClass GVfsUDisks2VolumeMonitorClass;
+
+struct _GVfsUDisks2VolumeMonitorClass
+{
+  GNativeVolumeMonitorClass parent_class;
+};
+
+struct _GVfsUDisks2VolumeMonitor
+{
+  GNativeVolumeMonitor parent;
+};
+
+G_DEFINE_TYPE (GVfsUDisks2VolumeMonitor, gvfs_udisks2_volume_monitor, G_TYPE_NATIVE_VOLUME_MONITOR)
+
+static void
+gvfs_udisks2_volume_monitor_dispose (GObject *object)
+{
+  the_volume_monitor = NULL;
+
+  if (G_OBJECT_CLASS (gvfs_udisks2_volume_monitor_parent_class)->dispose)
+    (*G_OBJECT_CLASS (gvfs_udisks2_volume_monitor_parent_class)->dispose) (object);
+}
+
+static void
+gvfs_udisks2_volume_monitor_finalize (GObject *object)
+{
+  /* GVfsUDisks2VolumeMonitor *monitor = GVFS_UDISKS2_VOLUME_MONITOR (object); */
+
+  (*G_OBJECT_CLASS (gvfs_udisks2_volume_monitor_parent_class)->finalize) (object);
+}
+
+static GList *
+get_mounts (GVolumeMonitor *volume_monitor)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GList *
+get_volumes (GVolumeMonitor *volume_monitor)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GList *
+get_connected_drives (GVolumeMonitor *volume_monitor)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GVolume *
+get_volume_for_uuid (GVolumeMonitor *volume_monitor,
+                     const gchar    *uuid)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GMount *
+get_mount_for_uuid (GVolumeMonitor *volume_monitor,
+                    const gchar    *uuid)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GMount *
+get_mount_for_mount_path (const gchar  *mount_path,
+                          GCancellable *cancellable)
+{
+  /* TODO */
+  return NULL;
+}
+
+static GObject *
+gvfs_udisks2_volume_monitor_constructor (GType                  type,
+                                         guint                  n_construct_properties,
+                                         GObjectConstructParam *construct_properties)
+{
+  GObject *ret = NULL;
+  GVfsUDisks2VolumeMonitor *monitor;
+  GObjectClass *parent_class;
+
+  if (the_volume_monitor != NULL)
+    {
+      ret = g_object_ref (the_volume_monitor);
+      goto out;
+    }
+
+  /*g_warning ("creating gdu vm");*/
+
+  /* Invoke parent constructor. */
+  parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_peek (GVFS_TYPE_UDISKS2_VOLUME_MONITOR)));
+  ret = parent_class->constructor (type,
+                                   n_construct_properties,
+                                   construct_properties);
+
+  monitor = GVFS_UDISKS2_VOLUME_MONITOR (ret);
+
+  /* TODO: init monitor */
+
+  the_volume_monitor = monitor;
+
+ out:
+  return ret;
+}
+
+static void
+gvfs_udisks2_volume_monitor_init (GVfsUDisks2VolumeMonitor *monitor)
+{
+}
+
+static gboolean
+is_supported (void)
+{
+  /* TODO: return FALSE if udisks2 is not available */
+  return TRUE;
+}
+
+static void
+gvfs_udisks2_volume_monitor_class_init (GVfsUDisks2VolumeMonitorClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GVolumeMonitorClass *monitor_class = G_VOLUME_MONITOR_CLASS (klass);
+  GNativeVolumeMonitorClass *native_class = G_NATIVE_VOLUME_MONITOR_CLASS (klass);
+
+  gobject_class->constructor = gvfs_udisks2_volume_monitor_constructor;
+  gobject_class->finalize = gvfs_udisks2_volume_monitor_finalize;
+  gobject_class->dispose = gvfs_udisks2_volume_monitor_dispose;
+
+  monitor_class->get_mounts = get_mounts;
+  monitor_class->get_volumes = get_volumes;
+  monitor_class->get_connected_drives = get_connected_drives;
+  monitor_class->get_volume_for_uuid = get_volume_for_uuid;
+  monitor_class->get_mount_for_uuid = get_mount_for_uuid;
+  monitor_class->is_supported = is_supported;
+
+  native_class->get_mount_for_mount_path = get_mount_for_mount_path;
+}
+
+/**
+ * gvfs_udisks2_volume_monitor_new:
+ *
+ * Returns:  a new #GVolumeMonitor.
+ **/
+GVolumeMonitor *
+gvfs_udisks2_volume_monitor_new (void)
+{
+  return G_VOLUME_MONITOR (g_object_new (GVFS_TYPE_UDISKS2_VOLUME_MONITOR, NULL));
+}
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.h b/monitor/udisks2/gvfsudisks2volumemonitor.h
new file mode 100644
index 0000000..57a67ac
--- /dev/null
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.h
@@ -0,0 +1,51 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* gvfs - extensions for gio
+ *
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#ifndef __GVFS_UDISKS2_VOLUME_MONITOR_H__
+#define __GVFS_UDISKS2_VOLUME_MONITOR_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <gio/gunixmounts.h>
+
+#include <udisks/udisks.h>
+
+G_BEGIN_DECLS
+
+#define GVFS_TYPE_UDISKS2_VOLUME_MONITOR (gvfs_udisks2_volume_monitor_get_type ())
+#define GVFS_UDISKS2_VOLUME_MONITOR(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GVFS_TYPE_UDISKS2_VOLUME_MONITOR, GVfsUDisks2VolumeMonitor))
+#define G_IS_GDU_VOLUME_MONITOR(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVFS_TYPE_UDISKS2_VOLUME_MONITOR))
+
+typedef struct _GVfsUDisks2VolumeMonitor GVfsUDisks2VolumeMonitor;
+
+/* Forward definitions */
+typedef struct _GVfsUDisks2Drive GVfsUDisks2Drive;
+typedef struct _GVfsUDisks2Volume GVfsUDisks2Volume;
+typedef struct _GVfsUDisks2Mount GVfsUDisks2Mount;
+
+GType           gvfs_udisks2_volume_monitor_get_type (void) G_GNUC_CONST;
+GVolumeMonitor *gvfs_udisks2_volume_monitor_new      (void);
+
+G_END_DECLS
+
+#endif /* __GVFS_UDISKS2_VOLUME_MONITOR_H__ */
diff --git a/monitor/udisks2/org.gtk.Private.UDisks2VolumeMonitor.service.in b/monitor/udisks2/org.gtk.Private.UDisks2VolumeMonitor.service.in
new file mode 100644
index 0000000..b2d825c
--- /dev/null
+++ b/monitor/udisks2/org.gtk.Private.UDisks2VolumeMonitor.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gtk.Private.UDisks2VolumeMonitor
+Exec= libexecdir@/gvfs-udisks2-volume-monitor
diff --git a/monitor/udisks2/udisks2.monitor b/monitor/udisks2/udisks2.monitor
new file mode 100644
index 0000000..dbb0c6a
--- /dev/null
+++ b/monitor/udisks2/udisks2.monitor
@@ -0,0 +1,5 @@
+[RemoteVolumeMonitor]
+Name=GProxyVolumeMonitorUDisks2
+DBusName=org.gtk.Private.UDisks2VolumeMonitor
+IsNative=true
+NativePriority=4
diff --git a/monitor/udisks2/udisks2volumemonitordaemon.c b/monitor/udisks2/udisks2volumemonitordaemon.c
new file mode 100644
index 0000000..954d8f2
--- /dev/null
+++ b/monitor/udisks2/udisks2volumemonitordaemon.c
@@ -0,0 +1,46 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* gvfs - extensions for gio
+ *
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+#include <gio/gio.h>
+
+#include <gvfsproxyvolumemonitordaemon.h>
+
+#include "gvfsudisks2volumemonitor.h"
+
+int
+main (int argc, char *argv[])
+{
+  g_vfs_proxy_volume_monitor_daemon_init ();
+
+  g_set_application_name (_("GVfs UDisks2 Volume Monitor"));
+
+  return g_vfs_proxy_volume_monitor_daemon_main (argc,
+                                                 argv,
+                                                 "org.gtk.Private.UDisks2VolumeMonitor",
+                                                 GVFS_TYPE_UDISKS2_VOLUME_MONITOR);
+}



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