aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-09-16 11:56:23 +0300
committerGergely Risko <gergely+context@risko.hu>2009-09-16 11:56:23 +0300
commit34f6c51234261a8c88b56d99c07e18fa75b47764 (patch)
tree964076d12838f58332c4be8b04a3f0f4e8edf016
parent1c3c8b563759d2ef2761124651e2a7979c619a25 (diff)
libcontextsubscriber/src/provider.cpp: make the elseif block more like a switch
-rw-r--r--libcontextsubscriber/src/provider.cpp54
1 files changed, 25 insertions, 29 deletions
diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp
index 2f8e008f..aa110a08 100644
--- a/libcontextsubscriber/src/provider.cpp
+++ b/libcontextsubscriber/src/provider.cpp
@@ -115,43 +115,39 @@ void Provider::constructPlugin()
if (pluginName == "contextkit-dbus") {
plugin = contextKitPluginFactory(constructionString);
}
- else {
- // Require the plugin name to start with /
- if (pluginName.startsWith("/")) {
-
- // Enable overriding the plugin location with an environment variable
- const char *pluginPath = getenv("CONTEXT_SUBSCRIBER_PLUGINS");
- if (! pluginPath)
- pluginPath = DEFAULT_CONTEXT_SUBSCRIBER_PLUGINS;
-
- QString pluginFilename(pluginPath);
- // Allow pluginPath to have a trailing / or not
- if (pluginFilename.endsWith("/")) {
- pluginFilename.chop(1);
- }
+ else if (pluginName.startsWith("/")) { // Require the plugin name to start with /
+ // Enable overriding the plugin location with an environment variable
+ const char *pluginPath = getenv("CONTEXT_SUBSCRIBER_PLUGINS");
+ if (! pluginPath)
+ pluginPath = DEFAULT_CONTEXT_SUBSCRIBER_PLUGINS;
+
+ QString pluginFilename(pluginPath);
+ // Allow pluginPath to have a trailing / or not
+ if (pluginFilename.endsWith("/")) {
+ pluginFilename.chop(1);
+ }
- pluginFilename.append(pluginName);
+ pluginFilename.append(pluginName);
- QLibrary library(pluginFilename);
- library.load();
+ QLibrary library(pluginFilename);
+ library.load();
- if (library.isLoaded()) {
- PluginFactoryFunc factory = (PluginFactoryFunc) library.resolve("pluginFactory");
- if (factory) {
- contextDebug() << "Resolved factory function";
- plugin = factory(constructionString);
- } else {
- contextCritical() << "Error resolving function pluginFactory from plugin" << pluginFilename;
- }
- }
- else {
- contextCritical() << "Error loading plugin" << pluginFilename << ":" << library.errorString();
+ if (library.isLoaded()) {
+ PluginFactoryFunc factory = (PluginFactoryFunc) library.resolve("pluginFactory");
+ if (factory) {
+ contextDebug() << "Resolved factory function";
+ plugin = factory(constructionString);
+ } else {
+ contextCritical() << "Error resolving function pluginFactory from plugin" << pluginFilename;
}
}
else {
- contextCritical() << "Illegal plugin name" << pluginName << ", doesn't start with /";
+ contextCritical() << "Error loading plugin" << pluginFilename << ":" << library.errorString();
}
}
+ else {
+ contextCritical() << "Illegal plugin name" << pluginName << ", doesn't start with /";
+ }
if (plugin == 0) {
pluginState = FAILED;