aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-07-02 07:15:22 -0500
committerTed Gould <ted@gould.cx>2011-07-02 07:15:22 -0500
commit782c36c2ccf01dd0db6cbac8cc712cc316f23c90 (patch)
tree668a107a7dbd60a10546134d287a1993a19c81af /src
parentd936a27b56706eb521f525970dedb63fe24c81bd (diff)
downloadayatana-indicator-messages-782c36c2ccf01dd0db6cbac8cc712cc316f23c90.tar.gz
ayatana-indicator-messages-782c36c2ccf01dd0db6cbac8cc712cc316f23c90.tar.bz2
ayatana-indicator-messages-782c36c2ccf01dd0db6cbac8cc712cc316f23c90.zip
Loading the modules and getting an object
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/status-items.c26
-rw-r--r--src/status-provider-emesene.c2
-rw-r--r--src/status-provider-mc5.c2
-rw-r--r--src/status-provider-pidgin.c2
-rw-r--r--src/status-provider-telepathy.c2
-rw-r--r--src/status-provider.h3
7 files changed, 36 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index de4fccb..87f3c67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,7 +55,7 @@ indicator_messages_service_SOURCES = \
dbus-data.h \
\
status-items.c \
- status-items.h
+ status-items.h \
status-provider.c \
status-provider.h
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:
diff --git a/src/status-provider-emesene.c b/src/status-provider-emesene.c
index ab75f68..29a8a22 100644
--- a/src/status-provider-emesene.c
+++ b/src/status-provider-emesene.c
@@ -78,6 +78,8 @@ static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar
G_DEFINE_TYPE (StatusProviderEmesene, status_provider_emesene, STATUS_PROVIDER_TYPE);
+STATUS_PROVIDER_EXPORT_TYPE(STATUS_PROVIDER_EMESENE_TYPE)
+
static void
status_provider_emesene_class_init (StatusProviderEmeseneClass *klass)
{
diff --git a/src/status-provider-mc5.c b/src/status-provider-mc5.c
index 468c6e8..e70496c 100644
--- a/src/status-provider-mc5.c
+++ b/src/status-provider-mc5.c
@@ -89,6 +89,8 @@ static void mc5_exists_cb (DBusGProxy * proxy, gboolean exists, GError * error,
G_DEFINE_TYPE (StatusProviderMC5, status_provider_mc5, STATUS_PROVIDER_TYPE);
+STATUS_PROVIDER_EXPORT_TYPE(STATUS_PROVIDER_MC5_TYPE)
+
/* Create the class. We over ride a few functions but nothing
really shocking. Most interesting is the set and get status. */
static void
diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c
index 3c0ca15..6c73d56 100644
--- a/src/status-provider-pidgin.c
+++ b/src/status-provider-pidgin.c
@@ -87,6 +87,8 @@ static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar
G_DEFINE_TYPE (StatusProviderPidgin, status_provider_pidgin, STATUS_PROVIDER_TYPE);
+STATUS_PROVIDER_EXPORT_TYPE(STATUS_PROVIDER_PIDGIN_TYPE)
+
static void
status_provider_pidgin_class_init (StatusProviderPidginClass *klass)
{
diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c
index f2815fb..c8e89da 100644
--- a/src/status-provider-telepathy.c
+++ b/src/status-provider-telepathy.c
@@ -86,6 +86,8 @@ static void get_status_async (DBusGProxy * proxy, DBusGProxyCall * call, gpointe
G_DEFINE_TYPE (StatusProviderTelepathy, status_provider_telepathy, STATUS_PROVIDER_TYPE);
+STATUS_PROVIDER_EXPORT_TYPE(STATUS_PROVIDER_TELEPATHY_TYPE)
+
static void
status_provider_telepathy_class_init (StatusProviderTelepathyClass *klass)
{
diff --git a/src/status-provider.h b/src/status-provider.h
index a0e1c55..45433fc 100644
--- a/src/status-provider.h
+++ b/src/status-provider.h
@@ -28,6 +28,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
G_BEGIN_DECLS
+#define STATUS_PROVIDER_EXPORT_TYPE(x) GType status_provider_export_type (void) { return (x); }
+#define STATUS_PROVIDER_EXPORT_S "status_provider_export_type"
+
#define STATUS_PROVIDER_TYPE (status_provider_get_type ())
#define STATUS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_TYPE, StatusProvider))
#define STATUS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_TYPE, StatusProviderClass))