[krb5-auth-dialog] Add dummy plugin



commit b2956aa5a9a2e7de4fe9844cba54427f2d53de4c
Author: Guido Günther <agx sigxcpu org>
Date:   Tue Apr 20 22:23:30 2010 +0200

    Add dummy plugin
    
    as example for new plugins.

 Makefile.am               |    2 +-
 configure.ac              |    1 +
 plugins/.gitignore        |    3 +
 plugins/Makefile.am       |   23 ++++++++++
 plugins/ka-plugin-dummy.c |  105 +++++++++++++++++++++++++++++++++++++++++++++
 plugins/ka-plugin-dummy.h |   57 ++++++++++++++++++++++++
 6 files changed, 190 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c6adefb..6a9ff8b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 NULL = 
 
-SUBDIRS = secmem gtksecentry src po etpo icons preferences help examples
+SUBDIRS = secmem gtksecentry src po etpo icons preferences help examples plugins
 
 EXTRA_DIST = \
 	krb5-auth-dialog.spec \
diff --git a/configure.ac b/configure.ac
index bb41970..cf05c5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,7 @@ preferences/Makefile
 preferences/krb5-auth-dialog-preferences.1
 help/Makefile
 examples/Makefile
+plugins/Makefile
 ])
 
 AC_MSG_NOTICE([])
diff --git a/plugins/.gitignore b/plugins/.gitignore
new file mode 100644
index 0000000..e3c5a86
--- /dev/null
+++ b/plugins/.gitignore
@@ -0,0 +1,3 @@
+*.la
+*.lo
+.libs/
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
new file mode 100644
index 0000000..0b41e38
--- /dev/null
+++ b/plugins/Makefile.am
@@ -0,0 +1,23 @@
+NULL =
+
+pkglibdir = $(KA_PLUGINS_DIR)
+
+pkglib_LTLIBRARIES = \
+	libka-plugin-dummy.la \
+	$(NULL)
+
+# Dummy example plugin
+libka_plugin_dummy_la_SOURCES = \
+	ka-plugin-dummy.c \
+	ka-plugin-dummy.h \
+	$(NULL)
+
+libka_plugin_dummy_la_CPPFLAGS = \
+	$(GTK_CFLAGS)       \
+	-I$(top_srcdir)/src \
+	$(NULL)
+
+libka_plugin_dummy_la_LDFLAGS = \
+	-module \
+	-avoid-version \
+	$(NULL)
diff --git a/plugins/ka-plugin-dummy.c b/plugins/ka-plugin-dummy.c
new file mode 100644
index 0000000..6485c0d
--- /dev/null
+++ b/plugins/ka-plugin-dummy.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 Guido Guenther <agx sigxcpu org>
+ *
+ * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "ka-plugin-dummy.h"
+#include <gmodule.h>
+
+G_DEFINE_TYPE (KaPluginDummy, ka_plugin_dummy, KA_TYPE_PLUGIN)
+
+#define GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), KA_TYPE_PLUGIN_DUMMY, KaPluginDummyPrivate))
+
+int ka_plugin_major_version = KA_PLUGIN_MAJOR_VERSION;
+int ka_plugin_minor_version = KA_PLUGIN_MINOR_VERSION;
+
+G_MODULE_EXPORT KaPlugin*
+ka_plugin_create (void)
+{
+  return KA_PLUGIN (ka_plugin_dummy_new());
+}
+
+typedef struct _KaPluginDummyPrivate KaPluginDummyPrivate;
+
+struct _KaPluginDummyPrivate {
+    gulong handlers[3];
+};
+
+event_cb (gpointer* applet, gchar* princ, guint when, gpointer user_data)
+{
+  g_message("%s %s @%d", user_data, princ, when);
+}
+
+static void
+ka_plugin_dummy_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (ka_plugin_dummy_parent_class)->finalize (object);
+}
+
+static void
+ka_plugin_dummy_activate (KaPlugin *self, KaApplet* applet)
+{
+  KaPluginDummyPrivate *priv = GET_PRIVATE (self);
+
+  priv->handlers[0] = g_signal_connect (applet,
+                                        "krb-tgt-expired",
+                                        G_CALLBACK (event_cb),
+                                        "Expired");
+  priv->handlers[1] = g_signal_connect (applet,
+                                        "krb-tgt-acquired",
+                                        G_CALLBACK (event_cb),
+                                        "Acquired");
+  priv->handlers[2] = g_signal_connect (applet,
+                                        "krb-tgt-renewed",
+                                        G_CALLBACK (event_cb),
+                                        "Renewed");
+}
+
+static void
+ka_plugin_dummy_deactivate (KaPlugin *self, KaApplet* applet)
+{
+	int i;
+	KaPluginDummyPrivate *priv = GET_PRIVATE (self);
+
+	for (i = 0; i < G_N_ELEMENTS(priv->handlers); i++)
+		g_signal_handler_disconnect (applet, priv->handlers[i]);
+}
+
+static void
+ka_plugin_dummy_class_init (KaPluginDummyClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  KaPluginClass *plugin_class = KA_PLUGIN_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (KaPluginDummyPrivate));
+
+  plugin_class->activate = ka_plugin_dummy_activate;
+  plugin_class->deactivate = ka_plugin_dummy_deactivate;
+  object_class->finalize = ka_plugin_dummy_finalize;
+}
+
+static void
+ka_plugin_dummy_init (KaPluginDummy *self)
+{
+}
+
+KaPluginDummy*
+ka_plugin_dummy_new (void)
+{
+  return g_object_new (KA_TYPE_PLUGIN_DUMMY, KA_PLUGIN_PROP_NAME,
+                       "dummy", NULL);
+}
diff --git a/plugins/ka-plugin-dummy.h b/plugins/ka-plugin-dummy.h
new file mode 100644
index 0000000..311861a
--- /dev/null
+++ b/plugins/ka-plugin-dummy.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 Guido Guenther <agx sigxcpu org>
+ *
+ * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _KA_PLUGIN_DUMMY
+#define _KA_PLUGIN_DUMMY
+
+#include "ka-plugin.h"
+
+G_BEGIN_DECLS
+
+#define KA_TYPE_PLUGIN_DUMMY ka_plugin_dummy_get_type()
+
+#define KA_PLUGIN_DUMMY(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), KA_TYPE_PLUGIN_DUMMY, KaPluginDummy))
+
+#define KA_PLUGIN_DUMMY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), KA_TYPE_PLUGIN_DUMMY, KaPluginDummyClass))
+
+#define KA_IS_PLUGIN_DUMMY(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KA_TYPE_PLUGIN_DUMMY))
+
+#define KA_IS_PLUGIN_DUMMY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), KA_TYPE_PLUGIN_DUMMY))
+
+#define KA_PLUGIN_DUMMY_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), KA_TYPE_PLUGIN_DUMMY, KaPluginDummyClass))
+
+typedef struct {
+  KaPlugin parent;
+} KaPluginDummy;
+
+typedef struct {
+  KaPluginClass parent_class;
+} KaPluginDummyClass;
+
+GType ka_plugin_dummy_get_type (void);
+
+KaPluginDummy* ka_plugin_dummy_new (void);
+
+G_END_DECLS
+
+#endif /* _KA_PLUGIN_DUMMY */



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