From cfd11bb46b0e93903135c127b955e657d7f2b33d Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Fri, 18 Jul 2014 23:47:12 +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 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..3214cdc 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(bool)), SLOT(onSilentWhenConnectedChanged(bool))); + // 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 From e8ad1c9c993a98cdeea92dfcec29052654ec807d Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Sun, 20 Jul 2014 21:48:03 +0200 Subject: Added VERSION to app and daemon --- app/app.pro | 2 ++ app/pebble.cpp | 9 ++++++++- daemon/daemon.cpp | 4 ++-- daemon/daemon.pro | 2 ++ rpm/pebble.spec | 3 ++- rpm/pebble.yaml | 2 ++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/app.pro b/app/app.pro index 48aff06..c0fe5d3 100644 --- a/app/app.pro +++ b/app/app.pro @@ -5,6 +5,8 @@ CONFIG += sailfishapp QT += dbus QMAKE_CXXFLAGS += -std=c++0x +DEFINES += APP_VERSION=\\\"$$VERSION\\\" + SOURCES += \ pebble.cpp \ pebbledinterface.cpp diff --git a/app/pebble.cpp b/app/pebble.cpp index b2f4d09..44f1aeb 100644 --- a/app/pebble.cpp +++ b/app/pebble.cpp @@ -39,6 +39,13 @@ int main(int argc, char *argv[]) // Register Pebble daemon interface object on QML side qmlRegisterType("org.pebbled", 0, 1, "PebbledInterface"); - return SailfishApp::main(argc, argv); + QScopedPointer app(SailfishApp::application(argc, argv)); + + QScopedPointer view(SailfishApp::createView()); + view->rootContext()->setContextProperty("APP_VERSION", APP_VERSION); + view->setSource(SailfishApp::pathTo("qml/pebble.qml")); + view->show(); + + return app->exec(); } diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index b891680..6fa634c 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -70,8 +70,6 @@ void initLogging() Log4Qt::LogManager::setHandleQtMessages(true); qDebug() << "Using following log config file: " << usedConfigFile; - - Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info("Logging started"); } int main(int argc, char *argv[]) @@ -82,6 +80,8 @@ int main(int argc, char *argv[]) // QCoreApplication for determining the .conf files locations initLogging(); + Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info() << argv[0] << APP_VERSION; + watch::WatchConnector watch; DBusConnector dbus; VoiceCallManager voice; diff --git a/daemon/daemon.pro b/daemon/daemon.pro index cf6d5b9..d77be1a 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -12,6 +12,8 @@ LIBS += -L$$OUT_PWD/../ext/Log4Qt/ -llog4qt QMAKE_RPATHDIR += /usr/share/pebble/lib INCLUDEPATH += ../ext/Log4Qt/src ../ext/Log4Qt/deploy/include +DEFINES += APP_VERSION=\\\"$$VERSION\\\" + SOURCES += \ daemon.cpp \ manager.cpp \ diff --git a/rpm/pebble.spec b/rpm/pebble.spec index 8129886..01a66e1 100644 --- a/rpm/pebble.spec +++ b/rpm/pebble.spec @@ -47,7 +47,8 @@ Include support for Pebble watch to receive event from SailfishOS device. Commun # >> build pre # << build pre -%qtc_qmake5 +%qtc_qmake5 \ + VERSION='%{version}-%{release}' %qtc_make %{?_smp_mflags} diff --git a/rpm/pebble.yaml b/rpm/pebble.yaml index f0fc73d..1bb3352 100644 --- a/rpm/pebble.yaml +++ b/rpm/pebble.yaml @@ -11,6 +11,8 @@ Description: | Include support for Pebble watch to receive event from SailfishOS device. Communicates via Bluetooth, supporting the Pebble protocol. Configure: none Builder: qtc5 +QMakeOptions: +- VERSION='%{version}-%{release}' PkgConfigBR: - Qt5DBus - Qt5Bluetooth -- cgit v1.2.3 From 4f708105d87b1b2dcb516b05dd2ab1c7da508a8a Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Sun, 20 Jul 2014 23:34:52 +0200 Subject: Implemented About Page --- app/app.pro | 2 ++ app/qml/images/btn_donate.png | Bin 0 -> 155389 bytes app/qml/pages/AboutPage.qml | 68 ++++++++++++++++++++++++++++++++++++++++++ app/qml/pages/ManagerPage.qml | 8 ++++- 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/qml/images/btn_donate.png create mode 100644 app/qml/pages/AboutPage.qml diff --git a/app/app.pro b/app/app.pro index c0fe5d3..cb4c33b 100644 --- a/app/app.pro +++ b/app/app.pro @@ -18,6 +18,8 @@ OTHER_FILES += \ qml/cover/CoverPage.qml \ qml/pages/ManagerPage.qml \ qml/pages/WatchPage.qml \ + qml/pages/AboutPage.qml \ qml/pebble.qml \ + qml/images/* \ pebble.desktop \ pebble.png diff --git a/app/qml/images/btn_donate.png b/app/qml/images/btn_donate.png new file mode 100644 index 0000000..3777e64 Binary files /dev/null and b/app/qml/images/btn_donate.png differ diff --git a/app/qml/pages/AboutPage.qml b/app/qml/pages/AboutPage.qml new file mode 100644 index 0000000..6d8d18e --- /dev/null +++ b/app/qml/pages/AboutPage.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 +import QtQml 2.1 +import Sailfish.Silica 1.0 + +Page { + id: page + + SilicaFlickable { + anchors.fill: parent + + contentHeight: column.height + + Column { + id: column + width: page.width + spacing: Theme.paddingMedium + + PageHeader { + title: "pebbled" + } + Label { + text: qsTr("Version ") + APP_VERSION + horizontalAlignment: Text.AlignRight + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingLarge + } + } + Label { + color: Theme.highlightColor + width: parent.width + horizontalAlignment: Text.AlignHCenter + text: "© 2014 Tomasz Sterna / Xiaoka.com\nAll Rights Reserved." + } + Label { + wrapMode: Text.Wrap + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingSmall + } + font.pixelSize: Theme.fontSizeTiny + horizontalAlignment: Text.AlignJustify + text: qsTr( +"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND "+ +"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "+ +"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE "+ +"DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR "+ +"ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES "+ +"(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; "+ +"LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND "+ +"ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT "+ +"(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS "+ +"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.") + } + IconButton { + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingMedium + } + icon.source: "../images/btn_donate.png" + onClicked: Qt.openUrlExternally("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MAGN86VCARBSA") + } + } + } +} diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index a6b6699..6f94e4b 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -45,9 +45,15 @@ Page { SilicaFlickable { anchors.fill: parent - contentHeight: column.height + PullDownMenu { + MenuItem { + text: qsTr("About") + onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml")) + } + } + Column { id: column -- cgit v1.2.3 From 2441492fa9e64f1782395f64015194b486c67808 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 21 Jul 2014 00:11:39 +0200 Subject: Implemented SilentWhenConnected --- daemon/manager.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ daemon/manager.h | 4 ++++ 2 files changed, 56 insertions(+) diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 3214cdc..e97da41 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -50,6 +50,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(dbus, SIGNAL(pebbleChanged()), adaptor, SIGNAL(pebbleChanged())); connect(watch, SIGNAL(connectedChanged()), adaptor, SIGNAL(connectedChanged())); + QString currentProfile = getCurrentProfile(); + defaultProfile = currentProfile.isEmpty() ? "ambience" : currentProfile; + connect(watch, SIGNAL(connectedChanged()), SLOT(applyProfile())); + // Music Control interface session.connect("", "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "PropertiesChanged", @@ -61,6 +65,7 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan void Manager::onSettingChanged(const QString &key) { logger()->debug() << __FUNCTION__ << key << ":" << settings->property(qPrintable(key)); + if (key == "silentWhenConnected") applyProfile(); } void Manager::onSettingsChanged() @@ -269,3 +274,50 @@ void Manager::setMprisMetadata(QVariantMap metadata) mprisMetadata = metadata; emit mprisMetadataChanged(mprisMetadata); } + +QString Manager::getCurrentProfile() +{ + QDBusReply profile = QDBusConnection::sessionBus().call( + QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile")); + if (profile.isValid()) { + QString currentProfile = profile.value(); + logger()->debug() << "Got profile" << currentProfile; + return currentProfile; + } + + logger()->error() << profile.error().message(); + return QString(); +} + +void Manager::applyProfile() +{ + QString currentProfile = getCurrentProfile(); + QString newProfile; + + if (settings->property("silentWhenConnected").toBool()) { + if (watch->isConnected() && currentProfile != "silent") { + newProfile = "silent"; + defaultProfile = currentProfile; + } + if (!watch->isConnected() && currentProfile == "silent" && defaultProfile != "silent") { + newProfile = defaultProfile; + } + } + else if (currentProfile != defaultProfile) { + newProfile = defaultProfile; + } + + if (!newProfile.isEmpty()) { + QDBusReply res = QDBusConnection::sessionBus().call( + QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "set_profile") + << newProfile); + if (res.isValid()) { + if (!res.value()) { + logger()->error() << "Unable to set profile" << newProfile; + } + } + else { + logger()->error() << res.error().message(); + } + } +} diff --git a/daemon/manager.h b/daemon/manager.h index 64dbcce..89b8e2b 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -47,6 +47,8 @@ class Manager : QContactDetailFilter numberFilter; GroupManager *conversations; + QString defaultProfile; + QString lastSeenMpris; public: @@ -54,6 +56,7 @@ public: Q_INVOKABLE QString findPersonByNumber(QString number); Q_INVOKABLE void processUnreadMessages(GroupObject *group); + Q_INVOKABLE QString getCurrentProfile(); Q_INVOKABLE QString mpris(); QVariantMap mprisMetadata; QVariantMap getMprisMetadata() { return mprisMetadata; } @@ -63,6 +66,7 @@ signals: public slots: void hangupAll(); + void applyProfile(); protected slots: void onSettingChanged(const QString &key); -- cgit v1.2.3 From 611f043655312c038351fae57b47fa42aeedfbef Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 21 Jul 2014 00:27:43 +0200 Subject: Release 0.7 --- rpm/pebble.spec | 2 +- rpm/pebble.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm/pebble.spec b/rpm/pebble.spec index 01a66e1..186cca5 100644 --- a/rpm/pebble.spec +++ b/rpm/pebble.spec @@ -13,7 +13,7 @@ Name: pebble %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Support for Pebble watch in SailfishOS -Version: 0.6 +Version: 0.7 Release: 1 Group: Qt/Qt License: BSD diff --git a/rpm/pebble.yaml b/rpm/pebble.yaml index 1bb3352..8bab167 100644 --- a/rpm/pebble.yaml +++ b/rpm/pebble.yaml @@ -1,6 +1,6 @@ Name: pebble Summary: Support for Pebble watch in SailfishOS -Version: 0.6 +Version: 0.7 Release: 1 Group: Qt/Qt URL: http://getpebble.com/ -- cgit v1.2.3 From 9f8db04d6059e0b220e36a064d694a1b0649f5f0 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 21 Jul 2014 13:20:43 +0200 Subject: Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bfd2f55..82b3e77 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Features * Voice Calls notification and control * SMS, IM Messages forwarding * MPRIS compatible media player support +* Set "silent" profile when watch is connected * daemon management app * "org.pebbled" DBus interface -- cgit v1.2.3