Real fix for Coverity 1372362.
[claws.git] / src / plugins / demo / demo.c
index 3f07060e71ad4806c9c41483993480349f91cbe1..751c33f1e36d1c7615eb864fda3e43f54c8984b5 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2012 the Claws Mail Team
  *
  * 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
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * 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.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
-#include "intl.h"
+#include <glib.h>
+#include <glib/gi18n.h>
+
+
+#include "version.h"
+#include "claws.h"
 #include "plugin.h"
 #include "utils.h"
 #include "hooks.h"
 #include "log.h"
 
+#define PLUGIN_NAME (_("Demo"))
+
 gboolean my_log_hook(gpointer source, gpointer data)
 {
        LogText *logtext = (LogText *)source;
 
-       printf("*** Demo Plugin log: %s\n", logtext->text);
+       g_print("*** Demo Plugin log: %s\n", logtext->text);
 
        return FALSE;
 }
@@ -36,38 +43,61 @@ static guint hook_id;
 
 gint plugin_init(gchar **error)
 {
+       if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
+                               VERSION_NUMERIC, PLUGIN_NAME, error))
+               return -1;
+
        hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
        if (hook_id == -1) {
-               *error = g_strdup("Failed to register log text hook");
+               *error = g_strdup(_("Failed to register log text hook"));
                return -1;
        }
 
-       printf("Demo plugin loaded\n");
+       g_print("Demo plugin loaded\n");
 
        return 0;
 }
 
-void plugin_done(void)
+gboolean plugin_done(void)
 {
        hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, hook_id);
 
-       printf("Demo plugin unloaded\n");
+       g_print("Demo plugin unloaded\n");
+       return TRUE;
 }
 
 const gchar *plugin_name(void)
 {
-       return _("Demo");
+       return PLUGIN_NAME;
 }
 
 const gchar *plugin_desc(void)
 {
-       return _("This Plugin is only a demo of how to write plugins for Sylpheed. "
+       return _("This Plugin is only a demo of how to write plugins for Claws Mail. "
                 "It installs a hook for new log output and writes it to stdout."
                 "\n\n"
-                "It is not really usefull");
+                "It is not really useful.");
 }
 
 const gchar *plugin_type(void)
 {
        return "Common";
 }
+
+const gchar *plugin_licence(void)
+{
+       return "GPL3+";
+}
+
+const gchar *plugin_version(void)
+{
+       return VERSION;
+}
+
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_OTHER, N_("Demo")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}