diff options
| -rw-r--r-- | app/app.pro | 2 | ||||
| -rw-r--r-- | app/pebbledinterface.cpp | 41 | ||||
| -rw-r--r-- | app/pebbledinterface.h | 7 | ||||
| -rw-r--r-- | app/qml/pages/AboutPage.qml | 2 | ||||
| -rw-r--r-- | app/qml/pages/AppConfigPage.qml (renamed from app/qml/pages/WebViewPage.qml) | 15 | ||||
| -rw-r--r-- | app/qml/pages/WatchPage.qml | 30 | ||||
| -rw-r--r-- | app/qml/pebble.qml | 5 | ||||
| -rw-r--r-- | daemon/jskitmanager.cpp | 4 | ||||
| -rw-r--r-- | daemon/manager.cpp | 6 | ||||
| -rw-r--r-- | daemon/manager.h | 3 | ||||
| -rw-r--r-- | org.pebbled.Watch.xml | 5 |
11 files changed, 88 insertions, 32 deletions
diff --git a/app/app.pro b/app/app.pro index e0ff449..ddf2dba 100644 --- a/app/app.pro +++ b/app/app.pro @@ -25,4 +25,4 @@ OTHER_FILES += \ qml/images/* \ pebble.desktop \ pebble.png \ - qml/pages/WebViewPage.qml + qml/pages/AppConfigPage.qml diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp index fb937f2..0aceaa0 100644 --- a/app/pebbledinterface.cpp +++ b/app/pebbledinterface.cpp @@ -3,7 +3,7 @@ static const QString PEBBLED_SYSTEMD_UNIT("pebbled.service"); static const QString PEBBLED_DBUS_SERVICE("org.pebbled"); -static const QString PEBBLED_DBUS_PATH("/org/pebbled/watch"); +static const QString PEBBLED_DBUS_PATH("/org/pebbled/Watch"); static const QString PEBBLED_DBUS_IFACE("org.pebbled.Watch"); PebbledInterface::PebbledInterface(QObject *parent) : @@ -22,6 +22,8 @@ PebbledInterface::PebbledInterface(QObject *parent) : this, &PebbledInterface::addressChanged); connect(watch, &OrgPebbledWatchInterface::ConnectedChanged, this, &PebbledInterface::connectedChanged); + connect(watch, &OrgPebbledWatchInterface::AppUuidChanged, + this, &PebbledInterface::appUuidChanged); // simulate connected change on active changed // as the daemon might not had a chance to send 'connectedChanged' @@ -67,7 +69,7 @@ void PebbledInterface::getUnitProperties() void PebbledInterface::onPropertiesChanged(QString interface, QMap<QString,QVariant> changed, QStringList invalidated) { - qDebug() << __FUNCTION__ << interface << changed << invalidated; + qDebug() << Q_FUNC_INFO << interface << changed << invalidated; if (interface != "org.freedesktop.systemd1.Unit") return; if (invalidated.contains("UnitFileState") || invalidated.contains("ActiveState")) getUnitProperties(); @@ -75,7 +77,7 @@ void PebbledInterface::onPropertiesChanged(QString interface, QMap<QString,QVari bool PebbledInterface::enabled() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return unitProperties["UnitFileState"].toString() == "enabled"; } @@ -95,7 +97,7 @@ void PebbledInterface::setEnabled(bool enabled) bool PebbledInterface::active() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return unitProperties["ActiveState"].toString() == "active"; } @@ -110,54 +112,61 @@ void PebbledInterface::setActive(bool active) bool PebbledInterface::connected() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->connected(); } QString PebbledInterface::name() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->name(); } QString PebbledInterface::address() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->address(); } +QString PebbledInterface::appUuid() const +{ + qDebug() << Q_FUNC_INFO; + return watch->appUuid(); +} + void PebbledInterface::ping() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Ping(66); } void PebbledInterface::time() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->SyncTime(); } void PebbledInterface::disconnect() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Disconnect(); } void PebbledInterface::reconnect() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Reconnect(); } -QUrl PebbledInterface::configureApp(const QUuid &uuid) +QUrl PebbledInterface::configureApp(const QString &uuid) { - qDebug() << __FUNCTION__ << uuid; - QString url = watch->StartAppConfiguration(uuid.toString()); + qDebug() << Q_FUNC_INFO << uuid; + QString url = watch->StartAppConfiguration(uuid); return QUrl(url); } -void PebbledInterface::setAppConfiguration(const QUuid &uuid, const QString &data) +void PebbledInterface::setAppConfiguration(const QString &uuid, const QString &data) { - watch->SendAppConfigurationData(uuid.toString(), data); + qDebug() << Q_FUNC_INFO << uuid << data; + watch->SendAppConfigurationData(uuid, data); } diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h index 78724ad..f506e67 100644 --- a/app/pebbledinterface.h +++ b/app/pebbledinterface.h @@ -15,6 +15,7 @@ class PebbledInterface : public QObject Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString address READ address NOTIFY addressChanged) + Q_PROPERTY(QString appUuid READ appUuid NOTIFY appUuidChanged) public: explicit PebbledInterface(QObject *parent = 0); @@ -24,6 +25,7 @@ public: bool connected() const; QString name() const; QString address() const; + QString appUuid() const; signals: void enabledChanged(); @@ -31,6 +33,7 @@ signals: void connectedChanged(); void nameChanged(); void addressChanged(); + void appUuidChanged(); public slots: void setEnabled(bool); @@ -40,8 +43,8 @@ public slots: void disconnect(); void reconnect(); - QUrl configureApp(const QUuid &uuid); - void setAppConfiguration(const QUuid &uuid, const QString &data); + QUrl configureApp(const QString &uuid); + void setAppConfiguration(const QString &uuid, const QString &data); private slots: void getUnitProperties(); diff --git a/app/qml/pages/AboutPage.qml b/app/qml/pages/AboutPage.qml index bec1031..8fd009e 100644 --- a/app/qml/pages/AboutPage.qml +++ b/app/qml/pages/AboutPage.qml @@ -40,7 +40,7 @@ Page { anchors { left: parent.left right: parent.right - margins: Theme.paddingSmall + margins: Theme.paddingMedium } font.pixelSize: Theme.fontSizeTiny horizontalAlignment: Text.AlignJustify diff --git a/app/qml/pages/WebViewPage.qml b/app/qml/pages/AppConfigPage.qml index 2c6fcf0..8fb31ca 100644 --- a/app/qml/pages/WebViewPage.qml +++ b/app/qml/pages/AppConfigPage.qml @@ -4,21 +4,26 @@ import QtWebKit 3.0 import Sailfish.Silica 1.0 Page { - id: webviewPage + id: appConfigPage property alias url: webview.url + property string uuid SilicaWebView { id: webview anchors.fill: parent + header: PageHeader { + title: "Configuring " + uuid + } + onNavigationRequested: { - console.log("navigation requested to " + request.url); - var url = request.url.toString() + console.log("appconfig navigation requested to " + request.url); + var url = request.url.toString(); if (/^pebblejs:\/\/close/.exec(url)) { var data = decodeURI(url.substring(17)); - console.log("match with pebble close regexp. data: " + data); - pebbled.webviewClosed(data); + console.log("appconfig requesting close; data: " + data); + pebbled.setAppConfiguration(uuid, data); pageStack.pop(); request.action = WebView.IgnoreRequest; } else { diff --git a/app/qml/pages/WatchPage.qml b/app/qml/pages/WatchPage.qml index 90e5ec9..8169507 100644 --- a/app/qml/pages/WatchPage.qml +++ b/app/qml/pages/WatchPage.qml @@ -77,6 +77,36 @@ Page { } } + + Label { + text: qsTr("App configuration") + font.family: Theme.fontFamilyHeading + color: Theme.highlightColor + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + } + + Button { + text: "Configure current app" + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingLarge + } + onClicked: { + var uuid = pebbled.appUuid; + console.log("going to configureApp " + uuid); + var url = pebbled.configureApp(uuid); + console.log("obtained configure URL " + url); + if (url) { + pageStack.push(Qt.resolvedUrl("AppConfigPage.qml"), { + url: url, + uuid: uuid + }); + } + } + } + } } } diff --git a/app/qml/pebble.qml b/app/qml/pebble.qml index 2ff0839..da3bfb5 100644 --- a/app/qml/pebble.qml +++ b/app/qml/pebble.qml @@ -41,10 +41,5 @@ ApplicationWindow PebbledInterface { id: pebbled - - onOpenUrl: { - console.log("got open url: " + url); - pageStack.push(Qt.resolvedUrl("pages/WebViewPage.qml"), {url: url}); - } } } diff --git a/daemon/jskitmanager.cpp b/daemon/jskitmanager.cpp index 9efc5c8..e1e4073 100644 --- a/daemon/jskitmanager.cpp +++ b/daemon/jskitmanager.cpp @@ -33,6 +33,8 @@ void JSKitManager::showConfiguration() { if (_engine) { _jspebble->invokeCallbacks("showConfiguration"); + } else { + logger()->warn() << "requested to show configuration, but JS engine is not running"; } } @@ -43,6 +45,8 @@ void JSKitManager::handleWebviewClosed(const QString &result) eventObj.setProperty("response", _engine->toScriptValue(result)); _jspebble->invokeCallbacks("webviewclosed", QJSValueList({eventObj})); + } else { + logger()->warn() << "webview closed event, but JS engine is not running"; } } diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 0666de0..1fc8a20 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -61,7 +61,7 @@ Manager::Manager(Settings *settings, QObject *parent) : QDBusConnection session = QDBusConnection::sessionBus(); new WatchAdaptor(proxy); - session.registerObject("/org/pebbled/watch", proxy); + session.registerObject("/org/pebbled/Watch", proxy); session.registerService("org.pebbled"); connect(dbus, &DBusConnector::pebbleChanged, proxy, &PebbledProxy::NameChanged); @@ -399,6 +399,7 @@ void Manager::onAppMessage(const QUuid &uuid, const QVariantMap &data) void Manager::onAppOpened(const QUuid &uuid) { currentAppUuid = uuid; + emit proxy->AppUuidChanged(); emit proxy->AppOpened(uuid.toString()); } @@ -406,6 +407,7 @@ void Manager::onAppClosed(const QUuid &uuid) { currentAppUuid = QUuid(); emit proxy->AppClosed(uuid.toString()); + emit proxy->AppUuidChanged(); } bool PebbledProxy::SendAppMessage(const QString &uuid, const QVariantMap &data) { @@ -468,5 +470,7 @@ QString PebbledProxy::StartAppConfiguration(const QString &uuid) { manager()->js->showConfiguration(); + // Note that the above signal handler _might_ have been already called by this point. + return QString(); // This return value should never be used. } diff --git a/daemon/manager.h b/daemon/manager.h index f099aac..22382b8 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -117,6 +117,7 @@ class PebbledProxy : public QObject, protected QDBusContext Q_PROPERTY(QString Name READ Name NOTIFY NameChanged) Q_PROPERTY(QString Address READ Address NOTIFY AddressChanged) Q_PROPERTY(bool Connected READ Connected NOTIFY ConnectedChanged) + Q_PROPERTY(QString AppUuid READ AppUuid NOTIFY AppUuidChanged) inline Manager* manager() const { return static_cast<Manager*>(parent()); } inline QVariantMap pebble() const { return manager()->dbus->pebble(); } @@ -127,6 +128,7 @@ public: inline QString Name() const { return pebble()["Name"].toString(); } inline QString Address() const { return pebble()["Address"].toString(); } inline bool Connected() const { return manager()->watch->isConnected(); } + inline QString AppUuid() const { return manager()->currentAppUuid.toString(); } public slots: inline void Disconnected() { manager()->watch->disconnect(); } @@ -148,6 +150,7 @@ signals: void NameChanged(); void AddressChanged(); void ConnectedChanged(); + void AppUuidChanged(); void AppMessage(const QString &uuid, const QVariantMap &data); void AppOpened(const QString &uuid); void AppClosed(const QString &uuid); diff --git a/org.pebbled.Watch.xml b/org.pebbled.Watch.xml index 11f20b7..759a6db 100644 --- a/org.pebbled.Watch.xml +++ b/org.pebbled.Watch.xml @@ -1,15 +1,18 @@ <?xml version="1.0"?> <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/org/pebbled/watch"> +<node name="/org/pebbled/Watch"> <interface name="org.pebbled.Watch"> <property name="Name" type="s" access="read"/> <property name="Address" type="s" access="read"/> <property name="Connected" type="b" access="read"/> + <property name="AppUuid" type="s" access="read"/> <!-- Qt does not yet support property changed signals, so we fake them. --> <signal name="NameChanged"/> <signal name="AddressChanged"/> <signal name="ConnectedChanged"/> + <signal name="AppUuidChanged"/> + <method name="Disconnect"/> <method name="Reconnect"/> <method name="Ping"> |
