/soc/2015/igor.gajowiak/chatlog: 8c2f75f40304: Added an initial ...

Igor Gajowiak igor.gajowiak at gmail.com
Sun Aug 2 16:57:52 EDT 2015


Changeset: 8c2f75f40304f00549e60a6401fd40c808643706
Author:	 Igor Gajowiak <igor.gajowiak at gmail.com>
Date:	 2015-08-02 22:57 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/8c2f75f40304

Description:

Added an initial version of a legacy log plugin.

diffstat:

 libpurple/plugins/log/Makefile.am |   10 ++-
 libpurple/plugins/log/legacylog.c |  149 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+), 1 deletions(-)

diffs (181 lines):

diff --git a/libpurple/plugins/log/Makefile.am b/libpurple/plugins/log/Makefile.am
--- a/libpurple/plugins/log/Makefile.am
+++ b/libpurple/plugins/log/Makefile.am
@@ -4,6 +4,14 @@ CLEANFILES =
 
 plugindir = @PURPLE_PLUGINDIR@
 
+legacylog_la_CFLAGS  = $(AM_CPPFLAGS)
+legacylog_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
+legacylog_la_SOURCES = legacylog.c
+legacylog_la_LIBADD  = @PURPLE_LIBS@
+
+plugin_LTLIBRARIES = \
+	legacylog.la
+
 if ENABLE_LOG_SQLITE
 
 logsqlite_la_CFLAGS  = $(AM_CPPFLAGS) $(SQLITE3_CFLAGS)
@@ -17,7 +25,7 @@ if PLUGINS
 
 if ENABLE_LOG_SQLITE
 
-plugin_LTLIBRARIES = \
+plugin_LTLIBRARIES += \
 	logsqlite.la
 
 endif
diff --git a/libpurple/plugins/log/legacylog.c b/libpurple/plugins/log/legacylog.c
new file mode 100644
--- /dev/null
+++ b/libpurple/plugins/log/legacylog.c
@@ -0,0 +1,149 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include "debug.h"
+#include "purple.h"
+#include "utils.h"
+#include "version.h"
+
+#define LEGACYLOG_ID          "genericlog-legacylog"
+#define LEGACYLOG_NAME        "Legacy log"
+#define LEGACYLOG_DESCRIPTION "This plugin exports messages " \
+                              "from a legacy log."
+#define LEGACYLOG_AUTHORS \
+	{ "Igor Gajowiak <igor.gajowiak at gmail.com>", NULL }
+
+/**************************************************************************/
+/* PurpleGenericLog API implementation                                    */
+/**************************************************************************/
+
+static gboolean
+legacylog_activate(void) { return TRUE; }
+
+static void
+legacylog_deactivate(void) {}
+
+/**************************************************************************/
+/* GObject stuff                                                          */
+/**************************************************************************/
+
+#define PURPLE_TYPE_LEGACYLOG          (purple_legacylog_get_type())
+
+typedef struct _PurpleLegacyLog        PurpleLegacyLog;
+typedef struct _PurpleLegacyLogClass   PurpleLegacyLogClass;
+
+struct _PurpleLegacyLog
+{
+	/*< private >*/
+	PurpleGenericLog parent_instance;
+};
+
+struct _PurpleLegacyLogClass
+{
+	/*< private >*/
+	PurpleGenericLogClass parent_class;
+};
+
+static PurpleGenericLogClass *parent_class = NULL;
+static PurpleLegacyLog *legacylog_instance = NULL;
+
+static void
+purple_legacylog_finalize(GObject *obj)
+{
+	G_OBJECT_CLASS(parent_class)->finalize(obj);
+	parent_class = NULL;
+}
+
+static void
+purple_legacylog_class_init(PurpleLegacyLogClass *klass)
+{
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+	parent_class = g_type_class_peek_parent(klass);
+
+	obj_class->finalize = purple_legacylog_finalize;
+
+	klass->parent_class.activate = legacylog_activate;
+	klass->parent_class.deactivate = legacylog_deactivate;
+}
+
+static GType
+purple_legacylog_get_type(void)
+{
+	static GType type = 0;
+	if (G_UNLIKELY(type == 0)) {
+
+		static const GTypeInfo info = {
+			.class_size = sizeof(PurpleLegacyLogClass),
+			.class_init = (GClassInitFunc) purple_legacylog_class_init,
+			.instance_size = sizeof(PurpleLegacyLog)
+		};
+
+		type = g_type_register_static(PURPLE_TYPE_GENERICLOG,
+			"PurpleLegacyLog", &info, 0);
+	}
+
+	return type;
+}
+
+/**************************************************************************/
+/* Plugin definition                                                      */
+/**************************************************************************/
+
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = LEGACYLOG_AUTHORS;
+
+	return purple_plugin_info_new (
+		"id",           LEGACYLOG_ID,
+		"name",         LEGACYLOG_NAME,
+		"version",      DISPLAY_VERSION,
+		"category",     "Genericlog",
+		"summary",      "Simple log plugin",
+		"description",  LEGACYLOG_DESCRIPTION,
+		"authors",      authors,
+		"abi-version",  PURPLE_ABI_VERSION,
+		"flags",        PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
+		NULL
+	);
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
+{
+	legacylog_instance = g_object_new(PURPLE_TYPE_LEGACYLOG,
+		PURPLE_GENERICLOG_PROPERTY_ID, LEGACYLOG_ID,
+		PURPLE_GENERICLOG_PROPERTY_NAME, LEGACYLOG_NAME,
+		NULL);
+	purple_genericlog_register(PURPLE_GENERICLOG(legacylog_instance));
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	purple_genericlog_unregister(PURPLE_GENERICLOG(legacylog_instance));
+	g_object_unref(legacylog_instance);
+	legacylog_instance = NULL;
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(Simple_Log, plugin_query, plugin_load, plugin_unload);



More information about the Commits mailing list