diff options
author | Marja Hassinen <ext-marja.2.hassinen@nokia.com> | 2009-09-11 11:32:56 +0300 |
---|---|---|
committer | Marja Hassinen <ext-marja.2.hassinen@nokia.com> | 2009-09-11 11:32:56 +0300 |
commit | 1c0fde79f0d7d25f0fffc525a6c1292d56f51a34 (patch) | |
tree | 443292ee76e2d43717c9525e8c482aafc381a950 /libcontextsubscriber | |
parent | 72a92e4835ed7647f0b17251128028c209d8e26f (diff) |
libcontextsubscriber, plugins: Building test plugins.
Diffstat (limited to 'libcontextsubscriber')
8 files changed, 210 insertions, 1 deletions
diff --git a/libcontextsubscriber/customer-tests/Makefile.am b/libcontextsubscriber/customer-tests/Makefile.am index 8eed733d..07495c1a 100644 --- a/libcontextsubscriber/customer-tests/Makefile.am +++ b/libcontextsubscriber/customer-tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = update-contextkit-providers +SUBDIRS = update-contextkit-providers testplugins libcontextsubscribertestsdir = $(datadir)/libcontextsubscriber-tests libcontextsubscribertests_DATA = tests.xml diff --git a/libcontextsubscriber/customer-tests/testplugins/Makefile.am b/libcontextsubscriber/customer-tests/testplugins/Makefile.am new file mode 100644 index 00000000..38b401c6 --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = timeplugin1 timeplugin2 +EXTRA_DIST = timeplugin.cpp timeplugin.h diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp new file mode 100644 index 00000000..f7b748de --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2009 Nokia Corporation. + * + * Contact: Marius Vollmer <marius.vollmer@nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include "timeplugin.h" +#include "sconnect.h" + +#include "logging.h" + +#include <QDateTime> + +/// The factory method for constructing the IPropertyProvider instance. +IProviderPlugin* pluginFactory(const QString& /*constructionString*/) +{ + // Note: it's the caller's responsibility to delete the plugin if + // needed. + return new ContextSubscriberTime::TimePlugin(); +} + +namespace ContextSubscriberTime { + +TimePlugin::TimePlugin() +{ + contextDebug(); + 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(); +} + +void TimePlugin::subscribe(QSet<QString> keys) +{ + contextDebug() << keys; + foreach(const QString& key, keys) { + emit subscribeFinished(key); + } + timer.start(); +} + +void TimePlugin::unsubscribe(QSet<QString> keys) +{ + timer.stop(); +} + +void TimePlugin::onEmitReady() +{ + contextDebug(); + emit ready(); +} + +void TimePlugin::onTimeout() +{ + contextDebug() << "Timeout"; + emit valueChanged("Test.Time", QDateTime::currentDateTime().toString().prepend(prefix)); +} + +} // end namespace + diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.h b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h new file mode 100644 index 00000000..508be886 --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 Nokia Corporation. + * + * Contact: Marius Vollmer <marius.vollmer@nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/* +This is a test plugin for customer tests. +*/ + +#ifndef TIMEPLUGIN_H +#define TIMEPLUGIN_H + +#include "iproviderplugin.h" // For IProviderPlugin definition +#include <QTimer> + +using ContextSubscriber::IProviderPlugin; + +extern "C" { + IProviderPlugin* pluginFactory(const QString& constructionString); +} + +namespace ContextSubscriberTime +{ + +class TimePlugin : public IProviderPlugin +{ + Q_OBJECT + +public: + explicit TimePlugin(); + virtual void subscribe(QSet<QString> keys); + virtual void unsubscribe(QSet<QString> keys); + +signals: + void emitReady(); + +private slots: + void onEmitReady(); + void onTimeout(); + +private: + QTimer timer; + QString prefix; +}; +} + +#endif diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin1/Makefile.am b/libcontextsubscriber/customer-tests/testplugins/timeplugin1/Makefile.am new file mode 100644 index 00000000..a7903652 --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin1/Makefile.am @@ -0,0 +1,30 @@ +lib_LTLIBRARIES = libcontextsubscribertime1.la +libcontextsubscribertime1_la_SOURCES = timeplugin.cpp timeplugin.h + +BUILT_SOURCES = $(libcontextsubscribertime1_la_SOURCES) +timeplugin.cpp: ../timeplugin.cpp + ln -sf $< $@ +timeplugin.h: ../timeplugin.h + ln -sf $< $@ + +clean-local: + rm -f timeplugin.cpp timeplugin.h + +AM_CXXFLAGS = -I$(top_srcdir)/common \ + -I$(srcdir)/../../../src $(QtCore_CFLAGS) \ + $(QtDBus_CFLAGS) \ + '-DCONTEXT_LOG_MODULE_NAME="time1plugin"' \ + '-DTIME_PLUGIN_PREFIX="Time1: "' + +$(top_builddir)/common/libcommon.a: + $(MAKE) -C $(top_builddir)/common libcommon.a + +LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtDBus_LIBS) +libcontextsubscribertime1_la_LIBADD=$(top_builddir)/common/libcommon.la + +.PHONY: $(top_builddir)/common/libcommon.la + +# moccing +nodist_libcontextsubscribertime1_la_SOURCES = mocs.cpp +QT_TOMOC = $(filter %.h, $(libcontextsubscribertime1_la_SOURCES)) +include $(top_srcdir)/am/qt.am diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin1/time1.context b/libcontextsubscriber/customer-tests/testplugins/timeplugin1/time1.context new file mode 100644 index 00000000..33c9d20d --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin1/time1.context @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<provider xmlns="http://contextkit.freedesktop.org/Provider" plugin="libcontextsubscribertime1" constructionString="time"> + <key name="Test.Time"><type>STRING</type></key> +</provider> diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin2/Makefile.am b/libcontextsubscriber/customer-tests/testplugins/timeplugin2/Makefile.am new file mode 100644 index 00000000..060efcad --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin2/Makefile.am @@ -0,0 +1,30 @@ +lib_LTLIBRARIES = libcontextsubscribertime2.la +libcontextsubscribertime2_la_SOURCES = timeplugin.cpp timeplugin.h + +BUILT_SOURCES = $(libcontextsubscribertime2_la_SOURCES) +timeplugin.cpp: ../timeplugin.cpp + ln -sf $< $@ +timeplugin.h: ../timeplugin.h + ln -sf $< $@ + +clean-local: + rm -f timeplugin.cpp timeplugin.h + +AM_CXXFLAGS = -I$(top_srcdir)/common \ + -I$(srcdir)/../../../src $(QtCore_CFLAGS) \ + $(QtDBus_CFLAGS) \ + '-DCONTEXT_LOG_MODULE_NAME="time2plugin"' \ + '-DTIME_PLUGIN_PREFIX="Time2: "' + +$(top_builddir)/common/libcommon.a: + $(MAKE) -C $(top_builddir)/common libcommon.a + +LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtDBus_LIBS) +libcontextsubscribertime2_la_LIBADD=$(top_builddir)/common/libcommon.la + +.PHONY: $(top_builddir)/common/libcommon.la + +# moccing +nodist_libcontextsubscribertime2_la_SOURCES = mocs.cpp +QT_TOMOC = $(filter %.h, $(libcontextsubscribertime2_la_SOURCES)) +include $(top_srcdir)/am/qt.am diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin2/time2.context b/libcontextsubscriber/customer-tests/testplugins/timeplugin2/time2.context new file mode 100644 index 00000000..ac170272 --- /dev/null +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin2/time2.context @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<provider xmlns="http://contextkit.freedesktop.org/Provider" plugin="libcontextsubscribertime2" constructionString="time"> + <key name="Test.Time"><type>STRING</type></key> +</provider> |