Initial definition of the plugin interface and a skeleton for the password plugin
authorAlexander Kanavin <alexander.kanavin@intel.com>
Mon, 14 Jan 2013 17:33:06 +0000 (19:33 +0200)
committerAlexander Kanavin <alexander.kanavin@intel.com>
Mon, 14 Jan 2013 17:33:06 +0000 (19:33 +0200)
configure.ac
include/gsignond/gsignond-plugin-interface.h [new file with mode: 0644]
src/Makefile.am
src/common/Makefile.am
src/common/gsignond-plugin-interface.c [new file with mode: 0644]
src/plugins/Makefile.am [new file with mode: 0644]
src/plugins/password/Makefile.am [new file with mode: 0644]
src/plugins/password/gsignond-password-plugin.c [new file with mode: 0644]
src/plugins/password/gsignond-password-plugin.h [new file with mode: 0644]

index 5d4361f..e34a3ad 100644 (file)
@@ -49,5 +49,7 @@ src/daemon/Makefile
 src/daemon/db/Makefile
 src/daemon/dbus/Makefile
 src/daemon/dbus/services/com.google.code.AccountsSSO.SingleSignOn.service
+src/plugins/Makefile
+src/plugins/password/Makefile
 test/Makefile
 ])
diff --git a/include/gsignond/gsignond-plugin-interface.h b/include/gsignond/gsignond-plugin-interface.h
new file mode 100644 (file)
index 0000000..39e0950
--- /dev/null
@@ -0,0 +1,71 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _GSIGNOND_PLUGIN_H_
+#define _GSIGNOND_PLUGIN_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_PLUGIN                           (gsignond_plugin_get_type ())
+#define GSIGNOND_PLUGIN(obj)                           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_PLUGIN, GSignondPlugin))
+#define GSIGNOND_IS_PLUGIN(obj)                                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_PLUGIN))
+#define GSIGNOND_PLUGIN_GET_INTERFACE(inst)            (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GSIGNOND_TYPE_PLUGIN, GSignondPluginInterface))
+
+typedef struct _GSignondPlugin GSignondPlugin; /* dummy object */
+typedef struct _GSignondPluginInterface GSignondPluginInterface;
+
+struct _GSignondPluginInterface {
+    GTypeInterface parent;
+
+    void       (*cancel) (GSignondPlugin *self);
+    void       (*abort) (GSignondPlugin *self);
+    void       (*process) (GSignondPlugin *self, const GVariant *session_data, const gchar *mechanism);
+    void       (*user_action_finished) (GSignondPlugin *self, const GVariant *session_data);
+    void       (*refresh) (GSignondPlugin *self, const GVariant *session_data);
+};
+
+GType gsignond_plugin_get_type (void);
+
+/* Methods */
+void gsignond_plugin_cancel (GSignondPlugin *self);
+void gsignond_plugin_abort (GSignondPlugin *self);
+void gsignond_plugin_process (GSignondPlugin *self, const GVariant *session_data, const gchar *mechanism);
+void gsignond_plugin_user_action_finished (GSignondPlugin *self, const GVariant *session_data);
+void gsignond_plugin_refresh (GSignondPlugin *self, const GVariant *session_data);
+
+/* Signals */
+void gsignond_plugin_result (GSignondPlugin *self, const GVariant *session_data);
+void gsignond_plugin_store (GSignondPlugin *self, const GVariant *session_data);
+void gsignond_plugin_error (GSignondPlugin *self, int error); //FIXME: what is the error type?
+void gsignond_plugin_user_action_required (GSignondPlugin *self, const GVariant *session_data);
+void gsignond_plugin_refreshed (GSignondPlugin *self, const GVariant *session_data);
+void gsignond_plugin_status_changed (GSignondPlugin *self, const gchar *status, const gchar *message);
+
+G_END_DECLS
+
+#endif /* _GSIGNOND_PLUGIN_H_ */
index e9500d6..5d77223 100644 (file)
@@ -1 +1 @@
-SUBDIRS=common daemon
+SUBDIRS=common daemon plugins
index 99e4808..3a62918 100644 (file)
@@ -28,6 +28,7 @@ libgsignond_common_la_SOURCES = \
     gsignond-credentials.c \
     gsignond-config.c \
     gsignond-error.c \
+    gsignond-plugin-interface.c \
     $(NULL)
 
 CLEANFILES = 
diff --git a/src/common/gsignond-plugin-interface.c b/src/common/gsignond-plugin-interface.c
new file mode 100644 (file)
index 0000000..1c6b827
--- /dev/null
@@ -0,0 +1,143 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+
+#include "gsignond/gsignond-plugin-interface.h"
+
+G_DEFINE_INTERFACE (GSignondPlugin, gsignond_plugin, 0)
+
+/* signals */
+enum
+{
+    RESULT,
+    STORE,
+    ERROR,
+    USER_ACTION_REQUIRED,
+    REFRESHED,
+    STATUS_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void gsignond_plugin_default_init (GSignondPluginInterface *g_class)
+{
+    signals[RESULT] = g_signal_new ("result", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        1, G_TYPE_VARIANT);
+
+    signals[STORE] = g_signal_new ("store", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        1, G_TYPE_VARIANT);
+
+    signals[ERROR] = g_signal_new ("error", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        1, G_TYPE_INT);
+    
+    signals[USER_ACTION_REQUIRED] = g_signal_new ("user-action-required", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        1, G_TYPE_VARIANT);
+
+    signals[REFRESHED] = g_signal_new ("refreshed", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        1, G_TYPE_VARIANT);
+
+    signals[STATUS_CHANGED] = g_signal_new ("status-changed", G_TYPE_FROM_CLASS (g_class),
+        G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
+        2, G_TYPE_STRING, G_TYPE_STRING);
+
+    g_object_interface_install_property (g_class,
+       g_param_spec_string ("type", "Type", "Plugin type", "none", G_PARAM_READABLE));
+
+     g_object_interface_install_property (g_class,
+        g_param_spec_boxed ("mechanisms", "Mechanisms", "List of plugin mechanisms", G_TYPE_STRV, G_PARAM_READABLE));
+    
+}
+
+void gsignond_plugin_cancel (GSignondPlugin *self)
+{
+    g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
+    
+    GSIGNOND_PLUGIN_GET_INTERFACE (self)->cancel (self);
+}
+
+void gsignond_plugin_abort (GSignondPlugin *self)
+{
+    g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
+    
+    GSIGNOND_PLUGIN_GET_INTERFACE (self)->abort (self);
+}
+
+void gsignond_plugin_process (GSignondPlugin *self, const GVariant *session_data, const gchar *mechanism)
+{
+    g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
+    
+    GSIGNOND_PLUGIN_GET_INTERFACE (self)->process (self, session_data, mechanism);
+}
+
+void gsignond_plugin_user_action_finished (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
+    
+    GSIGNOND_PLUGIN_GET_INTERFACE (self)->user_action_finished (self, session_data);
+}
+
+void gsignond_plugin_refresh (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
+    
+    GSIGNOND_PLUGIN_GET_INTERFACE (self)->refresh (self, session_data);
+}
+
+void gsignond_plugin_result (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_signal_emit (self, signals[RESULT], 0, session_data);
+}
+
+void gsignond_plugin_store (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_signal_emit (self, signals[STORE], 0, session_data);
+}
+
+void gsignond_plugin_error (GSignondPlugin *self, int error)
+{
+    g_signal_emit (self, signals[ERROR], 0, error);
+}
+
+void gsignond_plugin_user_action_required (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_signal_emit (self, signals[USER_ACTION_REQUIRED], 0, session_data);
+}
+
+void gsignond_plugin_refreshed (GSignondPlugin *self, const GVariant *session_data)
+{
+    g_signal_emit (self, signals[REFRESHED], 0, session_data);
+}
+
+void gsignond_plugin_status_changed (GSignondPlugin *self, const gchar *status, const gchar *message)
+{
+    g_signal_emit (self, signals[STATUS_CHANGED], 0, status, message);
+}
+
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
new file mode 100644 (file)
index 0000000..4760ee2
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS=password
diff --git a/src/plugins/password/Makefile.am b/src/plugins/password/Makefile.am
new file mode 100644 (file)
index 0000000..ac6c157
--- /dev/null
@@ -0,0 +1,19 @@
+lib_LTLIBRARIES = libpasswordplugin.la
+NULL=
+
+libpasswordplugin_la_CPPFLAGS = \
+    -I$(top_srcdir) \
+    -I$(top_srcdir)/src \
+    -I$(top_srcdir)/include \
+    $(GSIGNOND_CFLAGS) \
+    $(NULL)
+
+libpasswordplugin_la_LIBS = \
+    $(GSIGNOND_LIBS)
+    $(NULL)
+
+libpasswordplugin_la_SOURCES = \
+    gsignond-password-plugin.c \
+    $(NULL)
+
+CLEANFILES = 
diff --git a/src/plugins/password/gsignond-password-plugin.c b/src/plugins/password/gsignond-password-plugin.c
new file mode 100644 (file)
index 0000000..0483e8a
--- /dev/null
@@ -0,0 +1,134 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <gsignond/gsignond-plugin-interface.h>
+#include "gsignond-password-plugin.h"
+
+static void gsignond_plugin_interface_init (GSignondPluginInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GSignondPasswordPlugin, gsignond_password_plugin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (GSIGNOND_TYPE_PLUGIN,
+                                                gsignond_plugin_interface_init));
+
+static void gsignond_password_plugin_cancel (GSignondPlugin *self)
+{
+//  g_print ("Baz implementation of Ibaz interface Action: 0x%x.\n",
+//           self->instance_member);
+}
+
+static void gsignond_password_plugin_abort (GSignondPlugin *self)
+{
+    
+}
+
+static void gsignond_password_plugin_process (GSignondPlugin *self, const GVariant *session_data, const gchar *mechanism)
+{
+    
+}
+
+static void gsignond_password_plugin_user_action_finished (GSignondPlugin *self, const GVariant *session_data)
+{
+    
+}
+
+static void gsignond_password_plugin_refresh (GSignondPlugin *self, const GVariant *session_data)
+{
+    
+}
+
+static void
+gsignond_plugin_interface_init (GSignondPluginInterface *iface)
+{
+    iface->cancel = gsignond_password_plugin_cancel;
+    iface->abort = gsignond_password_plugin_abort;
+    iface->process = gsignond_password_plugin_process;
+    iface->user_action_finished = gsignond_password_plugin_user_action_finished;
+    iface->refresh = gsignond_password_plugin_refresh;
+}
+
+static void
+gsignond_password_plugin_init (GSignondPasswordPlugin *self)
+{
+    
+    
+}
+
+enum
+{
+    PROP_0,
+    
+    PROP_TYPE,
+    PROP_MECHANISMS
+};
+
+static void
+gsignond_password_plugin_set_property (GObject      *object,
+                                      guint         property_id,
+                                      const GValue *value,
+                                      GParamSpec   *pspec)
+{
+    switch (property_id)
+    {
+       default:
+           G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+           break;
+    }
+}
+
+static void
+gsignond_password_plugin_get_property (GObject    *object,
+                                      guint       prop_id,
+                                      GValue     *value,
+                                      GParamSpec *pspec)
+{
+    GSignondPasswordPlugin *password_plugin = GSIGNOND_PASSWORD_PLUGIN (object);
+    gchar *mechanisms[] = { "password", NULL };
+    
+    switch (prop_id)
+    {
+       case PROP_TYPE:
+           g_value_set_string (value, "password");
+           break;
+       case PROP_MECHANISMS:
+           g_value_set_boxed (value, mechanisms);
+           break;
+           
+       default:
+           G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+           break;
+    }
+}
+
+static void
+gsignond_password_plugin_class_init (GSignondPasswordPluginClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+    
+    gobject_class->set_property = gsignond_password_plugin_set_property;
+    gobject_class->get_property = gsignond_password_plugin_get_property;
+    
+    g_object_class_override_property (gobject_class, PROP_TYPE, "type");
+    g_object_class_override_property (gobject_class, PROP_MECHANISMS, "mechanisms");
+}
\ No newline at end of file
diff --git a/src/plugins/password/gsignond-password-plugin.h b/src/plugins/password/gsignond-password-plugin.h
new file mode 100644 (file)
index 0000000..6235290
--- /dev/null
@@ -0,0 +1,56 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_PASSWORD_PLUGIN_H__
+#define __GSIGNOND_PASSWORD_PLUGIN_H__
+
+#include <glib-object.h>
+
+#define GSIGNOND_TYPE_PASSWORD_PLUGIN             (gsignond_password_plugin_get_type ())
+#define GSIGNOND_PASSWORD_PLUGIN(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPlugin))
+#define GSIGNOND_IS_PASSWORD_PLUGIN(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN))
+#define GSIGNOND_PASSWORD_PLUGIN_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPluginClass))
+#define GSIGNOND_IS_PASSWORD_PLUGIN_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GSIGNOND_TYPE_PASSWORD_PLUGIN))
+#define GSIGNOND_PASSWORD_PLUGIN_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPluginClass))
+
+
+typedef struct _GSignondPasswordPlugin        GSignondPasswordPlugin;
+typedef struct _GSignondPasswordPluginClass   GSignondPasswordPluginClass;
+
+struct _GSignondPasswordPlugin
+{
+    GObject parent_instance;
+    
+    int instance_member;
+};
+
+struct _GSignondPasswordPluginClass
+{
+    GObjectClass parent_class;
+};
+
+GType gsignond_password_plugin_get_type (void);
+
+#endif /* __GSIGNOND_PASSWORD_PLUGIN_H__ */
\ No newline at end of file