summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-10 23:52:30 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-10 23:52:30 +0200
commit1b8f2a0e2e63b1f881b6ba7b18982353b9c27b19 (patch)
tree72a3b00cee7068e03d1d5182d70622903fda58c0
parentd3ed26704ad29f58f28f7ef84de5bbf6b5f0eaf6 (diff)
downloadsowatch-1b8f2a0e2e63b1f881b6ba7b18982353b9c27b19.tar.gz
sowatch-1b8f2a0e2e63b1f881b6ba7b18982353b9c27b19.zip
fix package upgrade issues
-rw-r--r--libsowatch/registry.cpp32
-rw-r--r--libsowatch/registry.h9
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml6
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml2
-rw-r--r--notificationswatchlet/metawatch-digital.qml4
-rw-r--r--qtc_packaging/debian_harmattan/postinst13
-rw-r--r--qtc_packaging/debian_harmattan/prerm13
-rwxr-xr-xqtc_packaging/debian_harmattan/rules6
-rw-r--r--sowatch.pro2
-rw-r--r--sowatchd/daemon.cpp1
-rw-r--r--sowatchd/daemon.h1
-rw-r--r--sowatchd/sowatchd.conf5
-rw-r--r--sowatchd/watchhandler.cpp63
-rw-r--r--sowatchd/watchhandler.h3
14 files changed, 140 insertions, 20 deletions
diff --git a/libsowatch/registry.cpp b/libsowatch/registry.cpp
index 5cbc464..4836aca 100644
--- a/libsowatch/registry.cpp
+++ b/libsowatch/registry.cpp
@@ -87,6 +87,7 @@ void Registry::loadDriver(const QString &file)
QStringList drivers = plugin->drivers();
foreach (const QString& driver, drivers) {
_driverIds[driver] = plugin;
+ emit driverLoaded(driver);
}
_watcher->addPath(file);
} else {
@@ -113,6 +114,7 @@ void Registry::loadNotificationProvider(const QString &file)
QStringList providers = plugin->providers();
foreach (const QString& provider, providers) {
_providerIds[provider] = plugin;
+ emit notificationProviderLoaded(provider);
}
_watcher->addPath(file);
} else {
@@ -139,6 +141,7 @@ void Registry::loadWatchlet(const QString &file)
QStringList watchlets = plugin->watchlets();
foreach (const QString& watchlet, watchlets) {
_watchletIds[watchlet] = plugin;
+ emit watchletLoaded(watchlet);
}
_watcher->addPath(file);
} else {
@@ -161,6 +164,7 @@ void Registry::unloadDriver(QPluginLoader *loader)
QStringList drivers = plugin->drivers();
foreach (const QString& driver, drivers) {
+ emit driverUnloaded(driver);
_driverIds.remove(driver);
}
@@ -168,9 +172,12 @@ void Registry::unloadDriver(QPluginLoader *loader)
_driverFiles.remove(file);
_watcher->removePath(file);
- // loader->unload();
- // TODO : Signal loss of a plugin so that servers can remove it before
- // we unload it.
+ qDebug() << "Now unloading" << file;
+ if (!loader->unload()) {
+ qWarning() << "Could not unload plugin" << file;
+ }
+
+ delete loader;
}
void Registry::unloadNotificationProvider(QPluginLoader *loader)
@@ -180,12 +187,20 @@ void Registry::unloadNotificationProvider(QPluginLoader *loader)
QStringList providers = plugin->providers();
foreach (const QString& provider, providers) {
+ emit notificationProviderUnloaded(provider);
_providerIds.remove(provider);
}
_providers.removeAll(plugin);
_providerFiles.remove(file);
_watcher->removePath(file);
+
+ qDebug() << "Now unloading" << file;
+ if (!loader->unload()) {
+ qWarning() << "Could not unload plugin" << file;
+ }
+
+ delete loader;
}
void Registry::unloadWatchlet(QPluginLoader *loader)
@@ -195,17 +210,25 @@ void Registry::unloadWatchlet(QPluginLoader *loader)
QStringList watchlets = plugin->watchlets();
foreach (const QString& watchlet, watchlets) {
+ emit watchletUnloaded(watchlet);
_watchletIds.remove(watchlet);
}
_watchlets.removeAll(plugin);
_watchletFiles.remove(file);
_watcher->removePath(file);
+
+ qDebug() << "Now unloading" << file;
+ if (!loader->unload()) {
+ qWarning() << "Could not unload plugin" << file;
+ }
+
+ delete loader;
}
void Registry::handlePluginDirectoryChanged(const QString &path)
{
- // If the directory changed, rescan it to load new discover new plugins.
+ // If the directory changed, rescan it to discover new plugins.
if (path == SOWATCH_DRIVERS_DIR) {
QDir dir(path);
foreach (QString entry, dir.entryList(QDir::Files)) {
@@ -235,7 +258,6 @@ void Registry::handlePluginDirectoryChanged(const QString &path)
void Registry::handlePluginFileChanged(const QString &file)
{
- QFile f(file);
if (_driverFiles.contains(file)) {
unloadDriver(_driverFiles[file]);
}
diff --git a/libsowatch/registry.h b/libsowatch/registry.h
index b2e2b0e..dab5009 100644
--- a/libsowatch/registry.h
+++ b/libsowatch/registry.h
@@ -58,6 +58,15 @@ public:
return _watchletIds.keys();
}
+signals:
+ void driverLoaded(const QString& id);
+ void notificationProviderLoaded(const QString& id);
+ void watchletLoaded(const QString& id);
+
+ void driverUnloaded(const QString& id);
+ void notificationProviderUnloaded(const QString& id);
+ void watchletUnloaded(const QString& id);
+
protected:
Registry();
~Registry();
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml
new file mode 100644
index 0000000..5ade4a8
--- /dev/null
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+Text {
+ font.family: "MetaWatch Large"
+ font.pixelSize: 16
+}
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
index 5eb30b5..c2cccab 100644
--- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
@@ -13,7 +13,7 @@ Rectangle {
anchors.top: parent.top
}
- Text {
+ MWLabel {
id: label
anchors.left: image.right
anchors.leftMargin: 2
diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml
index 493cc96..1e97052 100644
--- a/notificationswatchlet/metawatch-digital.qml
+++ b/notificationswatchlet/metawatch-digital.qml
@@ -28,7 +28,7 @@ Rectangle {
width: notifs.width
height: childrenRect.height
color: ListView.isCurrentItem ? "black" : "white"
- Text {
+ MWLabel {
width: 96
text: "<b>" + model.modelData.title + "</b><br>" + model.modelData.body
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
@@ -38,7 +38,7 @@ Rectangle {
visible: count > 0;
}
- Text {
+ MWLabel {
anchors.top: title.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("No notifications");
diff --git a/qtc_packaging/debian_harmattan/postinst b/qtc_packaging/debian_harmattan/postinst
new file mode 100644
index 0000000..c0a1855
--- /dev/null
+++ b/qtc_packaging/debian_harmattan/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+case "$1" in
+ configure)
+ start -v apps/sowatchd || :
+ ;;
+esac
+
+exit 0
diff --git a/qtc_packaging/debian_harmattan/prerm b/qtc_packaging/debian_harmattan/prerm
new file mode 100644
index 0000000..5deafcb
--- /dev/null
+++ b/qtc_packaging/debian_harmattan/prerm
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ upgrade|remove)
+ stop -v apps/sowatchd || :
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/qtc_packaging/debian_harmattan/rules b/qtc_packaging/debian_harmattan/rules
index 07d6f82..804d37c 100755
--- a/qtc_packaging/debian_harmattan/rules
+++ b/qtc_packaging/debian_harmattan/rules
@@ -20,7 +20,7 @@ endif
configure: configure-stamp
configure-stamp:
dh_testdir
- # qmake PREFIX=/usr# Uncomment this line for use without Qt Creator
+ # qmake PREFIX=/usr # Uncomment this line for use without Qt Creator
touch configure-stamp
@@ -30,9 +30,7 @@ build: build-stamp
build-stamp: configure-stamp
dh_testdir
- # Add here commands to compile the package.
# $(MAKE) $(PARALLEL) # Uncomment this line for use without Qt Creator
- #docbook-to-man debian/sowatch.sgml > sowatch.1
touch $@
@@ -41,7 +39,6 @@ clean:
dh_testroot
rm -f build-stamp configure-stamp
- # Add here commands to clean up after the build process.
-$(MAKE) clean
dh_clean
@@ -52,7 +49,6 @@ install: build
dh_clean -k
dh_installdirs
- # Add here commands to install the package into debian/sowatch.
$(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/sowatch install
diff --git a/sowatch.pro b/sowatch.pro
index 3d13e32..00f475b 100644
--- a/sowatch.pro
+++ b/sowatch.pro
@@ -47,6 +47,8 @@ OTHER_FILES += \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog \
qtc_packaging/debian_harmattan/manifest.aegis \
+ qtc_packaging/debian_harmattan/prerm \
+ qtc_packaging/debian_harmattan/postinst \
qtc_packaging/debian_fremantle/rules \
qtc_packaging/debian_fremantle/README \
qtc_packaging/debian_fremantle/copyright \
diff --git a/sowatchd/daemon.cpp b/sowatchd/daemon.cpp
index bcf3686..b8d5d0e 100644
--- a/sowatchd/daemon.cpp
+++ b/sowatchd/daemon.cpp
@@ -6,7 +6,6 @@ using namespace sowatch;
Daemon::Daemon(QObject *parent) :
QObject(parent),
- _registry(Registry::registry()),
_config(new GConfKey("/apps/sowatch", this)),
_watches_list(_config->getSubkey("watches", this)),
_status_mapper(new QSignalMapper(this))
diff --git a/sowatchd/daemon.h b/sowatchd/daemon.h
index e3f748b..45a2d60 100644
--- a/sowatchd/daemon.h
+++ b/sowatchd/daemon.h
@@ -27,7 +27,6 @@ signals:
void WatchStatusChanged(const QString &watch, const QString &status);
private:
- Registry* _registry;
ConfigKey* _config;
ConfigKey* _watches_list;
QMap<QString, WatchHandler*> _watches;
diff --git a/sowatchd/sowatchd.conf b/sowatchd/sowatchd.conf
index 2cebb82..77bdca4 100644
--- a/sowatchd/sowatchd.conf
+++ b/sowatchd/sowatchd.conf
@@ -4,10 +4,9 @@ author "maemo@javispedro.com"
stop on stopping xsession
console none
-
respawn
respawn limit 3 10
-
-nice 2
+normal exit 0 TERM
+nice 1
exec /usr/bin/aegis-exec -s -u user -l "exec /opt/sowatch/bin/sowatchd"
diff --git a/sowatchd/watchhandler.cpp b/sowatchd/watchhandler.cpp
index 314156a..4bebb9c 100644
--- a/sowatchd/watchhandler.cpp
+++ b/sowatchd/watchhandler.cpp
@@ -13,12 +13,26 @@ WatchHandler::WatchHandler(ConfigKey *config, QObject *parent)
connect(_config, SIGNAL(subkeyChanged(QString)),
SLOT(handleConfigSubkeyChanged(QString)));
+ // Connect to the registry in case plugins are unloaded
+ connect(registry, SIGNAL(driverUnloaded(QString)),
+ SLOT(handleDriverUnloaded(QString)));
+ connect(registry, SIGNAL(watchletLoaded(QString)),
+ SLOT(updateWatchlets()));
+ connect(registry, SIGNAL(watchletUnloaded(QString)),
+ SLOT(handleWatchletUnloaded(QString)));
+ connect(registry, SIGNAL(notificationProviderLoaded(QString)),
+ SLOT(updateProviders()));
+ connect(registry, SIGNAL(notificationProviderUnloaded(QString)),
+ SLOT(handleProviderUnloaded(QString)));
+
+ // Get the watch driver
const QString driver = _config->value("driver").toString();
if (driver.isEmpty()) {
qWarning() << "Watch" << _config->value("name") << "has no driver setting";
return;
}
+
WatchPluginInterface *watchPlugin = registry->getWatchPlugin(driver);
if (!watchPlugin) {
qWarning() << "Invalid driver" << driver;
@@ -50,7 +64,7 @@ WatchHandler::WatchHandler(ConfigKey *config, QObject *parent)
QString WatchHandler::status() const
{
- if (_watch->isConnected()) {
+ if (_watch && _watch->isConnected()) {
return "connected";
} else if (_config->value("enable").toBool()) {
return "enabled";
@@ -62,6 +76,9 @@ QString WatchHandler::status() const
void WatchHandler::updateWatchlets()
{
Registry *registry = Registry::registry();
+
+ if (!_server) return;
+
QStringList newWatchlets = _config->value("watchlets").toStringList();
QStringList curWatchlets = _watchlet_order;
@@ -97,6 +114,9 @@ void WatchHandler::updateWatchlets()
void WatchHandler::updateProviders()
{
Registry *registry = Registry::registry();
+
+ if (!_server) return;
+
QSet<QString> curProviders = _providers.keys().toSet();
QSet<QString> newProviders = _config->value("providers").toStringList().toSet();
QSet<QString> removed = curProviders - newProviders;
@@ -128,7 +148,46 @@ void WatchHandler::handleConfigSubkeyChanged(const QString &subkey)
updateWatchlets();
} else if (subkey == "providers") {
updateProviders();
- } else if (subkey == "next-watchlet-button") {
+ } else if (subkey == "next-watchlet-button" && _server) {
_server->setNextWatchletButton(_config->value("next-watchlet-button").toString());
}
}
+
+void WatchHandler::handleDriverUnloaded(const QString &id)
+{
+ if (id == _config->value("driver").toString()) {
+ // Emergency disconnection!
+ qWarning("Unloading driver of active watch!");
+ if (_server) {
+ delete _server;
+ _server = 0;
+ }
+ if (_watch) {
+ delete _watch;
+ _watch = 0;
+ }
+ emit statusChanged();
+ }
+}
+
+void WatchHandler::handleWatchletUnloaded(const QString &id)
+{
+ if (_watchlets.contains(id)) {
+ qDebug() << "Unloading watchlet" << id << "from watch";
+ Watchlet* watchlet = _watchlets[id];
+ _server->removeWatchlet(watchlet);
+ _watchlets.remove(id);
+ delete watchlet;
+ }
+}
+
+void WatchHandler::handleProviderUnloaded(const QString &id)
+{
+ if (_providers.contains(id)) {
+ qDebug() << "Unloading provider" << id << "from watch";
+ NotificationProvider *provider = _providers[id];
+ _server->removeProvider(provider);
+ _providers.remove(id);
+ delete provider;
+ }
+}
diff --git a/sowatchd/watchhandler.h b/sowatchd/watchhandler.h
index 3fa7c6b..39c1d17 100644
--- a/sowatchd/watchhandler.h
+++ b/sowatchd/watchhandler.h
@@ -26,6 +26,9 @@ private slots:
void updateWatchlets();
void updateProviders();
void handleConfigSubkeyChanged(const QString& key);
+ void handleDriverUnloaded(const QString& id);
+ void handleWatchletUnloaded(const QString& id);
+ void handleProviderUnloaded(const QString& id);
private:
ConfigKey *_config;