summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2015-04-17 14:06:50 +0200
committerTomasz Sterna <tomek@xiaoka.com>2015-04-17 14:06:50 +0200
commit453e9ea4ea8d56ad84c2329cb95f1dfed279be95 (patch)
tree0987f90f3c9d0302dcc7dde7d1854af38f04f419
parente059c47ff2986c329d075f6f5fbedbf19cff430d (diff)
Better watch versions handling
Didn't react on firmware version change.
-rw-r--r--app/qml/pages/WatchInfo.qml32
-rw-r--r--app/translations/pebble-es.ts8
-rw-r--r--app/translations/pebble-pl.ts8
-rw-r--r--app/translations/pebble.ts8
-rw-r--r--daemon/manager.h3
-rw-r--r--daemon/watchconnector.cpp40
-rw-r--r--daemon/watchconnector.h6
7 files changed, 61 insertions, 44 deletions
diff --git a/app/qml/pages/WatchInfo.qml b/app/qml/pages/WatchInfo.qml
index 94445fb..69a916c 100644
--- a/app/qml/pages/WatchInfo.qml
+++ b/app/qml/pages/WatchInfo.qml
@@ -46,22 +46,6 @@ Page {
Label {
text: new Date(pebbled.info.bootloader * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat)
}
-
- Label {
- color: Theme.highlightColor
- text: qsTr("Firmware")
- }
- Label {
- text: app.firmwareVersion
- }
-
- Label {
- color: Theme.highlightColor
- text: qsTr("Recovery")
- }
- Label {
- text: app.recoveryVersion
- }
}
Label {
@@ -82,6 +66,22 @@ Page {
Label {
color: Theme.highlightColor
+ text: qsTr("Recovery")
+ }
+ Label {
+ text: app.recoveryVersion
+ }
+
+ Label {
+ color: Theme.highlightColor
+ text: qsTr("Running")
+ }
+ Label {
+ text: app.firmwareVersion
+ }
+
+ Label {
+ color: Theme.highlightColor
text: qsTr("Latest")
}
Label {
diff --git a/app/translations/pebble-es.ts b/app/translations/pebble-es.ts
index 4a67245..f4255bd 100644
--- a/app/translations/pebble-es.ts
+++ b/app/translations/pebble-es.ts
@@ -304,16 +304,20 @@ Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente.</tra
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="52"/>
- <location filename="../qml/pages/WatchInfo.qml" line="68"/>
<source>Firmware</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../qml/pages/WatchInfo.qml" line="60"/>
+ <location filename="../qml/pages/WatchInfo.qml" line="69"/>
<source>Recovery</source>
<translation type="unfinished"></translation>
</message>
<message>
+ <location filename="../qml/pages/WatchInfo.qml" line="77"/>
+ <source>Running</source>
+ <translation type="unfinished">Ejecutándose</translation>
+ </message>
+ <message>
<location filename="../qml/pages/WatchInfo.qml" line="85"/>
<source>Latest</source>
<translation type="unfinished"></translation>
diff --git a/app/translations/pebble-pl.ts b/app/translations/pebble-pl.ts
index 7d882c7..040df3d 100644
--- a/app/translations/pebble-pl.ts
+++ b/app/translations/pebble-pl.ts
@@ -300,16 +300,20 @@ Jeśli nie zostaje znaleziony sprawdź czy jest w zasięgu i czy jest sparowany
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="52"/>
- <location filename="../qml/pages/WatchInfo.qml" line="68"/>
<source>Firmware</source>
<translation>Firmware</translation>
</message>
<message>
- <location filename="../qml/pages/WatchInfo.qml" line="60"/>
+ <location filename="../qml/pages/WatchInfo.qml" line="69"/>
<source>Recovery</source>
<translation>Recovery</translation>
</message>
<message>
+ <location filename="../qml/pages/WatchInfo.qml" line="77"/>
+ <source>Running</source>
+ <translation type="unfinished">Pracuje</translation>
+ </message>
+ <message>
<location filename="../qml/pages/WatchInfo.qml" line="85"/>
<source>Latest</source>
<translation type="unfinished"></translation>
diff --git a/app/translations/pebble.ts b/app/translations/pebble.ts
index 1b62733..9da7dd2 100644
--- a/app/translations/pebble.ts
+++ b/app/translations/pebble.ts
@@ -299,16 +299,20 @@ If it can&apos;t be found please check it&apos;s available and paired in Bluetoo
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="52"/>
- <location filename="../qml/pages/WatchInfo.qml" line="68"/>
<source>Firmware</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../qml/pages/WatchInfo.qml" line="60"/>
+ <location filename="../qml/pages/WatchInfo.qml" line="69"/>
<source>Recovery</source>
<translation type="unfinished"></translation>
</message>
<message>
+ <location filename="../qml/pages/WatchInfo.qml" line="77"/>
+ <source>Running</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location filename="../qml/pages/WatchInfo.qml" line="85"/>
<source>Latest</source>
<translation type="unfinished"></translation>
diff --git a/daemon/manager.h b/daemon/manager.h
index d04b730..de01dbb 100644
--- a/daemon/manager.h
+++ b/daemon/manager.h
@@ -124,8 +124,7 @@ public:
inline QString Name() const { return pebble()["Name"].toString(); }
inline QString Address() const { return pebble()["Address"].toString(); }
- inline QVariantMap Info() const { return manager()->watch->versions().serialNumber.isEmpty()
- ? QVariantMap() : manager()->watch->versions().toMap(); }
+ inline QVariantMap Info() const { return manager()->watch->versions().toMap(); }
inline bool Connected() const { return manager()->watch->isConnected(); }
inline QString AppUuid() const { return manager()->currentAppUuid.toString(); }
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index 54048de..8d1dbac 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -28,7 +28,7 @@ QDebug operator<< (QDebug d, const WatchConnector::WatchVersions &ver) {
return d;
}
-QVariantMap WatchConnector::SoftwareVersion::toMap()
+QVariantMap WatchConnector::SoftwareVersion::toMap() const
{
QVariantMap map;
map.insert("version", this->version);
@@ -40,16 +40,28 @@ QVariantMap WatchConnector::SoftwareVersion::toMap()
return map;
}
-QVariantMap WatchConnector::WatchVersions::toMap()
+QVariantMap WatchConnector::WatchVersions::toMap() const
{
QVariantMap map;
- map.insert("bootloader", this->bootLoaderBuild.toTime_t());
- map.insert("serial", this->serialNumber);
- map.insert("address", this->address.toHex());
- map.insertMulti("firmware", this->main.toMap());
- map.insertMulti("firmware", this->safe.toMap());
+ if (!isEmpty()) {
+ map.insert("bootloader", this->bootLoaderBuild.toTime_t());
+ map.insert("serial", this->serialNumber);
+ map.insert("address", this->address.toHex());
+ map.insertMulti("firmware", this->main.toMap());
+ map.insertMulti("firmware", this->safe.toMap());
+ }
return map;
}
+void WatchConnector::WatchVersions::clear()
+{
+ serialNumber.clear();
+ address.clear();
+}
+
+bool WatchConnector::WatchVersions::isEmpty() const
+{
+ return serialNumber.isEmpty() || address.isEmpty();
+}
WatchConnector::WatchConnector(QObject *parent) :
QObject(parent), l(metaObject()->className()), socket(nullptr), is_connected(false)
@@ -151,15 +163,9 @@ void WatchConnector::handleWatch(const QString &name, const QString &address)
socket->deleteLater();
}
- bool emit_name = (_last_name != name);
_last_name = name;
_last_address = address;
- if (emit_name) emit nameChanged();
-
- if (emit_name) {
- // If we've changed names, don't reuse cached serial number!
- _versions.serialNumber.clear();
- }
+ _versions.clear();
qCDebug(l) << "Creating socket";
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
@@ -293,11 +299,9 @@ void WatchConnector::onConnected()
qCDebug(l) << "Found" << writeData.length() << "bytes in write buffer - resending";
sendData(writeData);
}
- if (_versions.serialNumber.isEmpty()) {
- // Ask for version information from the watch
- sendMessage(watchVERSION, QByteArray(1, 0));
- }
+ sendMessage(watchVERSION, QByteArray(1, 0));
emit connectedChanged();
+ if (name() != _last_name) emit nameChanged();
}
}
diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h
index 8d78356..18f5fba 100644
--- a/daemon/watchconnector.h
+++ b/daemon/watchconnector.h
@@ -169,7 +169,7 @@ public:
QString hw_string;
quint8 metadata_version;
- QVariantMap toMap();
+ QVariantMap toMap() const;
};
struct WatchVersions {
@@ -180,7 +180,9 @@ public:
QString serialNumber;
QByteArray address;
- QVariantMap toMap();
+ QVariantMap toMap() const;
+ void clear();
+ bool isEmpty() const;
};
typedef QMap<int, QVariant> Dict;