From efa11999bab127572a34d60ab5b133d1b6562a0b Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Fri, 3 Sep 2010 11:27:52 -0400 Subject: [PATCH] Add skeleton for UDisksFilesystem implementation and use it Signed-off-by: David Zeuthen --- src/Makefile.am | 1 + src/linuxblock.c | 7 ++-- src/types.h | 3 ++ src/udisksfilesystemimpl.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ src/udisksfilesystemimpl.h | 36 ++++++++++++++++++ 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 src/udisksfilesystemimpl.c create mode 100644 src/udisksfilesystemimpl.h diff --git a/src/Makefile.am b/src/Makefile.am index c1c4d2c..2ac7fbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,6 +28,7 @@ udisks_daemon_SOURCES = \ gposixsignal.h gposixsignal.c \ types.h \ linuxblock.h linuxblock.c \ + udisksfilesystemimpl.h udisksfilesystemimpl.c \ $(NULL) udisks_daemon_CPPFLAGS = \ diff --git a/src/linuxblock.c b/src/linuxblock.c index f6f7a5e..c036603 100644 --- a/src/linuxblock.c +++ b/src/linuxblock.c @@ -20,10 +20,11 @@ #include "config.h" -#include "linuxblock.h" - #include +#include "linuxblock.h" +#include "udisksfilesystemimpl.h" + typedef struct { GDBusObjectManager *object_manager; @@ -224,7 +225,7 @@ linux_block_update (LinuxBlock *block, update_iface (block, uevent_action, block_device_probed_check, block_device_probed_update, UDISKS_TYPE_BLOCK_DEVICE_PROBED_STUB, &block->iface_block_device_probed); update_iface (block, uevent_action, filesystem_check, filesystem_update, - UDISKS_TYPE_FILESYSTEM_STUB, &block->iface_filesystem); + UDISKS_TYPE_FILESYSTEM_IMPL, &block->iface_filesystem); } /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/types.h b/src/types.h index 234fe34..5e6d684 100644 --- a/src/types.h +++ b/src/types.h @@ -25,4 +25,7 @@ #include #include +struct _UDisksFilesystemImpl; +typedef struct _UDisksFilesystemImpl UDisksFilesystemImpl; + #endif diff --git a/src/udisksfilesystemimpl.c b/src/udisksfilesystemimpl.c new file mode 100644 index 0000000..c56fd13 --- /dev/null +++ b/src/udisksfilesystemimpl.c @@ -0,0 +1,93 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2007-2010 David Zeuthen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" + +#include "udisksfilesystemimpl.h" + +typedef struct _UDisksFilesystemImplClass UDisksFilesystemImplClass; + +struct _UDisksFilesystemImpl +{ + UDisksFilesystemStub parent_instance; +}; + +struct _UDisksFilesystemImplClass +{ + UDisksFilesystemStubClass parent_class; + gpointer padding[8]; +}; + +static void filesystem_iface_init (UDisksFilesystemIface *iface); + +G_DEFINE_TYPE_WITH_CODE (UDisksFilesystemImpl, udisks_filesystem_impl, UDISKS_TYPE_FILESYSTEM_STUB, + G_IMPLEMENT_INTERFACE (UDISKS_TYPE_FILESYSTEM, filesystem_iface_init)); + +static void +udisks_filesystem_impl_init (UDisksFilesystemImpl *filesystem) +{ +} + +static void +udisks_filesystem_impl_class_init (UDisksFilesystemImplClass *klass) +{ +} + +UDisksFilesystem * +udisks_filesystem_impl_new (void) +{ + return UDISKS_FILESYSTEM (g_object_new (UDISKS_TYPE_FILESYSTEM_IMPL, NULL)); +} + +/* ---------------------------------------------------------------------------------------------------- */ + +static gboolean +handle_mount (UDisksFilesystem *object, + GDBusMethodInvocation *invocation, + const gchar *filesystem_type, + const gchar* const *options) +{ + //UDisksFilesystemImpl *filesystem = UDISKS_FILESYSTEM_IMPL (object); + g_dbus_method_invocation_return_dbus_error (invocation, "org.foo.error.mount", "no, not yet implemented"); + return TRUE; +} + +/* ---------------------------------------------------------------------------------------------------- */ + +static gboolean +handle_unmount (UDisksFilesystem *object, + GDBusMethodInvocation *invocation, + const gchar* const *options) +{ + //UDisksFilesystemImpl *filesystem = UDISKS_FILESYSTEM_IMPL (object); + g_dbus_method_invocation_return_dbus_error (invocation, "org.foo.error.unmount", "no, not yet implemented"); + return TRUE; +} + +/* ---------------------------------------------------------------------------------------------------- */ + +static void +filesystem_iface_init (UDisksFilesystemIface *iface) +{ + iface->handle_mount = handle_mount; + iface->handle_unmount = handle_unmount; +} + +/* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/udisksfilesystemimpl.h b/src/udisksfilesystemimpl.h new file mode 100644 index 0000000..c5baa2d --- /dev/null +++ b/src/udisksfilesystemimpl.h @@ -0,0 +1,36 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2007-2010 David Zeuthen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __UDISKS_FILESYSTEM_IMPL_H__ +#define __UDISKS_FILESYSTEM_IMPL_H__ + +#include "types.h" + +G_BEGIN_DECLS + +#define UDISKS_TYPE_FILESYSTEM_IMPL (udisks_filesystem_impl_get_type ()) +#define UDISKS_FILESYSTEM_IMPL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UDISKS_TYPE_FILESYSTEM_IMPL, UDisksFilesystemImpl)) +#define UDISKS_IS_FILESYSTEM_IMPL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UDISKS_TYPE_FILESYSTEM_IMPL)) + +GType udisks_filesystem_impl_get_type (void) G_GNUC_CONST; +UDisksFilesystem *udisks_filesystem_impl_new (void); + + +#endif /* __UDISKS_FILESYSTEM_IMPL_H__ */ -- 2.7.4