summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2013-06-22 18:09:26 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2013-06-23 16:06:05 +0100
commitc48dfbe92fa02ecbdace6f7ad608d9ef7d87ec43 (patch)
tree76d2c20f1bc06976e20a3715ca1faabcba0e9bfd /plugins
parent0c8fadad44e3b4acc9a2086f59df9d653128dbd8 (diff)
console: split plugin into one file per class
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am9
-rw-r--r--plugins/console/debug.c36
-rw-r--r--plugins/console/debug.h28
-rw-r--r--plugins/console/plugin.c134
-rw-r--r--plugins/console/plugin.h51
-rw-r--r--plugins/console/sidecar.c (renamed from plugins/console.c)136
-rw-r--r--plugins/console/sidecar.h (renamed from plugins/console.h)34
7 files changed, 259 insertions, 169 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a51160472..159ecb141 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -62,8 +62,13 @@ libgateways_la_SOURCES = \
gateways.h
libconsole_la_SOURCES = \
- console.c \
- console.h
+ console/debug.c \
+ console/debug.h \
+ console/plugin.c \
+ console/plugin.h \
+ console/sidecar.c \
+ console/sidecar.h \
+ $(NULL)
AM_CFLAGS = $(ERROR_CFLAGS) \
-I $(top_srcdir) -I $(top_builddir) \
diff --git a/plugins/console/debug.c b/plugins/console/debug.c
new file mode 100644
index 000000000..29dcf161b
--- /dev/null
+++ b/plugins/console/debug.c
@@ -0,0 +1,36 @@
+/* XML console plugin
+ *
+ * Copyright © 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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 <glib.h>
+
+#include "console/debug.h"
+
+int debug = 0;
+
+static const GDebugKey debug_keys[] = {
+ { "console", 1 },
+ { NULL, 0 }
+};
+
+void
+gabble_console_debug_init (void)
+{
+ debug = g_parse_debug_string (g_getenv ("GABBLE_DEBUG"), debug_keys,
+ G_N_ELEMENTS (debug_keys) - 1);
+}
diff --git a/plugins/console/debug.h b/plugins/console/debug.h
new file mode 100644
index 000000000..78031722d
--- /dev/null
+++ b/plugins/console/debug.h
@@ -0,0 +1,28 @@
+/* XML console plugin
+ *
+ * Copyright © 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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
+ */
+
+extern int debug;
+
+#define DEBUG(format, ...) \
+G_STMT_START { \
+ if (debug != 0) \
+ g_debug ("%s: " format, G_STRFUNC, ## __VA_ARGS__); \
+} G_STMT_END
+
+void gabble_console_debug_init (void);
diff --git a/plugins/console/plugin.c b/plugins/console/plugin.c
new file mode 100644
index 000000000..d5f02157f
--- /dev/null
+++ b/plugins/console/plugin.c
@@ -0,0 +1,134 @@
+/* XML console plugin
+ *
+ * Copyright © 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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 "config.h"
+#include "console/plugin.h"
+
+#include <telepathy-glib/telepathy-glib.h>
+#include <wocky/wocky.h>
+#include <gabble/gabble.h>
+#include "extensions/extensions.h"
+
+#include "console/debug.h"
+#include "console/sidecar.h"
+
+static void plugin_iface_init (
+ gpointer g_iface,
+ gpointer data);
+
+static const gchar * const sidecar_interfaces[] = {
+ GABBLE_IFACE_GABBLE_PLUGIN_CONSOLE,
+ NULL
+};
+
+G_DEFINE_TYPE_WITH_CODE (GabbleConsolePlugin, gabble_console_plugin,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (GABBLE_TYPE_PLUGIN, plugin_iface_init);
+ )
+
+static void
+gabble_console_plugin_init (GabbleConsolePlugin *self)
+{
+}
+
+static void
+gabble_console_plugin_class_init (GabbleConsolePluginClass *klass)
+{
+}
+
+static void
+gabble_console_plugin_create_sidecar_async (
+ GabblePlugin *plugin,
+ const gchar *sidecar_interface,
+ GabblePluginConnection *connection,
+ WockySession *session,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
+ callback, user_data,
+ gabble_console_plugin_create_sidecar_async);
+ GabbleSidecar *sidecar = NULL;
+
+ if (!tp_strdiff (sidecar_interface, GABBLE_IFACE_GABBLE_PLUGIN_CONSOLE))
+ {
+ sidecar = g_object_new (GABBLE_TYPE_CONSOLE_SIDECAR,
+ "connection", connection,
+ "session", session,
+ NULL);
+ }
+ else
+ {
+ g_simple_async_result_set_error (result, TP_ERROR,
+ TP_ERROR_NOT_IMPLEMENTED, "'%s' not implemented", sidecar_interface);
+ }
+
+ if (sidecar != NULL)
+ g_simple_async_result_set_op_res_gpointer (result, sidecar,
+ g_object_unref);
+
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+}
+
+static GabbleSidecar *
+gabble_console_plugin_create_sidecar_finish (
+ GabblePlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ GabbleSidecar *sidecar;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error))
+ return NULL;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (plugin), gabble_console_plugin_create_sidecar_async), NULL);
+
+ sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result)));
+
+ return g_object_ref (sidecar);
+}
+
+static void
+plugin_iface_init (
+ gpointer g_iface,
+ gpointer data G_GNUC_UNUSED)
+{
+ GabblePluginInterface *iface = g_iface;
+
+ iface->name = "XMPP console";
+ iface->version = PACKAGE_VERSION;
+ iface->sidecar_interfaces = sidecar_interfaces;
+ iface->create_sidecar_async = gabble_console_plugin_create_sidecar_async;
+ iface->create_sidecar_finish = gabble_console_plugin_create_sidecar_finish;
+}
+
+GabblePlugin *
+gabble_plugin_create (void)
+{
+ gabble_console_debug_init ();
+
+ DEBUG ("loaded");
+
+ return g_object_new (GABBLE_TYPE_CONSOLE_PLUGIN,
+ NULL);
+}
diff --git a/plugins/console/plugin.h b/plugins/console/plugin.h
new file mode 100644
index 000000000..153484f91
--- /dev/null
+++ b/plugins/console/plugin.h
@@ -0,0 +1,51 @@
+/* XML console plugin
+ *
+ * Copyright © 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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 <glib-object.h>
+
+typedef struct _GabbleConsolePlugin GabbleConsolePlugin;
+typedef struct _GabbleConsolePluginClass GabbleConsolePluginClass;
+typedef struct _GabbleConsolePluginPrivate GabbleConsolePluginPrivate;
+
+struct _GabbleConsolePlugin {
+ GObject parent;
+ GabbleConsolePluginPrivate *priv;
+};
+
+struct _GabbleConsolePluginClass {
+ GObjectClass parent;
+};
+
+GType gabble_console_plugin_get_type (void);
+
+#define GABBLE_TYPE_CONSOLE_PLUGIN \
+ (gabble_console_plugin_get_type ())
+#define GABBLE_CONSOLE_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GABBLE_TYPE_CONSOLE_PLUGIN, \
+ GabbleConsolePlugin))
+#define GABBLE_CONSOLE_PLUGIN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), GABBLE_TYPE_CONSOLE_PLUGIN, \
+ GabbleConsolePluginClass))
+#define GABBLE_IS_CONSOLE_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GABBLE_TYPE_CONSOLE_PLUGIN))
+#define GABBLE_IS_CONSOLE_PLUGIN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), GABBLE_TYPE_CONSOLE_PLUGIN))
+#define GABBLE_CONSOLE_PLUGIN_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_CONSOLE_PLUGIN, \
+ GabbleConsolePluginClass))
diff --git a/plugins/console.c b/plugins/console/sidecar.c
index fd49d0bd8..1e01234cd 100644
--- a/plugins/console.c
+++ b/plugins/console/sidecar.c
@@ -18,144 +18,14 @@
*/
#include "config.h"
-
-#include "console.h"
+#include "console/sidecar.h"
#include <string.h>
-
-#include <telepathy-glib/telepathy-glib.h>
-
#include <wocky/wocky.h>
-
-#include "extensions/extensions.h"
-
#include <gabble/gabble.h>
+#include "extensions/extensions.h"
-/*************************
- * Plugin implementation *
- *************************/
-
-static guint debug = 0;
-
-#define DEBUG(format, ...) \
-G_STMT_START { \
- if (debug != 0) \
- g_debug ("%s: " format, G_STRFUNC, ## __VA_ARGS__); \
-} G_STMT_END
-
-static const GDebugKey debug_keys[] = {
- { "console", 1 },
- { NULL, 0 }
-};
-
-static void plugin_iface_init (
- gpointer g_iface,
- gpointer data);
-
-static const gchar * const sidecar_interfaces[] = {
- GABBLE_IFACE_GABBLE_PLUGIN_CONSOLE,
- NULL
-};
-
-G_DEFINE_TYPE_WITH_CODE (GabbleConsolePlugin, gabble_console_plugin,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (GABBLE_TYPE_PLUGIN, plugin_iface_init);
- )
-
-static void
-gabble_console_plugin_init (GabbleConsolePlugin *self)
-{
-}
-
-static void
-gabble_console_plugin_class_init (GabbleConsolePluginClass *klass)
-{
-}
-
-static void
-gabble_console_plugin_create_sidecar_async (
- GabblePlugin *plugin,
- const gchar *sidecar_interface,
- GabblePluginConnection *connection,
- WockySession *session,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
- callback, user_data,
- gabble_console_plugin_create_sidecar_async);
- GabbleSidecar *sidecar = NULL;
-
- if (!tp_strdiff (sidecar_interface, GABBLE_IFACE_GABBLE_PLUGIN_CONSOLE))
- {
- sidecar = g_object_new (GABBLE_TYPE_CONSOLE_SIDECAR,
- "connection", connection,
- "session", session,
- NULL);
- }
- else
- {
- g_simple_async_result_set_error (result, TP_ERROR,
- TP_ERROR_NOT_IMPLEMENTED, "'%s' not implemented", sidecar_interface);
- }
-
- if (sidecar != NULL)
- g_simple_async_result_set_op_res_gpointer (result, sidecar,
- g_object_unref);
-
- g_simple_async_result_complete_in_idle (result);
- g_object_unref (result);
-}
-
-static GabbleSidecar *
-gabble_console_plugin_create_sidecar_finish (
- GabblePlugin *plugin,
- GAsyncResult *result,
- GError **error)
-{
- GabbleSidecar *sidecar;
-
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return NULL;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (plugin), gabble_console_plugin_create_sidecar_async), NULL);
-
- sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result)));
-
- return g_object_ref (sidecar);
-}
-
-static void
-plugin_iface_init (
- gpointer g_iface,
- gpointer data G_GNUC_UNUSED)
-{
- GabblePluginInterface *iface = g_iface;
-
- iface->name = "XMPP console";
- iface->version = PACKAGE_VERSION;
- iface->sidecar_interfaces = sidecar_interfaces;
- iface->create_sidecar_async = gabble_console_plugin_create_sidecar_async;
- iface->create_sidecar_finish = gabble_console_plugin_create_sidecar_finish;
-}
-
-GabblePlugin *
-gabble_plugin_create (void)
-{
- debug = g_parse_debug_string (g_getenv ("GABBLE_DEBUG"), debug_keys,
- G_N_ELEMENTS (debug_keys) - 1);
- DEBUG ("loaded");
-
- return g_object_new (GABBLE_TYPE_CONSOLE_PLUGIN,
- NULL);
-}
-
-/**************************
- * Sidecar implementation *
- **************************/
+#include "console/debug.h"
enum {
PROP_0,
diff --git a/plugins/console.h b/plugins/console/sidecar.h
index e646d067e..b31b2071b 100644
--- a/plugins/console.h
+++ b/plugins/console/sidecar.h
@@ -18,42 +18,8 @@
*/
#include <glib-object.h>
-
-#include <gio/gio.h>
-#include <wocky/wocky.h>
#include <telepathy-glib/telepathy-glib.h>
-typedef struct _GabbleConsolePlugin GabbleConsolePlugin;
-typedef struct _GabbleConsolePluginClass GabbleConsolePluginClass;
-typedef struct _GabbleConsolePluginPrivate GabbleConsolePluginPrivate;
-
-struct _GabbleConsolePlugin {
- GObject parent;
- GabbleConsolePluginPrivate *priv;
-};
-
-struct _GabbleConsolePluginClass {
- GObjectClass parent;
-};
-
-GType gabble_console_plugin_get_type (void);
-
-#define GABBLE_TYPE_CONSOLE_PLUGIN \
- (gabble_console_plugin_get_type ())
-#define GABBLE_CONSOLE_PLUGIN(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), GABBLE_TYPE_CONSOLE_PLUGIN, \
- GabbleConsolePlugin))
-#define GABBLE_CONSOLE_PLUGIN_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), GABBLE_TYPE_CONSOLE_PLUGIN, \
- GabbleConsolePluginClass))
-#define GABBLE_IS_CONSOLE_PLUGIN(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GABBLE_TYPE_CONSOLE_PLUGIN))
-#define GABBLE_IS_CONSOLE_PLUGIN_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), GABBLE_TYPE_CONSOLE_PLUGIN))
-#define GABBLE_CONSOLE_PLUGIN_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_CONSOLE_PLUGIN, \
- GabbleConsolePluginClass))
-
typedef struct _GabbleConsoleSidecar GabbleConsoleSidecar;
typedef struct _GabbleConsoleSidecarClass GabbleConsoleSidecarClass;
typedef struct _GabbleConsoleSidecarPrivate GabbleConsoleSidecarPrivate;