From 782c36c2ccf01dd0db6cbac8cc712cc316f23c90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 2 Jul 2011 07:15:22 -0500 Subject: Loading the modules and getting an object --- src/status-items.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/status-items.c') diff --git a/src/status-items.c b/src/status-items.c index 5e8a07c..eef240f 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -107,7 +107,7 @@ provider_directory_parse (gpointer directory) const gchar * name; while ((name = g_dir_read_name(dir)) != NULL) { - if (!g_str_has_suffix(name, ".so")) { + if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { continue; } @@ -137,10 +137,32 @@ load_status_provider (gpointer dir) module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); if (module == NULL) { g_warning("Unable to module for: %s", provider); - goto exit_final; + goto exit_module_fail; } /* Got it */ + GType (*type_func) (void); + if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) { + g_warning("Unable to find type symbol in: %s", provider); + goto exit_module_fail; + } + + GType provider_type = type_func(); + if (provider_type == 0) { + g_warning("Unable to create type from: %s", provider); + goto exit_module_fail; + } + + StatusProvider * sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL)); + if (sprovider == NULL) { + g_warning("Unable to build provider from: %s", provider); + goto exit_module_fail; + } + + + goto exit_final; + +exit_module_fail: g_module_close(module); exit_final: -- cgit v1.2.3