[telepathy-gabble/master] Add a trivial GabblePlugin interface

Will Thompson will.thompson at collabora.co.uk
Fri Nov 13 10:34:54 PST 2009


---
 src/Makefile.am |    2 +
 src/plugin.c    |   61 ++++++++++++++++++++++++++++++++++++++++++++++
 src/plugin.h    |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+), 0 deletions(-)
 create mode 100644 src/plugin.c
 create mode 100644 src/plugin.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 578c853..1e86681 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -104,6 +104,8 @@ libgabble_convenience_la_SOURCES = \
     olpc-view.c \
     plugin-loader.h \
     plugin-loader.c \
+    plugin.h \
+    plugin.c \
     presence.h \
     presence.c \
     presence-cache.h \
diff --git a/src/plugin.c b/src/plugin.c
new file mode 100644
index 0000000..5357cff
--- /dev/null
+++ b/src/plugin.c
@@ -0,0 +1,61 @@
+/*
+ * plugin.c — API for telepathy-gabble plugins
+ * Copyright © 2009 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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 "plugin.h"
+
+GType
+gabble_plugin_get_type (void)
+{
+  static GType type = 0;
+
+  if (type == 0) {
+    static const GTypeInfo info = {
+      sizeof (GabblePluginInterface),
+      NULL,   /* base_init */
+      NULL,   /* base_finalize */
+      NULL,   /* class_init */
+      NULL,   /* class_finalize */
+      NULL,   /* class_data */
+      0,
+      0,      /* n_preallocs */
+      NULL    /* instance_init */
+    };
+
+    type = g_type_register_static (G_TYPE_INTERFACE, "GabblePlugin", &info, 0);
+  }
+
+  return type;
+}
+
+const gchar *
+gabble_plugin_get_name (GabblePlugin *plugin)
+{
+  GabblePluginInterface *iface = GABBLE_PLUGIN_GET_INTERFACE (plugin);
+
+  return iface->name;
+}
+
+const gchar * const *
+gabble_plugin_get_sidecar_interfaces (GabblePlugin *plugin)
+{
+  GabblePluginInterface *iface = GABBLE_PLUGIN_GET_INTERFACE (plugin);
+
+  return iface->sidecar_interfaces;
+}
diff --git a/src/plugin.h b/src/plugin.h
new file mode 100644
index 0000000..3200f23
--- /dev/null
+++ b/src/plugin.h
@@ -0,0 +1,72 @@
+/*
+ * plugin.h — API for telepathy-gabble plugins
+ * Copyright © 2009 Collabora Ltd.
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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 __PLUGIN_H__
+#define __PLUGIN_H__
+
+#include <glib-object.h>
+
+#include <gio/gio.h>
+
+#define GABBLE_TYPE_PLUGIN (gabble_plugin_get_type ())
+#define GABBLE_PLUGIN(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GABBLE_TYPE_PLUGIN, GabblePlugin))
+#define GABBLE_IS_PLUGIN(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GABBLE_TYPE_PLUGIN))
+#define GABBLE_PLUGIN_GET_INTERFACE(obj) \
+    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GABBLE_TYPE_PLUGIN, \
+        GabblePluginInterface))
+
+typedef struct _GabblePlugin GabblePlugin;
+typedef struct _GabblePluginInterface GabblePluginInterface;
+
+struct _GabblePluginInterface {
+    GTypeInterface parent;
+
+    /**
+     * An arbitrary human-readable name identifying this plugin.
+     */
+    const gchar *name;
+
+    /**
+     * A %NULL-terminated array of strings listing the sidecar D-Bus interfaces
+     * implemented by this plugin.
+     */
+    const gchar * const *sidecar_interfaces;
+};
+
+GType gabble_plugin_get_type (void);
+
+const gchar *gabble_plugin_get_name (
+    GabblePlugin *plugin);
+const gchar * const *gabble_plugin_get_sidecar_interfaces (
+    GabblePlugin *plugin);
+
+/**
+ * gabble_plugin_create:
+ *
+ * Prototype for the plugin entry point.
+ *
+ * Returns: a new instance of this plugin, which must not be %NULL.
+ */
+GabblePlugin *gabble_plugin_create (void);
+
+typedef GabblePlugin *(*GabblePluginCreateImpl) (void);
+
+#endif
-- 
1.5.6.5




More information about the telepathy-commits mailing list