aboutsummaryrefslogtreecommitdiff
path: root/libcontextsubscriber
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-09-11 15:01:06 +0300
committerGergely Risko <gergely+context@risko.hu>2009-09-11 15:01:06 +0300
commit1e90445d3293699df4160d9d1820144422d795be (patch)
treef78a8a6300cd4330a5628c439906ed1538dcdb72 /libcontextsubscriber
parent9d7836875e96fd336d8f002ef2a6047701a3ea9e (diff)
Libcontextsubscriber/plugin loading review.
Diffstat (limited to 'libcontextsubscriber')
-rw-r--r--libcontextsubscriber/customer-tests/bluez-plugin/Makefile.am2
-rw-r--r--libcontextsubscriber/customer-tests/bluez-plugin2/bluez.context8
-rw-r--r--libcontextsubscriber/customer-tests/bluez-plugin2/test-bluez-plugin.py102
-rw-r--r--libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp11
-rw-r--r--libcontextsubscriber/customer-tests/testplugins/timeplugin.h7
-rw-r--r--libcontextsubscriber/src/Makefile.am2
-rw-r--r--libcontextsubscriber/src/iproviderplugin.h2
-rw-r--r--libcontextsubscriber/src/provider.cpp2
8 files changed, 66 insertions, 70 deletions
diff --git a/libcontextsubscriber/customer-tests/bluez-plugin/Makefile.am b/libcontextsubscriber/customer-tests/bluez-plugin/Makefile.am
index d0b2c85a..93d69310 100644
--- a/libcontextsubscriber/customer-tests/bluez-plugin/Makefile.am
+++ b/libcontextsubscriber/customer-tests/bluez-plugin/Makefile.am
@@ -22,4 +22,4 @@ include $(top_srcdir)/am/qt.am
# Running the customer test
check-customer:
- LD_LIBRARY_PATH=$(builddir)/../../plugins/bluez/.libs/ ./test-bluez-plugin \ No newline at end of file
+ LD_LIBRARY_PATH=$(builddir)/../../plugins/bluez/.libs/ ./test-bluez-plugin
diff --git a/libcontextsubscriber/customer-tests/bluez-plugin2/bluez.context b/libcontextsubscriber/customer-tests/bluez-plugin2/bluez.context
index 91e31e77..5472f1a7 100644
--- a/libcontextsubscriber/customer-tests/bluez-plugin2/bluez.context
+++ b/libcontextsubscriber/customer-tests/bluez-plugin2/bluez.context
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<provider
-xmlns="http://contextkit.freedesktop.org/Provider"
-plugin="libcontextsubscriberbluez" constructionString="bluez">
-<key name="Bluetooth.Enabled"> <type>TRUTH</type> </key>
-<key name="Bluetooth.Visible"> <type>TRUTH</type> </key>
+ xmlns="http://contextkit.freedesktop.org/Provider"
+ plugin="libcontextsubscriberbluez" constructionString="bluez">
+ <key name="Bluetooth.Enabled"> <type>TRUTH</type> </key>
+ <key name="Bluetooth.Visible"> <type>TRUTH</type> </key>
</provider>
diff --git a/libcontextsubscriber/customer-tests/bluez-plugin2/test-bluez-plugin.py b/libcontextsubscriber/customer-tests/bluez-plugin2/test-bluez-plugin.py
index e1d70bec..338124ea 100644
--- a/libcontextsubscriber/customer-tests/bluez-plugin2/test-bluez-plugin.py
+++ b/libcontextsubscriber/customer-tests/bluez-plugin2/test-bluez-plugin.py
@@ -33,78 +33,76 @@ import signal
from time import sleep
def proc_kill(pid):
- os.system('../common/rec-kill.sh %d' % pid)
+ os.system('../common/rec-kill.sh %d' % pid)
def timeoutHandler(signum, frame):
- raise Exception('Tests have been running for too long')
+ raise Exception('Tests have been running for too long')
def stdoutRead (object,lines):
- list = []
- for i in range(lines):
- list.append(object.stdout.readline().rstrip())
- return list
+ list = []
+ for i in range(lines):
+ list.append(object.stdout.readline().rstrip())
+ return list
def set_bluez_property(property, value):
- os.system('dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/`pidof bluetoothd`/hci0 org.bluez.Adapter.SetProperty string:%s variant:boolean:%s' % (property, value))
- time.sleep(1)
+ os.system('dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/`pidof bluetoothd`/hci0 org.bluez.Adapter.SetProperty string:%s variant:boolean:%s' % (property, value))
+ time.sleep(1)
class BluezPlugin(unittest.TestCase):
- def setUp(self):
- os.environ["CONTEXT_PROVIDERS"] = "."
+ def setUp(self):
+ os.environ["CONTEXT_PROVIDERS"] = "."
- # Make Bluetooth invisible and un-enabled
- # Note: This test will alter the bluetooth settings of the system!
+ # Make Bluetooth invisible and un-enabled
+ # Note: This test will alter the bluetooth settings of the system!
- set_bluez_property("Discoverable", "false")
- set_bluez_property("Powered", "false")
+ set_bluez_property("Discoverable", "false")
+ set_bluez_property("Powered", "false")
- self.context_client = Popen(["context-listen","Bluetooth.Enabled","Bluetooth.Visible"],stdin=PIPE,stdout=PIPE,stderr=PIPE)
- self.initial_output = stdoutRead(self.context_client, 2)
- self.initial_output.sort()
+ self.context_client = Popen(["context-listen","Bluetooth.Enabled","Bluetooth.Visible"],stdin=PIPE,stdout=PIPE,stderr=PIPE)
+ self.initial_output = stdoutRead(self.context_client, 2)
+ self.initial_output.sort()
- def tearDown(self):
+ def tearDown(self):
- # Restore some default values for Bluez
- set_bluez_property("Powered", "true")
- set_bluez_property("Discoverable", "false")
+ # Restore some default values for Bluez
+ set_bluez_property("Powered", "true")
+ set_bluez_property("Discoverable", "false")
- proc_kill(self.context_client.pid)
+ proc_kill(self.context_client.pid)
- def testInitial(self):
- self.assertEqual(self.initial_output[0].strip(), "Bluetooth.Enabled = bool:false")
- self.assertEqual(self.initial_output[1].strip(), "Bluetooth.Visible = bool:false")
+ def testInitial(self):
+ self.assertEqual(self.initial_output[0].strip(), "Bluetooth.Enabled = bool:false")
+ self.assertEqual(self.initial_output[1].strip(), "Bluetooth.Visible = bool:false")
- def testEnabledAndVisible(self):
-
- # Enable
- set_bluez_property("Powered", "true")
- actual = stdoutRead(self.context_client,1)
- expected = ["Bluetooth.Enabled = bool:true"]
- self.assertEqual(actual, expected)
+ def testEnabledAndVisible(self):
+ # Enable
+ set_bluez_property("Powered", "true")
+ actual = stdoutRead(self.context_client,1)
+ expected = ["Bluetooth.Enabled = bool:true"]
+ self.assertEqual(actual, expected)
- # Set visible
- set_bluez_property("Discoverable", "true")
- actual = stdoutRead(self.context_client,1)
- expected = ["Bluetooth.Visible = bool:true"]
- self.assertEqual(actual, expected)
+ # Set visible
+ set_bluez_property("Discoverable", "true")
+ actual = stdoutRead(self.context_client,1)
+ expected = ["Bluetooth.Visible = bool:true"]
+ self.assertEqual(actual, expected)
- # Set invisible
- set_bluez_property("Discoverable", "false")
- actual = stdoutRead(self.context_client,1)
- expected = ["Bluetooth.Visible = bool:false"]
- self.assertEqual(actual, expected)
-
- # Disable
- set_bluez_property("Powered", "false")
- actual = stdoutRead(self.context_client,1)
- expected = ["Bluetooth.Enabled = bool:false"]
- self.assertEqual(actual, expected)
+ # Set invisible
+ set_bluez_property("Discoverable", "false")
+ actual = stdoutRead(self.context_client,1)
+ expected = ["Bluetooth.Visible = bool:false"]
+ self.assertEqual(actual, expected)
+ # Disable
+ set_bluez_property("Powered", "false")
+ actual = stdoutRead(self.context_client,1)
+ expected = ["Bluetooth.Enabled = bool:false"]
+ self.assertEqual(actual, expected)
if __name__ == "__main__":
- sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
- signal.signal(signal.SIGALRM, timeoutHandler)
- signal.alarm(30)
- unittest.main()
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
+ signal.signal(signal.SIGALRM, timeoutHandler)
+ signal.alarm(30)
+ unittest.main()
diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp
index f7b748de..8cc08e3b 100644
--- a/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp
+++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp
@@ -27,7 +27,7 @@
#include <QDateTime>
/// The factory method for constructing the IPropertyProvider instance.
-IProviderPlugin* pluginFactory(const QString& /*constructionString*/)
+IProviderPlugin* pluginFactory(QString /*constructionString*/)
{
// Note: it's the caller's responsibility to delete the plugin if
// needed.
@@ -42,8 +42,10 @@ TimePlugin::TimePlugin()
prefix = TIME_PLUGIN_PREFIX;
timer.setInterval(2000);
sconnect(&timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
- sconnect(this, SIGNAL(emitReady()), this, SLOT(onEmitReady()), Qt::QueuedConnection);
- emit emitReady();
+ QTimer *t = new QTimer(this);
+ sconnect(t, SIGNAL(timeout()), this, SLOT(emitReady()), Qt::QueuedConnection);
+ t.setSingleShot(true);
+ t.setInterval(0);
}
void TimePlugin::subscribe(QSet<QString> keys)
@@ -60,7 +62,7 @@ void TimePlugin::unsubscribe(QSet<QString> keys)
timer.stop();
}
-void TimePlugin::onEmitReady()
+void TimePlugin::emitReady()
{
contextDebug();
emit ready();
@@ -73,4 +75,3 @@ void TimePlugin::onTimeout()
}
} // end namespace
-
diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.h b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h
index 508be886..78f1ccc2 100644
--- a/libcontextsubscriber/customer-tests/testplugins/timeplugin.h
+++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h
@@ -32,7 +32,7 @@ This is a test plugin for customer tests.
using ContextSubscriber::IProviderPlugin;
extern "C" {
- IProviderPlugin* pluginFactory(const QString& constructionString);
+ IProviderPlugin* pluginFactory(QString constructionString);
}
namespace ContextSubscriberTime
@@ -47,11 +47,8 @@ public:
virtual void subscribe(QSet<QString> keys);
virtual void unsubscribe(QSet<QString> keys);
-signals:
- void emitReady();
-
private slots:
- void onEmitReady();
+ void emitReady();
void onTimeout();
private:
diff --git a/libcontextsubscriber/src/Makefile.am b/libcontextsubscriber/src/Makefile.am
index b00f11a8..986fdec1 100644
--- a/libcontextsubscriber/src/Makefile.am
+++ b/libcontextsubscriber/src/Makefile.am
@@ -12,7 +12,7 @@ libcontextsubscriber_la_SOURCES = contextproperty.cpp \
dbusnamelistener.cpp handlesignalrouter.cpp \
handlesignalrouter.h queuedinvoker.cpp queuedinvoker.h \
loggingfeatures.h contextkitplugin.h contextkitplugin.cpp \
- iproviderplugin.h bluezinterface.h bluezinterface.cpp
+ iproviderplugin.h
includecontextsubscriberdir=$(includedir)/contextsubscriber
includecontextsubscriber_HEADERS = contextproperty.h \
diff --git a/libcontextsubscriber/src/iproviderplugin.h b/libcontextsubscriber/src/iproviderplugin.h
index 2cfef845..e03900ed 100644
--- a/libcontextsubscriber/src/iproviderplugin.h
+++ b/libcontextsubscriber/src/iproviderplugin.h
@@ -42,6 +42,8 @@ signals:
void valueChanged(QString key, QVariant value);
};
+typedef IProviderPlugin* (*PluginFactoryFunc)(QString constructionString);
+
}
#endif
diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp
index c39963bd..511568b5 100644
--- a/libcontextsubscriber/src/provider.cpp
+++ b/libcontextsubscriber/src/provider.cpp
@@ -92,8 +92,6 @@ namespace ContextSubscriber {
\brief Emitted when the subscription procedure for \c keys finished
(either succeeded, either failed) */
-typedef IProviderPlugin* (*PluginFactoryFunc)(const QString& constructionString);
-
/// Stores the passed plugin name and construction paramater, then
/// moves into the main thread and queues a constructPlugin call.
Provider::Provider(const QString &plugin, const QString &constructionString)