2010-03-01 [iwkse] 3.7.5cvs29
[claws.git] / src / common / plugin.c
index f1054817c89f60849b0266897644b8959a5f2c3e..34981cda09aec0879157ec497a8c7574cd1adda5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto and 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
@@ -89,9 +89,9 @@ static gint list_find_by_plugin_filename(const Plugin *plugin, const gchar *file
           different directory.  I think it would be better to compare
           only the basename of the filename here (case-insensitive on
           W32). */
-       g_return_val_if_fail(plugin, 1);
-       g_return_val_if_fail(plugin->filename, 1);
-       g_return_val_if_fail(filename, 1);
+       cm_return_val_if_fail(plugin, 1);
+       cm_return_val_if_fail(plugin->filename, 1);
+       cm_return_val_if_fail(filename, 1);
        return strcmp(filename, plugin->filename);
 }
 
@@ -214,6 +214,7 @@ static gint plugin_load_deps(const gchar *filename, gchar **error)
                        dep_plugin = plugin_load(path, error);
                        if (dep_plugin == NULL) {
                                g_free(path);
+                               fclose(fp);
                                return -1;
                        }
                }
@@ -310,8 +311,8 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
        struct PluginFeature *(*plugin_provides)(void);
        gint ok;
        START_TIMING((filename?filename:"NULL plugin"));
-       g_return_val_if_fail(filename != NULL, NULL);
-       g_return_val_if_fail(error != NULL, NULL);
+       cm_return_val_if_fail(filename != NULL, NULL);
+       cm_return_val_if_fail(error != NULL, NULL);
 
        /* check duplicate plugin path name */
        if (plugin_is_loaded(filename)) {
@@ -361,7 +362,7 @@ init_plugin:
        
        if (strcmp(plugin_licence(), "GPL2+") && strncmp(plugin_licence(), "GPL3", strlen("GPL3"))
        &&  strncmp(plugin_licence(), "GPL2+-compatible", strlen("GPL2+-compatible"))) {
-               *error = g_strdup(_("This module is not licenced under a GPL v2 or later compatible licence."));
+               *error = g_strdup(_("This module is not licensed under a GPL v2 or later compatible license."));
                if (plugin->unloaded_hidden)
                        return NULL;
                g_module_close(plugin->module);
@@ -463,6 +464,8 @@ void plugin_load_all(const gchar *type)
        if ((pfile = prefs_read_open(rcpath)) == NULL ||
            (prefs_set_block_label(pfile, block) < 0)) {
                g_free(rcpath);
+               if (pfile)
+                       prefs_file_close(pfile);
                return;
        }
        g_free(block);
@@ -563,6 +566,22 @@ GSList *plugin_get_list(void)
        return new;
 }
 
+Plugin *plugin_get_loaded_by_name(const gchar *name) 
+{
+       Plugin *plugin = NULL;
+       GSList *new, *cur; 
+       new = plugin_get_list();
+       for (cur = new; cur; cur = g_slist_next(cur)) {
+               plugin = (Plugin *)cur->data;
+               if (!g_ascii_strcasecmp(plugin->name(), name)) 
+                       break;
+               else 
+                       plugin = NULL;
+       }
+       g_slist_free(new);
+       return plugin;
+}
+
 GSList *plugin_get_unloaded_list(void)
 {
        return g_slist_copy(unloaded_plugins);