/* Free the plugin list */
for (iter = priv->plugins; iter; iter = g_slist_next (iter))
- g_module_close ((GModule*) iter->data);
+ g_object_unref ((GObject *) iter->data);
g_slist_free (priv->plugins);
priv->plugins = NULL;
ModestPluginFactory*
modest_plugin_factory_new (void)
{
- ModestPluginFactory *self;
- ModestPluginFactoryPrivate *priv;
-
- self = MODEST_PLUGIN_FACTORY (g_object_new (MODEST_TYPE_PLUGIN_FACTORY, NULL));
- priv = MODEST_PLUGIN_FACTORY_GET_PRIVATE(self);
-
-/* if (priv->plugins == NULL) { */
-/* g_critical ("%s, no mail plugins detected", __FUNCTION__); */
-/* g_object_unref (self); */
-/* self = NULL; */
-/* } */
- return self;
+ return MODEST_PLUGIN_FACTORY (g_object_new (MODEST_TYPE_PLUGIN_FACTORY, NULL));
}
void
-modest_plugin_factory_load_all (ModestPluginFactory *self)
+modest_plugin_factory_load_all (ModestPluginFactory *self)
{
ModestPluginFactoryPrivate *priv;
GError *error = NULL;
while ((dirent = g_dir_read_name (d))) {
if (g_str_has_suffix (dirent, PLUGIN_EXT)) {
gchar *plugin_file;
- ModestPlugin *plugin;
-
+ ModestPlugin *plugin = NULL;
+
plugin_file = g_build_filename (MODEST_MAILPLUGINDIR, dirent, NULL);
plugin = modest_plugin_factory_load (plugin_file);
g_free (plugin_file);
priv->plugins = g_slist_prepend (priv->plugins, plugin);
}
}
-
priv->plugins = g_slist_reverse (priv->plugins);
g_dir_close (d);
static ModestPlugin*
modest_plugin_factory_load (const gchar *file)
{
- ModestPlugin *plugin;
+ ModestPlugin *plugin = NULL;
GKeyFile *plugin_file = NULL;
gchar *plugin_name, *dir, *path;
GTypeModule *type_module;
g_key_file_free (plugin_file);
/* Build path to plugin */
- dir = g_path_get_dirname (file);
+ dir = g_path_get_dirname (file);
path = g_module_build_path (dir, plugin_name);
g_free (dir);
/* plugin = g_module_open (path, G_MODULE_BIND_LAZY); */
- g_message ("PLUGIN TYPE IS %d", (gint) modest_plugin_get_type ());
type_module = G_TYPE_MODULE (modest_module_new (path));
if (type_module) {
g_type_module_use (type_module);
plugin = MODEST_PLUGIN (modest_module_new_object (MODEST_MODULE (type_module)));
+ if (plugin)
+ g_debug ("Plugin %s API version %s", plugin_name, modest_plugin_get_api_version (plugin));
+ g_type_module_unuse (type_module);
}
g_free (path);
+ g_free (plugin_name);
return plugin;
error: