Merge lp:~bhdouglass/rockwork/appsettings into lp:rockwork

Proposed by Brian Douglass
Status: Merged
Merged at revision: 33
Proposed branch: lp:~bhdouglass/rockwork/appsettings
Merge into: lp:rockwork
Diff against target: 999 lines (+348/-54)
27 files modified
manifest.json.in (+2/-1)
po/rockwork.mzanetti.pot (+22/-18)
rockwork/AppSettingsPage.qml (+82/-0)
rockwork/InstalledAppsPage.qml (+12/-1)
rockwork/Main.qml (+0/-2)
rockwork/MainMenuPage.qml (+9/-0)
rockwork/applicationsmodel.cpp (+31/-0)
rockwork/applicationsmodel.h (+12/-1)
rockwork/main.cpp (+0/-1)
rockwork/pebble.cpp (+14/-1)
rockwork/pebble.h (+3/-0)
rockwork/rockwork.pro (+3/-2)
rockwork/rockwork.qrc (+1/-0)
rockwork/rockwork.url-dispatcher (+5/-0)
rockworkd/dbusinterface.cpp (+12/-3)
rockworkd/dbusinterface.h (+3/-0)
rockworkd/libpebble/appinfo.cpp (+20/-1)
rockworkd/libpebble/appinfo.h (+1/-0)
rockworkd/libpebble/appmsgmanager.cpp (+41/-16)
rockworkd/libpebble/appmsgmanager.h (+3/-1)
rockworkd/libpebble/jskitmanager.cpp (+18/-0)
rockworkd/libpebble/jskitmanager.h (+4/-1)
rockworkd/libpebble/jskitobjects.cpp (+16/-1)
rockworkd/libpebble/jskitobjects.h (+3/-0)
rockworkd/libpebble/pebble.cpp (+25/-1)
rockworkd/libpebble/pebble.h (+3/-0)
rockworkd/libpebble/watchconnection.cpp (+3/-3)
To merge this branch: bzr merge lp:~bhdouglass/rockwork/appsettings
Reviewer Review Type Date Requested Status
Michael Zanetti Pending
Review via email: mp+281477@code.launchpad.net

Description of the change

App settings hookups

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manifest.json.in'
2--- manifest.json.in 2015-12-17 23:33:39 +0000
3+++ manifest.json.in 2016-01-03 06:41:00 +0000
4@@ -6,7 +6,8 @@
5 "hooks": {
6 "rockwork": {
7 "apparmor": "rockwork/rockwork.apparmor",
8- "desktop": "rockwork/rockwork.desktop"
9+ "desktop": "rockwork/rockwork.desktop",
10+ "urls": "rockwork/rockwork.url-dispatcher"
11 }
12 },
13 "version": "@VERSION@",
14
15=== modified file 'po/rockwork.mzanetti.pot'
16--- po/rockwork.mzanetti.pot 2016-01-03 02:45:11 +0000
17+++ po/rockwork.mzanetti.pot 2016-01-03 06:41:00 +0000
18@@ -8,7 +8,7 @@
19 msgstr ""
20 "Project-Id-Version: PACKAGE VERSION\n"
21 "Report-Msgid-Bugs-To: \n"
22-"POT-Creation-Date: 2016-01-03 01:54+0100\n"
23+"POT-Creation-Date: 2016-01-03 05:55+0000\n"
24 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
25 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
26 "Language-Team: LANGUAGE <LL@li.org>\n"
27@@ -17,74 +17,78 @@
28 "Content-Type: text/plain; charset=CHARSET\n"
29 "Content-Transfer-Encoding: 8bit\n"
30
31-#: /home/micha/Develop/upebble/rockwork/AppStorePage.qml:8
32+#: /home/vagrant/appsettings/rockwork/AppSettingsPage.qml:13
33+msgid "App Settings"
34+msgstr ""
35+
36+#: /home/vagrant/appsettings/rockwork/AppStorePage.qml:8
37 msgid "Add new watchapp"
38 msgstr ""
39
40-#: /home/micha/Develop/upebble/rockwork/AppStorePage.qml:8
41+#: /home/vagrant/appsettings/rockwork/AppStorePage.qml:8
42 msgid "Add new watchface"
43 msgstr ""
44
45-#: /home/micha/Develop/upebble/rockwork/AppStorePage.qml:76
46+#: /home/vagrant/appsettings/rockwork/AppStorePage.qml:76
47 msgid "Previous"
48 msgstr ""
49
50-#: /home/micha/Develop/upebble/rockwork/AppStorePage.qml:84
51+#: /home/vagrant/appsettings/rockwork/AppStorePage.qml:84
52 msgid "Next"
53 msgstr ""
54
55-#: /home/micha/Develop/upebble/rockwork/InstalledAppsPage.qml:8
56+#: /home/vagrant/appsettings/rockwork/InstalledAppsPage.qml:8
57 msgid "Apps & Watchfaces"
58 msgstr ""
59
60-#: /home/micha/Develop/upebble/rockwork/InstalledAppsPage.qml:8
61+#: /home/vagrant/appsettings/rockwork/InstalledAppsPage.qml:8
62 msgid "Apps"
63 msgstr ""
64
65-#: /home/micha/Develop/upebble/rockwork/InstalledAppsPage.qml:8
66+#: /home/vagrant/appsettings/rockwork/InstalledAppsPage.qml:8
67 msgid "Watchfaces"
68 msgstr ""
69
70-#: /home/micha/Develop/upebble/rockwork/MainMenuPage.qml:20
71+#: /home/vagrant/appsettings/rockwork/MainMenuPage.qml:20
72 msgid "Manage notifications"
73 msgstr ""
74
75-#: /home/micha/Develop/upebble/rockwork/MainMenuPage.qml:26
76+#: /home/vagrant/appsettings/rockwork/MainMenuPage.qml:26
77 msgid "Manage Apps"
78 msgstr ""
79
80-#: /home/micha/Develop/upebble/rockwork/MainMenuPage.qml:33
81+#: /home/vagrant/appsettings/rockwork/MainMenuPage.qml:33
82 msgid "Manage Watchfaces"
83 msgstr ""
84
85-#: /home/micha/Develop/upebble/rockwork/NotificationsPage.qml:7
86+#: /home/vagrant/appsettings/rockwork/NotificationsPage.qml:7
87 msgid "Notifications"
88 msgstr ""
89
90-#: /home/micha/Develop/upebble/rockwork/NotificationsPage.qml:26
91+#: /home/vagrant/appsettings/rockwork/NotificationsPage.qml:26
92 msgid ""
93 "Entries here will appear as notifications keep coming. Selected "
94 "notifications will be shown on your Pebble smartwatch."
95 msgstr ""
96
97-#: /home/micha/Develop/upebble/rockwork/PebblesPage.qml:6
98+#: /home/vagrant/appsettings/rockwork/PebblesPage.qml:6
99 msgid "Manage Pebble Watches"
100 msgstr ""
101
102-#: /home/micha/Develop/upebble/rockwork/PebblesPage.qml:36
103+#: /home/vagrant/appsettings/rockwork/PebblesPage.qml:36
104 msgid "Connected"
105 msgstr ""
106
107-#: /home/micha/Develop/upebble/rockwork/PebblesPage.qml:36
108+#: /home/vagrant/appsettings/rockwork/PebblesPage.qml:36
109 msgid "Disconnected"
110 msgstr ""
111
112-#: /home/micha/Develop/upebble/rockwork/PebblesPage.qml:55
113+#: /home/vagrant/appsettings/rockwork/PebblesPage.qml:55
114 msgid ""
115 "No Pebble smartwatches configured yet. Please connect your Pebble watch "
116 "using the system settings."
117 msgstr ""
118
119-#: /home/micha/Develop/upebble/rockwork/PebblesPage.qml:62
120+#: /home/vagrant/appsettings/rockwork/PebblesPage.qml:62
121 msgid "Open system settings"
122 msgstr ""
123
124=== added file 'rockwork/AppSettingsPage.qml'
125--- rockwork/AppSettingsPage.qml 1970-01-01 00:00:00 +0000
126+++ rockwork/AppSettingsPage.qml 2016-01-03 06:41:00 +0000
127@@ -0,0 +1,82 @@
128+import QtQuick 2.4
129+import Ubuntu.Web 0.2
130+import Ubuntu.Components 1.3
131+import com.canonical.Oxide 1.0 as Oxide
132+
133+Page {
134+ id: settings
135+
136+ property string uuid;
137+ property string url;
138+ property var pebble;
139+
140+ title: i18n.tr("App Settings")
141+
142+ WebContext {
143+ id: webcontext
144+ userAgent: "Mozilla/5.0 (Linux; Android 5.0; Nexus 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.102 Mobile Safari/537.36 Ubuntu Touch (RockWork)"
145+ }
146+
147+ WebView {
148+ id: webview
149+ anchors {
150+ fill: parent
151+ bottom: parent.bottom
152+ }
153+ width: parent.width
154+ height: parent.height
155+
156+ context: webcontext
157+ url: settings.url
158+ preferences.localStorageEnabled: true
159+ preferences.appCacheEnabled: true
160+ preferences.javascriptCanAccessClipboard: true
161+
162+ function navigationRequestedDelegate(request) {
163+ //The pebblejs:// protocol is handeled by the urihandler, as it appears we can't intercept it
164+
165+ var url = request.url.toString();
166+ console.log(url, url.substring(0, 16));
167+ if (url.substring(0, 16) == 'pebblejs://close') {
168+ pebble.configurationClosed(settings.uuid, url);
169+ request.action = Oxide.NavigationRequest.ActionReject;
170+ pageStack.pop();
171+ }
172+ else {
173+ Qt.openUrlExternally(url);
174+ request.action = Oxide.NavigationRequest.ActionReject;
175+ }
176+ }
177+
178+ Component.onCompleted: {
179+ preferences.localStorageEnabled = true;
180+ }
181+ }
182+
183+ ProgressBar {
184+ height: units.dp(3)
185+ anchors {
186+ left: parent.left
187+ right: parent.right
188+ top: parent.top
189+ }
190+
191+ showProgressPercentage: false
192+ value: (webview.loadProgress / 100)
193+ visible: (webview.loading && !webview.lastLoadStopped)
194+ }
195+
196+ Connections {
197+ target: UriHandler
198+ onOpened: {
199+ if (uris && uris[0] && uris[0].length) {
200+ var url = uris[0];
201+
202+ if (url.substring(0, 16) == 'pebblejs://close') {
203+ pebble.configurationClosed(settings.uuid, url);
204+ pageStack.pop();
205+ }
206+ }
207+ }
208+ }
209+}
210
211=== modified file 'rockwork/InstalledAppsPage.qml'
212--- rockwork/InstalledAppsPage.qml 2015-12-30 19:15:55 +0000
213+++ rockwork/InstalledAppsPage.qml 2016-01-03 06:41:00 +0000
214@@ -44,6 +44,18 @@
215 ]
216 }
217
218+ trailingActions: ListItemActions {
219+ actions: [
220+ Action {
221+ visible: model.hasSettings
222+ iconName: "settings"
223+ onTriggered: {
224+ pebble.requestConfigurationURL(model.uuid);
225+ }
226+ }
227+ ]
228+ }
229+
230 RowLayout {
231 anchors {
232 fill: parent
233@@ -73,4 +85,3 @@
234 }
235 }
236 }
237-
238
239=== modified file 'rockwork/Main.qml'
240--- rockwork/Main.qml 2015-12-21 03:46:24 +0000
241+++ rockwork/Main.qml 2016-01-03 06:41:00 +0000
242@@ -36,7 +36,5 @@
243 PageStack {
244 id: pageStack
245 Component.onCompleted: push(Qt.resolvedUrl("PebblesPage.qml"));
246-
247 }
248 }
249-
250
251=== modified file 'rockwork/MainMenuPage.qml'
252--- rockwork/MainMenuPage.qml 2015-12-25 14:08:31 +0000
253+++ rockwork/MainMenuPage.qml 2016-01-03 06:41:00 +0000
254@@ -71,4 +71,13 @@
255 }
256 }
257 }
258+
259+ Connections {
260+ target: pebble
261+ onOpenURL: {
262+ if (url) {
263+ pageStack.push(Qt.resolvedUrl("AppSettingsPage.qml"), {uuid: uuid, url: url, pebble: pebble})
264+ }
265+ }
266+ }
267 }
268
269=== modified file 'rockwork/applicationsmodel.cpp'
270--- rockwork/applicationsmodel.cpp 2015-12-21 03:46:24 +0000
271+++ rockwork/applicationsmodel.cpp 2016-01-03 06:41:00 +0000
272@@ -18,6 +18,8 @@
273 switch (role) {
274 case RoleId:
275 return m_apps.at(index.row())->id();
276+ case RoleUuid:
277+ return m_apps.at(index.row())->uuid();
278 case RoleName:
279 return m_apps.at(index.row())->name();
280 case RoleIcon:
281@@ -26,7 +28,12 @@
282 return m_apps.at(index.row())->vendor();
283 case RoleVersion:
284 return m_apps.at(index.row())->version();
285+ case RoleIsWatchFace:
286+ return m_apps.at(index.row())->isWatchFace();
287+ case RoleHasSettings:
288+ return m_apps.at(index.row())->hasSettings();
289 }
290+
291 return QVariant();
292 }
293
294@@ -34,10 +41,14 @@
295 {
296 QHash<int, QByteArray> roles;
297 roles.insert(RoleId, "id");
298+ roles.insert(RoleUuid, "uuid");
299 roles.insert(RoleName, "name");
300 roles.insert(RoleIcon, "icon");
301 roles.insert(RoleVendor, "vendor");
302 roles.insert(RoleVersion, "version");
303+ roles.insert(RoleIsWatchFace, "isWatchFace");
304+ roles.insert(RoleHasSettings, "hasSettings");
305+
306 return roles;
307 }
308
309@@ -74,6 +85,11 @@
310 return m_id;
311 }
312
313+QString AppItem::uuid() const
314+{
315+ return m_uuid;
316+}
317+
318 QString AppItem::name() const
319 {
320 return m_name;
321@@ -99,11 +115,21 @@
322 return m_isWatchFace;
323 }
324
325+bool AppItem::hasSettings() const
326+{
327+ return m_hasSettings;
328+}
329+
330 void AppItem::setId(const QString &id)
331 {
332 m_id = id;
333 }
334
335+void AppItem::setUuid(const QString &uuid)
336+{
337+ m_uuid = uuid;
338+}
339+
340 void AppItem::setName(const QString &name)
341 {
342 m_name = name;
343@@ -128,3 +154,8 @@
344 {
345 m_isWatchFace = isWatchFace;
346 }
347+
348+void AppItem::setHasSettings(bool hasSettings)
349+{
350+ m_hasSettings = hasSettings;
351+}
352
353=== modified file 'rockwork/applicationsmodel.h'
354--- rockwork/applicationsmodel.h 2015-12-21 03:46:24 +0000
355+++ rockwork/applicationsmodel.h 2016-01-03 06:41:00 +0000
356@@ -10,36 +10,44 @@
357 {
358 Q_OBJECT
359 Q_PROPERTY(QString id MEMBER m_id)
360+ Q_PROPERTY(QString uuid MEMBER m_uuid)
361 Q_PROPERTY(QString name MEMBER m_name)
362 Q_PROPERTY(QString icon MEMBER m_icon)
363 Q_PROPERTY(QString vendor MEMBER m_vendor)
364 Q_PROPERTY(QString version MEMBER m_version)
365 Q_PROPERTY(bool isWatchFace MEMBER m_isWatchFace)
366+ Q_PROPERTY(bool hasSettings MEMBER m_hasSettings)
367
368 public:
369 AppItem(QObject *parent = 0);
370
371 QString id() const;
372+ QString uuid() const;
373 QString name() const;
374 QString icon() const;
375 QString vendor() const;
376 QString version() const;
377 bool isWatchFace() const;
378+ bool hasSettings() const;
379
380 void setId(const QString &id);
381+ void setUuid(const QString &uuid);
382 void setName(const QString &name);
383 void setIcon(const QString &icon);
384 void setVendor(const QString &vendor);
385 void setVersion(const QString &version);
386 void setIsWatchFace(bool isWatchFace);
387+ void setHasSettings(bool hasSettings);
388
389 private:
390 QString m_id;
391+ QString m_uuid;
392 QString m_name;
393 QString m_icon;
394 QString m_vendor;
395 QString m_version;
396 bool m_isWatchFace = false;
397+ bool m_hasSettings = false;
398 };
399
400 class ApplicationsModel : public QAbstractListModel
401@@ -48,10 +56,13 @@
402 public:
403 enum Roles {
404 RoleId,
405+ RoleUuid,
406 RoleName,
407 RoleIcon,
408 RoleVendor,
409- RoleVersion
410+ RoleVersion,
411+ RoleIsWatchFace,
412+ RoleHasSettings
413 };
414
415 ApplicationsModel(QObject *parent = nullptr);
416
417=== modified file 'rockwork/main.cpp'
418--- rockwork/main.cpp 2015-12-30 19:15:55 +0000
419+++ rockwork/main.cpp 2016-01-03 06:41:00 +0000
420@@ -31,4 +31,3 @@
421 view.show();
422 return app.exec();
423 }
424-
425
426=== modified file 'rockwork/pebble.cpp'
427--- rockwork/pebble.cpp 2015-12-30 19:15:55 +0000
428+++ rockwork/pebble.cpp 2016-01-03 06:41:00 +0000
429@@ -14,6 +14,7 @@
430 QDBusConnection::sessionBus().connect("org.rockwork", path.path(), "org.rockwork.Pebble", "Connected", this, SLOT(pebbleConnected()));
431 QDBusConnection::sessionBus().connect("org.rockwork", path.path(), "org.rockwork.Pebble", "Disconnected", this, SLOT(pebbleDisconnected()));
432 QDBusConnection::sessionBus().connect("org.rockwork", path.path(), "org.rockwork.Pebble", "InstalledAppsChanged", this, SLOT(refreshApps()));
433+ QDBusConnection::sessionBus().connect("org.rockwork", path.path(), "org.rockwork.Pebble", "OpenURL", this, SIGNAL(openURL(const QString&, const QString&)));
434
435 dataChanged();
436 refreshApps();
437@@ -54,6 +55,16 @@
438 return m_installedApps;
439 }
440
441+void Pebble::configurationClosed(const QString &uuid, const QString &url)
442+{
443+ m_iface->call("ConfigurationClosed", uuid, url.mid(17));
444+}
445+
446+void Pebble::requestConfigurationURL(const QString &id)
447+{
448+ m_iface->call("ConfigurationURL", id);
449+}
450+
451 void Pebble::removeApp(const QString &id)
452 {
453 qDebug() << "should remove app" << id;
454@@ -138,12 +149,14 @@
455 foreach (const QVariant &v, appList) {
456 AppItem *app = new AppItem(this);
457 app->setId(v.toMap().value("uuid").toString());
458+ app->setUuid(v.toMap().value("uuid").toString());
459 app->setName(v.toMap().value("name").toString());
460 app->setIcon(v.toMap().value("icon").toString());
461 app->setVendor(v.toMap().value("vendor").toString());
462 app->setVersion(v.toMap().value("version").toString());
463 app->setIsWatchFace(v.toMap().value("watchface").toBool());
464- qDebug() << "inserting app" << app->name();
465+ app->setHasSettings(v.toMap().value("hasSettings").toBool());
466+
467 m_installedApps->insert(app);
468 }
469 }
470
471=== modified file 'rockwork/pebble.h'
472--- rockwork/pebble.h 2015-12-30 19:15:55 +0000
473+++ rockwork/pebble.h 2016-01-03 06:41:00 +0000
474@@ -29,9 +29,12 @@
475 public slots:
476 void removeApp(const QString &id);
477 void installApp(const QString &id);
478+ void requestConfigurationURL(const QString &id);
479+ void configurationClosed(const QString &uuid, const QString &url);
480
481 signals:
482 void connectedChanged();
483+ void openURL(const QString &uuid, const QString &url);
484
485 private:
486 QVariant fetchProperty(const QString &propertyName);
487
488=== modified file 'rockwork/rockwork.pro'
489--- rockwork/rockwork.pro 2015-12-30 19:15:55 +0000
490+++ rockwork/rockwork.pro 2016-01-03 06:41:00 +0000
491@@ -33,7 +33,8 @@
492
493 CONF_FILES += rockwork.apparmor \
494 rockwork.svg \
495- rockwork.desktop
496+ rockwork.desktop \
497+ rockwork.url-dispatcher
498
499 AP_TEST_FILES += tests/autopilot/run \
500 $$files(tests/*.py,true)
501@@ -49,7 +50,7 @@
502 config_files.files += $${CONF_FILES}
503 INSTALLS+=config_files
504
505-#install the desktop file, a translated version is
506+#install the desktop file, a translated version is
507 #automatically created in the build directory
508 desktop_file.path = /rockwork
509 desktop_file.files = $$OUT_PWD/rockwork.desktop
510
511=== modified file 'rockwork/rockwork.qrc'
512--- rockwork/rockwork.qrc 2015-12-30 19:15:55 +0000
513+++ rockwork/rockwork.qrc 2016-01-03 06:41:00 +0000
514@@ -5,6 +5,7 @@
515 <file>PebblesPage.qml</file>
516 <file>InstalledAppsPage.qml</file>
517 <file>MainMenuPage.qml</file>
518+ <file>AppSettingsPage.qml</file>
519 <file>AppStorePage.qml</file>
520 </qresource>
521 </RCC>
522
523=== added file 'rockwork/rockwork.url-dispatcher'
524--- rockwork/rockwork.url-dispatcher 1970-01-01 00:00:00 +0000
525+++ rockwork/rockwork.url-dispatcher 2016-01-03 06:41:00 +0000
526@@ -0,0 +1,5 @@
527+[
528+ {
529+ "protocol": "pebblejs"
530+ }
531+]
532
533=== modified file 'rockworkd/dbusinterface.cpp'
534--- rockworkd/dbusinterface.cpp 2015-12-30 19:15:55 +0000
535+++ rockworkd/dbusinterface.cpp 2016-01-03 06:41:00 +0000
536@@ -9,6 +9,7 @@
537 connect(pebble, &Pebble::pebbleConnected, this, &DBusPebble::Connected);
538 connect(pebble, &Pebble::pebbleDisconnected, this, &DBusPebble::Disconnected);
539 connect(pebble, &Pebble::installedAppsChanged, this, &DBusPebble::InstalledAppsChanged);
540+ connect(pebble, SIGNAL(openURL(const QString&, const QString&)), this, SIGNAL(OpenURL(const QString&, const QString&)));
541 }
542
543 QString DBusPebble::Address() const
544@@ -52,6 +53,7 @@
545 app.insert("watchface", info.isWatchface());
546 app.insert("version", info.versionLabel());
547 app.insert("uuid", info.uuid().toString());
548+ app.insert("hasSettings", info.hasSettings());
549
550 list.append(app);
551 }
552@@ -63,6 +65,16 @@
553 m_pebble->removeApp(id);
554 }
555
556+void DBusPebble::ConfigurationURL(const QString &uuid)
557+{
558+ m_pebble->requestConfigurationURL(QUuid(uuid));
559+}
560+
561+void DBusPebble::ConfigurationClosed(const QString &uuid, const QString &result)
562+{
563+ m_pebble->configurationClosed(QUuid(uuid), result);
564+}
565+
566 QString DBusPebble::SerialNumber() const
567 {
568 return m_pebble->serialNumber();
569@@ -121,6 +133,3 @@
570 m_dbusPebbles.insert(address, dbusPebble);
571 QDBusConnection::sessionBus().registerObject("/org/rockwork/" + address, dbusPebble, QDBusConnection::ExportAllContents);
572 }
573-
574-
575-
576
577=== modified file 'rockworkd/dbusinterface.h'
578--- rockworkd/dbusinterface.h 2015-12-30 19:15:55 +0000
579+++ rockworkd/dbusinterface.h 2016-01-03 06:41:00 +0000
580@@ -18,6 +18,7 @@
581 void Connected();
582 void Disconnected();
583 void InstalledAppsChanged();
584+ void OpenURL(const QString &uuid, const QString &url);
585
586 public slots:
587 QString Address() const;
588@@ -30,6 +31,8 @@
589 QStringList InstalledAppIds() const;
590 QVariantList InstalledApps() const;
591 void RemoveApp(const QString &id);
592+ void ConfigurationURL(const QString &uuid);
593+ void ConfigurationClosed(const QString &uuid, const QString &result);
594
595 private:
596 Pebble *m_pebble;
597
598=== modified file 'rockworkd/libpebble/appinfo.cpp'
599--- rockworkd/libpebble/appinfo.cpp 2015-12-30 19:15:55 +0000
600+++ rockworkd/libpebble/appinfo.cpp 2016-01-03 06:41:00 +0000
601@@ -44,6 +44,7 @@
602 m_companyName = map.value("companyName").toString();
603 m_versionCode = map.value("versionCode").toInt();
604 m_versionLabel = map.value("versionLabel").toString();
605+ m_capabilities = 0;
606
607 m_isWatchface = map.value("watchapp").toMap().value("watchface").toBool();
608
609@@ -54,6 +55,20 @@
610 }
611 }
612
613+ if (map.contains("capabilities")) {
614+ QList<QVariant> capabilities = map.value("capabilities").toList();
615+
616+ foreach (const QVariant &value, capabilities) {
617+ QString capability = value.toString();
618+ if (capability == "location") {
619+ m_capabilities |= Location;
620+ }
621+ else if (capability == "configurable") {
622+ m_capabilities |= Configurable;
623+ }
624+ }
625+ }
626+
627 QFile jsApp(path + "/pebble-js-app.js");
628 m_isJsKit = jsApp.exists();
629 }
630@@ -117,6 +132,11 @@
631 return m_appKeys;
632 }
633
634+bool AppInfo::hasSettings() const
635+{
636+ return (m_capabilities & Configurable);
637+}
638+
639 AppInfo::Capabilities AppInfo::capabilities() const
640 {
641 return m_capabilities;
642@@ -249,4 +269,3 @@
643 }
644 return 0;
645 }
646-
647
648=== modified file 'rockworkd/libpebble/appinfo.h'
649--- rockworkd/libpebble/appinfo.h 2015-12-30 19:15:55 +0000
650+++ rockworkd/libpebble/appinfo.h 2016-01-03 06:41:00 +0000
651@@ -41,6 +41,7 @@
652 bool isJSKit() const;
653 QHash<QString, int> appKeys() const;
654 Capabilities capabilities() const;
655+ bool hasSettings() const;
656
657 bool hasMenuIcon() const;
658 QImage getMenuIconImage(HardwarePlatform hardwarePlatform) const;
659
660=== modified file 'rockworkd/libpebble/appmsgmanager.cpp'
661--- rockworkd/libpebble/appmsgmanager.cpp 2015-12-30 19:22:54 +0000
662+++ rockworkd/libpebble/appmsgmanager.cpp 2016-01-03 06:41:00 +0000
663@@ -1,13 +1,16 @@
664 #include <QTimer>
665
666+#include "pebble.h"
667 #include "appmsgmanager.h"
668 #include "watchdatareader.h"
669 #include "watchdatawriter.h"
670
671 // TODO D-Bus server for non JS kit apps!!!!
672
673-AppMsgManager::AppMsgManager(AppManager *apps, WatchConnection *connection, QObject *parent)
674- : QObject(parent), apps(apps),
675+AppMsgManager::AppMsgManager(Pebble *pebble, AppManager *apps, WatchConnection *connection)
676+ : QObject(pebble),
677+ m_pebble(pebble),
678+ apps(apps),
679 m_connection(connection), _lastTransactionId(0), _timeout(new QTimer(this))
680 {
681 connect(m_connection, &WatchConnection::watchConnected,
682@@ -113,24 +116,36 @@
683
684 void AppMsgManager::launchApp(const QUuid &uuid)
685 {
686- WatchConnection::Dict dict;
687- dict.insert(1, LauncherActionStart);
688-
689- qDebug() << "Sending message to launcher" << uuid << dict;
690-
691- QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
692- m_connection->writeToPebble(WatchConnection::EndpointLauncher, msg);
693+ if (m_pebble->softwareVersion() < "v3.0") {
694+ WatchConnection::Dict dict;
695+ dict.insert(1, LauncherActionStart);
696+
697+ qDebug() << "Sending start message to launcher" << uuid << dict;
698+ QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
699+ m_connection->writeToPebble(WatchConnection::EndpointLauncher, msg);
700+ }
701+ else {
702+ QByteArray msg = buildLaunchMessage(LauncherActionStart, uuid);
703+ qDebug() << "Sending start message to launcher" << uuid;
704+ m_connection->writeToPebble(WatchConnection::EndpointAppLaunch, msg);
705+ }
706 }
707
708 void AppMsgManager::closeApp(const QUuid &uuid)
709 {
710- WatchConnection::Dict dict;
711- dict.insert(1, LauncherActionStop);
712-
713- qDebug() << "Sending message to launcher" << uuid << dict;
714-
715- QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
716- m_connection->writeToPebble(WatchConnection::EndpointLauncher, msg);
717+ if (m_pebble->softwareVersion() < "v3.0") {
718+ WatchConnection::Dict dict;
719+ dict.insert(1, LauncherActionStop);
720+
721+ qDebug() << "Sending stop message to launcher" << uuid << dict;
722+ QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
723+ m_connection->writeToPebble(WatchConnection::EndpointLauncher, msg);
724+ }
725+ else {
726+ QByteArray msg = buildLaunchMessage(LauncherActionStop, uuid);
727+ qDebug() << "Sending stop message to launcher" << uuid;
728+ m_connection->writeToPebble(WatchConnection::EndpointAppLaunch, msg);
729+ }
730 }
731
732 WatchConnection::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariantMap &data)
733@@ -227,6 +242,16 @@
734 return ba;
735 }
736
737+QByteArray AppMsgManager::buildLaunchMessage(quint8 messageType, const QUuid &uuid)
738+{
739+ QByteArray ba;
740+ WatchDataWriter writer(&ba);
741+ writer.write<quint8>(messageType);
742+ writer.writeUuid(uuid);
743+
744+ return ba;
745+}
746+
747 QByteArray AppMsgManager::buildAckMessage(quint8 transaction)
748 {
749 QByteArray ba(2, Qt::Uninitialized);
750
751=== modified file 'rockworkd/libpebble/appmsgmanager.h'
752--- rockworkd/libpebble/appmsgmanager.h 2015-12-17 05:02:00 +0000
753+++ rockworkd/libpebble/appmsgmanager.h 2016-01-03 06:41:00 +0000
754@@ -24,7 +24,7 @@
755 LauncherActionStop = 0
756 };
757
758- explicit AppMsgManager(AppManager *apps, WatchConnection *connection, QObject *parent);
759+ explicit AppMsgManager(Pebble *pebble, AppManager *apps, WatchConnection *connection);
760
761 void send(const QUuid &uuid, const QVariantMap &data,
762 const std::function<void()> &ackCallback,
763@@ -54,6 +54,7 @@
764 static bool unpackPushMessage(const QByteArray &msg, quint8 *transaction, QUuid *uuid, WatchConnection::Dict *dict);
765
766 static QByteArray buildPushMessage(quint8 transaction, const QUuid &uuid, const WatchConnection::Dict &dict);
767+ static QByteArray buildLaunchMessage(quint8 messageType, const QUuid &uuid);
768 static QByteArray buildAckMessage(quint8 transaction);
769 static QByteArray buildNackMessage(quint8 transaction);
770
771@@ -73,6 +74,7 @@
772 void handleApplicationMessage(const QByteArray &data);
773
774 private:
775+ Pebble *m_pebble;
776 AppManager *apps;
777 WatchConnection *m_connection;
778 QHash<QUuid, MessageHandlerFunc> _handlers;
779
780=== modified file 'rockworkd/libpebble/jskitmanager.cpp'
781--- rockworkd/libpebble/jskitmanager.cpp 2015-12-30 19:15:55 +0000
782+++ rockworkd/libpebble/jskitmanager.cpp 2016-01-03 06:41:00 +0000
783@@ -9,6 +9,7 @@
784 m_pebble(pebble),
785 m_connection(connection), _apps(apps), _appmsg(appmsg), _engine(0)
786 {
787+ m_configurationUuid = QUuid();
788 connect(_appmsg, &AppMsgManager::appStarted, this, &JSKitManager::handleAppStarted);
789 connect(_appmsg, &AppMsgManager::appStopped, this, &JSKitManager::handleAppStopped);
790 }
791@@ -62,6 +63,16 @@
792 }
793 }
794
795+void JSKitManager::setConfigurationId(const QUuid &uuid)
796+{
797+ m_configurationUuid = uuid;
798+}
799+
800+AppInfo JSKitManager::currentApp()
801+{
802+ return _curApp;
803+}
804+
805 void JSKitManager::handleAppStarted(const QUuid &uuid)
806 {
807 qDebug() << "handleAppStarted!!!" << uuid;
808@@ -197,6 +208,13 @@
809
810 // We try to invoke the callbacks even if script parsing resulted in error...
811 _jspebble->invokeCallbacks("ready");
812+
813+ if (m_configurationUuid == _curApp.uuid()) {
814+ qDebug() << "going to launch config for" << m_configurationUuid;
815+ showConfiguration();
816+ }
817+
818+ m_configurationUuid = QUuid();
819 }
820
821 void JSKitManager::stopJsApp()
822
823=== modified file 'rockworkd/libpebble/jskitmanager.h'
824--- rockworkd/libpebble/jskitmanager.h 2015-11-29 14:19:26 +0000
825+++ rockworkd/libpebble/jskitmanager.h 2016-01-03 06:41:00 +0000
826@@ -29,10 +29,12 @@
827
828 void showConfiguration();
829 void handleWebviewClosed(const QString &result);
830+ void setConfigurationId(const QUuid &uuid);
831+ AppInfo currentApp();
832
833 signals:
834 void appNotification(const QUuid &uuid, const QString &title, const QString &body);
835- void appOpenUrl(const QUrl &url);
836+ void openURL(const QString &uuid, const QString &url);
837
838 private slots:
839 void handleAppStarted(const QUuid &uuid);
840@@ -57,6 +59,7 @@
841 QPointer<JSKitConsole> _jsconsole;
842 QPointer<JSKitLocalStorage> _jsstorage;
843 QPointer<JSKitGeolocation> _jsgeo;
844+ QUuid m_configurationUuid;
845 };
846
847 #endif // JSKITMANAGER_H
848
849=== modified file 'rockworkd/libpebble/jskitobjects.cpp'
850--- rockworkd/libpebble/jskitobjects.cpp 2015-12-17 05:03:19 +0000
851+++ rockworkd/libpebble/jskitobjects.cpp 2016-01-03 06:41:00 +0000
852@@ -152,7 +152,7 @@
853 void JSKitPebble::openURL(const QUrl &url)
854 {
855 qDebug() << "opening url" << url.toString();
856- emit _mgr->appOpenUrl(url);
857+ emit _mgr->openURL(_appInfo.uuid().toString(), url.toString());
858 }
859
860 QString JSKitPebble::getAccountToken() const
861@@ -244,6 +244,21 @@
862 qCDebug(l) << msg;
863 }
864
865+void JSKitConsole::warn(const QString &msg)
866+{
867+ qCWarning(l) << msg;
868+}
869+
870+void JSKitConsole::error(const QString &msg)
871+{
872+ qCCritical(l) << msg;
873+}
874+
875+void JSKitConsole::info(const QString &msg)
876+{
877+ qCDebug(l) << msg;
878+}
879+
880 JSKitLocalStorage::JSKitLocalStorage(const QUuid &uuid, QObject *parent)
881 : QObject(parent), _storage(new QSettings(getStorageFileFor(uuid), QSettings::IniFormat, this))
882 {
883
884=== modified file 'rockworkd/libpebble/jskitobjects.h'
885--- rockworkd/libpebble/jskitobjects.h 2015-11-29 14:19:26 +0000
886+++ rockworkd/libpebble/jskitobjects.h 2016-01-03 06:41:00 +0000
887@@ -61,6 +61,9 @@
888 explicit JSKitConsole(QObject *parent=0);
889
890 Q_INVOKABLE void log(const QString &msg);
891+ Q_INVOKABLE void warn(const QString &msg);
892+ Q_INVOKABLE void error(const QString &msg);
893+ Q_INVOKABLE void info(const QString &msg);
894 };
895
896 class JSKitLocalStorage : public QObject
897
898=== modified file 'rockworkd/libpebble/pebble.cpp'
899--- rockworkd/libpebble/pebble.cpp 2016-01-03 02:45:11 +0000
900+++ rockworkd/libpebble/pebble.cpp 2016-01-03 06:41:00 +0000
901@@ -26,17 +26,24 @@
902 m_connection->registerEndpointHandler(WatchConnection::EndpointVersion, this, "pebbleVersionReceived");
903 m_connection->registerEndpointHandler(WatchConnection::EndpointPhoneVersion, this, "phoneVersionAsked");
904 m_connection->registerEndpointHandler(WatchConnection::EndpointDataLogging, this, "logData");
905+
906 m_notificationEndpoint = new NotificationEndpoint(this, m_connection);
907 m_musicEndpoint = new MusicEndpoint(this, m_connection);
908 m_phoneCallEndpoint = new PhoneCallEndpoint(this, m_connection);
909 QObject::connect(m_phoneCallEndpoint, &PhoneCallEndpoint::hangupCall, this, &Pebble::hangupCall);
910+
911 m_appManager = new AppManager(this, m_connection);
912 QObject::connect(m_appManager, &AppManager::appsChanged, this, &Pebble::installedAppsChanged);
913- m_appMsgManager = new AppMsgManager(m_appManager, m_connection, this);
914+
915+ m_appMsgManager = new AppMsgManager(this, m_appManager, m_connection);
916+
917 m_jskitManager = new JSKitManager(this, m_connection, m_appManager, m_appMsgManager, this);
918+ QObject::connect(m_jskitManager, SIGNAL(openURL(const QString&, const QString&)), this, SIGNAL(openURL(const QString&, const QString&)));
919+
920 m_blobDB = new BlobDB(this, m_connection);
921 QObject::connect(m_blobDB, &BlobDB::muteSource, this, &Pebble::muteNotificationSource);
922 QObject::connect(m_blobDB, &BlobDB::actionTriggered, this, &Pebble::actionTriggered);
923+
924 m_appDownloader = new AppDownloader(m_storagePath, this);
925 QObject::connect(m_appDownloader, &AppDownloader::downloadFinished, this, &Pebble::appDownloadFinished);
926
927@@ -220,6 +227,23 @@
928 m_appManager->removeApp(uuid);
929 }
930
931+void Pebble::requestConfigurationURL(const QUuid &uuid) {
932+ if (m_jskitManager->currentApp().uuid() == uuid) {
933+ m_jskitManager->showConfiguration();
934+ }
935+ else {
936+ m_jskitManager->setConfigurationId(uuid);
937+ m_appMsgManager->launchApp(uuid);
938+ }
939+}
940+
941+void Pebble::configurationClosed(const QUuid &uuid, const QString &result)
942+{
943+ if (m_jskitManager->currentApp().uuid() == uuid) {
944+ m_jskitManager->handleWebviewClosed(result);
945+ }
946+}
947+
948 void Pebble::onPebbleConnected()
949 {
950 qDebug() << "Pebble connected:" << m_name;
951
952=== modified file 'rockworkd/libpebble/pebble.h'
953--- rockworkd/libpebble/pebble.h 2015-12-30 19:15:55 +0000
954+++ rockworkd/libpebble/pebble.h 2016-01-03 06:41:00 +0000
955@@ -73,6 +73,8 @@
956 QList<QUuid> installedAppIds();
957 AppInfo appInfo(const QUuid &uuid);
958 void removeApp(const QUuid &uuid);
959+ void requestConfigurationURL(const QUuid &uuid);
960+ void configurationClosed(const QUuid &uuid, const QString &result);
961
962 private slots:
963 void onPebbleConnected();
964@@ -90,6 +92,7 @@
965 void muteNotificationSource(const QString &source);
966 void actionTriggered(const QString &actToken);
967 void installedAppsChanged();
968+ void openURL(const QString &uuid, const QString &url);
969
970 private:
971 void setHardwareRevision(HardwareRevision hardwareRevision);
972
973=== modified file 'rockworkd/libpebble/watchconnection.cpp'
974--- rockworkd/libpebble/watchconnection.cpp 2015-12-19 01:48:22 +0000
975+++ rockworkd/libpebble/watchconnection.cpp 2016-01-03 06:41:00 +0000
976@@ -95,7 +95,8 @@
977 qWarning() << "Socket not open. Cannot send data to Pebble. (Endpoint:" << endpoint << ")";
978 return;
979 }
980-// qCDebug(l) << "sending message to endpoint" << decodeEndpoint(endpoint);
981+
982+ //qDebug() << "sending message to endpoint" << endpoint;
983 QByteArray msg;
984
985 msg.append((data.length() & 0xFF00) >> 8);
986@@ -106,7 +107,7 @@
987
988 msg.append(data);
989
990-// qDebug() << "Writing:" << msg.toHex();
991+ //qDebug() << "Writing:" << msg.toHex();
992 m_socket->write(msg);
993 }
994
995@@ -232,4 +233,3 @@
996 res.append(buildData(data));
997 return res;
998 }
999-

Subscribers

People subscribed via source and target branches