From 7d8f121652ceecc371a5f73986e2ef8fc2f1e4be Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Wed, 16 Jul 2014 04:26:05 +0200 Subject: Use new Log4Qt features and fixes --- daemon/daemon.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'daemon/daemon.cpp') diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index eba9afa..a2cb900 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -54,18 +54,8 @@ void signalhandler(int sig) } } -// For some reason exactly SystemLogAppender doesn't have a factory registered in log4qt, -// so in order for it to be instantiatable from .conf file (or even in general?) we declare factory -// right here and will register it in initLoggin() -Log4Qt::Appender *create_system_log_appender() { - return new Log4Qt::SystemLogAppender; -} - void initLogging() { - // Should really be done in log4qt, but somehow it's missing these - Log4Qt::Factory::registerAppender("org.apache.log4j.SystemLogAppender", create_system_log_appender); - // Sailfish OS-specific locations for the app settings files and app's own files const QString logConfigFilePath(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0) + "pebble/log4qt.conf"); @@ -74,36 +64,6 @@ void initLogging() const QString& usedConfigFile = QFile::exists(logConfigFilePath) ? logConfigFilePath : fallbackLogConfigPath; Log4Qt::PropertyConfigurator::configure(usedConfigFile); - // Uglyish hack for replacing $XDG_CACHE_HOME with the proper cache directory - // TODO: Implement replacing of $XDG_CACHE_HOME (and other vars?) with the proper values before configuring log4qt - - // Iterate all appenders attached to root logger and whenever a FileAppender (or its descender found), replace - // $XDG_CACHE_HOME with the proper folder name - QList appenders = Log4Qt::LogManager::rootLogger()->appenders(); - QList::iterator i; - QDir pathCreator; - for (i = appenders.begin(); i != appenders.end(); ++i) { - Log4Qt::FileAppender* fa = qobject_cast(*i); - if(fa) { - QString filename = fa->file(); - - // As per March 2014 on emulator QStandardPaths::CacheLocation is /home/nemo/.cache - // while on device it is /home/nemo/.cache/app-name - // both things are fine, logging path will just be a little deeper on device - filename.replace("$XDG_CACHE_HOME", - QStandardPaths::standardLocations(QStandardPaths::CacheLocation).at(0) - ); - // make sure loggin dir exists - QFileInfo fi(filename); - if(!pathCreator.mkpath(fi.path())) { - Log4Qt::LogManager::rootLogger()->error("Failed to create dir for logging: %1", fi.path()); - } - - fa->setFile(filename); - fa->activateOptions(); - } - } - // For capturing qDebug() and console.log() messages // Note that console.log() might fail in Sailfish OS device builds. Not sure why, but it seems like // console.log() exactly in Sailfish OS device release builds doesn't go through the same qDebug() channel -- cgit v1.2.3 From c47315faa12bbb36772c3f5897751bf74fa122f4 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Fri, 18 Jul 2014 23:36:05 +0200 Subject: Implemented settings skeleton and notifications --- app/qml/pages/ManagerPage.qml | 11 +++++++++-- daemon/daemon.cpp | 4 +++- daemon/daemon.pro | 3 ++- daemon/manager.cpp | 18 ++++++++++++++++-- daemon/manager.h | 7 ++++++- daemon/settings.h | 25 +++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 daemon/settings.h (limited to 'daemon/daemon.cpp') diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index 92d79b1..a6b6699 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -32,10 +32,17 @@ import QtQuick 2.0 import QtQml 2.1 import Sailfish.Silica 1.0 +import org.nemomobile.configuration 1.0 Page { id: page + ConfigurationGroup { + id: settings + path: "/org/pebbled/settings" + property bool silentWhenConnected: false + } + SilicaFlickable { anchors.fill: parent @@ -121,10 +128,10 @@ Page { } TextSwitch { text: qsTr("Silent when connected") - checked: false + checked: settings.silentWhenConnected automaticCheck: false onClicked: { - console.log('settings.silentConnected'); + settings.silentWhenConnected = !settings.silentWhenConnected; } } } diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index a2cb900..b891680 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -86,7 +86,9 @@ int main(int argc, char *argv[]) DBusConnector dbus; VoiceCallManager voice; - Manager manager(&watch, &dbus, &voice); + Settings settings; + + Manager manager(&watch, &dbus, &voice, &settings); signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); diff --git a/daemon/daemon.pro b/daemon/daemon.pro index 3db6918..cf6d5b9 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -29,7 +29,8 @@ HEADERS += \ watchconnector.h \ dbusconnector.h \ dbusadaptor.h \ - watchcommands.h + watchcommands.h \ + settings.h OTHER_FILES += \ org.pebbled.xml \ diff --git a/daemon/manager.cpp b/daemon/manager.cpp index a2365b4..8e07d52 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -5,10 +5,14 @@ #include #include -Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice) : +Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, Settings *settings) : QObject(0), watch(watch), dbus(dbus), voice(voice), commands(new WatchCommands(watch, this)), - notification(MNotification::DeviceEvent) + settings(settings), notification(MNotification::DeviceEvent) { + connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); + connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged())); + connect(settings, SIGNAL(silentWhenConnectedChanged()), SLOT(onSettingsChanged())); + // We don't need to handle presence changes, so report them separately and ignore them QMap parameters; parameters.insert(QString::fromLatin1("mergePresenceChanges"), QString::fromLatin1("false")); @@ -54,6 +58,16 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(this, SIGNAL(mprisMetadataChanged(QVariantMap)), commands, SLOT(onMprisMetadataChanged(QVariantMap))); } +void Manager::onSettingChanged(const QString &key) +{ + logger()->debug() << __FUNCTION__ << key << ":" << settings->property(qPrintable(key)); +} + +void Manager::onSettingsChanged() +{ + logger()->warn() << __FUNCTION__ << "Not implemented!"; +} + void Manager::onPebbleChanged() { const QVariantMap & pebble = dbus->pebble(); diff --git a/daemon/manager.h b/daemon/manager.h index e967dae..64dbcce 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -5,6 +5,7 @@ #include "dbusconnector.h" #include "voicecallmanager.h" #include "watchcommands.h" +#include "settings.h" #include #include @@ -38,6 +39,8 @@ class Manager : WatchCommands *commands; + Settings *settings; + MNotification notification; QContactManager *contacts; @@ -47,7 +50,7 @@ class Manager : QString lastSeenMpris; public: - explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice); + explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, Settings *settings); Q_INVOKABLE QString findPersonByNumber(QString number); Q_INVOKABLE void processUnreadMessages(GroupObject *group); @@ -62,6 +65,8 @@ public slots: void hangupAll(); protected slots: + void onSettingChanged(const QString &key); + void onSettingsChanged(); void onPebbleChanged(); void onConnectedChanged(); void onActiveVoiceCallChanged(); diff --git a/daemon/settings.h b/daemon/settings.h new file mode 100644 index 0000000..50ffd86 --- /dev/null +++ b/daemon/settings.h @@ -0,0 +1,25 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include + +class Settings : public MDConfGroup +{ + Q_OBJECT + + Q_PROPERTY(bool silentWhenConnected MEMBER silentWhenConnected NOTIFY silentWhenConnectedChanged) + bool silentWhenConnected; + +public: + explicit Settings(QObject *parent = 0) : + MDConfGroup("/org/pebbled/settings", parent, BindProperties) + { resolveMetaObject(); } + +signals: + void silentWhenConnectedChanged(bool); + +public slots: + +}; + +#endif // SETTINGS_H -- cgit v1.2.3