1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of gsignond
6 * Copyright (C) 2012 Intel Corporation.
8 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 #include "gsignond/gsignond-log.h"
30 #include "gsignond-plugin-loader.h"
34 GSignondConfig* config,
37 gchar* plugin_filename = g_module_build_path (
38 gsignond_config_get_string (config,
39 GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type);
40 GSignondPlugin *plugin = gsignond_load_plugin_with_filename (plugin_type,
42 g_free(plugin_filename);
47 gsignond_load_plugin_with_filename(
49 gchar *plugin_filename)
51 DBG("Loading plugin %s", plugin_filename);
52 GModule* plugin_module = g_module_open (plugin_filename,
54 if (plugin_module == NULL) {
55 DBG("Plugin couldn't be opened: %s", g_module_error());
59 gchar* plugin_get_type = g_strdup_printf("gsignond_%s_plugin_get_type",
63 DBG("Resolving symbol %s", plugin_get_type);
64 gboolean symfound = g_module_symbol (plugin_module,
66 g_free(plugin_get_type);
68 DBG("Symbol couldn't be resolved");
69 g_module_close (plugin_module);
73 DBG("Creating plugin object");
74 GType (*plugin_get_type_f)(void) = p;
75 GSignondPlugin* plugin = g_object_new(plugin_get_type_f(), NULL);
77 DBG("Plugin couldn't be created");
78 g_module_close (plugin_module);
81 g_module_make_resident (plugin_module);