Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
Handle multiple paired Pebbles
Browse files Browse the repository at this point in the history
Moved Pebble discovery to WatchConnector.
Removed empty DBusConnector.
Minor firmware handling fixes.
  • Loading branch information
smokku committed Jun 9, 2015
1 parent 7d7dd8a commit 882b7b9
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 191 deletions.
1 change: 1 addition & 0 deletions app/pebblefirmware.cpp
Expand Up @@ -18,6 +18,7 @@ void PebbleFirmware::updateLatest(QString hw)
QNetworkRequest req;
req.setUrl(firmwareURL.arg(hw).arg(hw.startsWith("snowy_") ? "release-v3" : "release-v2"));
req.setRawHeader("Cache-Control", "no-cache");
qDebug() << "Getting latest firmware" << req.url();
nm->get(req);
}

Expand Down
10 changes: 5 additions & 5 deletions app/qml/pages/WatchInfo.qml
Expand Up @@ -28,15 +28,15 @@ Page {
text: qsTr("Address")
}
Label {
text: pebbled.info.address
text: pebbled.info.address || ""
}

Label {
color: Theme.highlightColor
text: qsTr("Serial Number")
}
Label {
text: pebbled.info.serial
text: pebbled.info.serial || ""
}

Label {
Expand Down Expand Up @@ -69,15 +69,15 @@ Page {
text: qsTr("Recovery")
}
Label {
text: app.recoveryVersion
text: app.recoveryVersion || qsTr("unknown")
}

Label {
color: Theme.highlightColor
text: qsTr("Running")
}
Label {
text: app.firmwareVersion
text: app.firmwareVersion || qsTr("unknown")
}

Label {
Expand All @@ -89,7 +89,7 @@ Page {
}
}
Button {
visible: app.firmwareLatest && app.firmwareVersion && app.firmwareVersion !== app.firmwareLatest
visible: app.firmwareLatest && app.firmwareVersion !== app.firmwareLatest
text: qsTr("Upgrade Firmware")
anchors {
left: parent.left
Expand Down
2 changes: 2 additions & 0 deletions app/qml/pebble.qml
Expand Up @@ -22,6 +22,8 @@ ApplicationWindow
recoveryVersion = firmware.version
} else {
firmwareVersion = firmware.version
}
if (firmware.hardware) {
hardwareVersion = firmware.hardware
}
})
Expand Down
2 changes: 2 additions & 0 deletions app/translations/pebble-es.ts
Expand Up @@ -425,6 +425,8 @@ Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente.</tra
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="72"/>
<location filename="../qml/pages/WatchInfo.qml" line="80"/>
<location filename="../qml/pages/WatchInfo.qml" line="88"/>
<source>unknown</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 2 additions & 0 deletions app/translations/pebble-pl.ts
Expand Up @@ -453,6 +453,8 @@ Jeśli nie zostaje znaleziony sprawdź czy jest w zasięgu i czy jest sparowany
<translation>Najnowszy</translation>
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="72"/>
<location filename="../qml/pages/WatchInfo.qml" line="80"/>
<location filename="../qml/pages/WatchInfo.qml" line="88"/>
<source>unknown</source>
<translation>nie wiadomo</translation>
Expand Down
2 changes: 2 additions & 0 deletions app/translations/pebble-zh_CN.ts
Expand Up @@ -405,6 +405,8 @@ If it can&apos;t be found please check it&apos;s available and paired in Bluetoo
<translation>最新</translation>
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="72"/>
<location filename="../qml/pages/WatchInfo.qml" line="80"/>
<location filename="../qml/pages/WatchInfo.qml" line="88"/>
<source>unknown</source>
<translation>未知</translation>
Expand Down
2 changes: 2 additions & 0 deletions app/translations/pebble.ts
Expand Up @@ -404,6 +404,8 @@ If it can&apos;t be found please check it&apos;s available and paired in Bluetoo
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchInfo.qml" line="72"/>
<location filename="../qml/pages/WatchInfo.qml" line="80"/>
<location filename="../qml/pages/WatchInfo.qml" line="88"/>
<source>unknown</source>
<translation type="unfinished"></translation>
Expand Down
2 changes: 0 additions & 2 deletions daemon/daemon.pro
Expand Up @@ -16,7 +16,6 @@ SOURCES += \
voicecallhandler.cpp \
notificationmanager.cpp \
watchconnector.cpp \
dbusconnector.cpp \
appmanager.cpp \
musicmanager.cpp \
datalogmanager.cpp \
Expand All @@ -36,7 +35,6 @@ HEADERS += \
voicecallhandler.h \
notificationmanager.h \
watchconnector.h \
dbusconnector.h \
settings.h \
appmanager.h \
musicmanager.h \
Expand Down
77 changes: 0 additions & 77 deletions daemon/dbusconnector.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions daemon/dbusconnector.h

This file was deleted.

22 changes: 3 additions & 19 deletions daemon/manager.cpp
Expand Up @@ -10,7 +10,6 @@ Manager::Manager(Settings *settings, QObject *parent) :
QObject(parent), l(metaObject()->className()), settings(settings),
proxy(new PebbledProxy(this)),
watch(new WatchConnector(this)),
dbus(new DBusConnector(this)),
upload(new UploadManager(watch, this)),
apps(new AppManager(this)),
bank(new BankManager(watch, upload, apps, this)),
Expand Down Expand Up @@ -67,8 +66,8 @@ Manager::Manager(Settings *settings, QObject *parent) :
session.registerObject("/org/pebbled/Watch", proxy);
session.registerService("org.pebbled");

connect(dbus, &DBusConnector::pebbleChanged, proxy, &PebbledProxy::NameChanged);
connect(dbus, &DBusConnector::pebbleChanged, proxy, &PebbledProxy::AddressChanged);
connect(watch, &WatchConnector::pebbleChanged, proxy, &PebbledProxy::NameChanged);
connect(watch, &WatchConnector::pebbleChanged, proxy, &PebbledProxy::AddressChanged);
connect(watch, &WatchConnector::connectedChanged, proxy, &PebbledProxy::ConnectedChanged);
connect(watch, &WatchConnector::versionsChanged, proxy, &PebbledProxy::InfoChanged);
connect(bank, &BankManager::slotsChanged, proxy, &PebbledProxy::AppSlotsChanged);
Expand All @@ -79,11 +78,7 @@ Manager::Manager(Settings *settings, QObject *parent) :
// Set BT icon for notification
notification.setImage("icon-system-bluetooth-device");

if (btDevice.isValid()) {
qCDebug(l) << "BT local name:" << btDevice.name();
connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
dbus->findPebble();
}
watch->findPebbles();
}

Manager::~Manager()
Expand All @@ -100,17 +95,6 @@ void Manager::onSettingsChanged()
qCWarning(l) << __FUNCTION__ << "Not implemented!";
}

void Manager::onPebbleChanged()
{
const QVariantMap & pebble = dbus->pebble();
QString name = pebble["Name"].toString();
if (name.isEmpty()) {
qCDebug(l) << "Pebble gone";
} else {
watch->deviceConnect(name, pebble["Address"].toString());
}
}

void Manager::onConnectedChanged()
{
QString message = QString("%1 %2")
Expand Down
17 changes: 5 additions & 12 deletions daemon/manager.h
Expand Up @@ -2,7 +2,6 @@
#define MANAGER_H

#include "watchconnector.h"
#include "dbusconnector.h"
#include "uploadmanager.h"
#include "voicecallmanager.h"
#include "notificationmanager.h"
Expand All @@ -15,7 +14,6 @@
#include "settings.h"

#include <QObject>
#include <QBluetoothLocalDevice>
#include <QDBusContext>
#include <QtContacts/QContactManager>
#include <QtContacts/QContactDetailFilter>
Expand All @@ -35,14 +33,11 @@ class Manager : public QObject, protected QDBusContext

friend class PebbledProxy;

QBluetoothLocalDevice btDevice;

Settings *settings;

PebbledProxy *proxy;

WatchConnector *watch;
DBusConnector *dbus;
UploadManager *upload;
AppManager *apps;
BankManager *bank;
Expand Down Expand Up @@ -79,7 +74,6 @@ public slots:
private slots:
void onSettingChanged(const QString &key);
void onSettingsChanged();
void onPebbleChanged();
void onConnectedChanged();
void onActiveVoiceCallChanged();
void onVoiceError(const QString &message);
Expand Down Expand Up @@ -113,16 +107,15 @@ class PebbledProxy : public QObject, protected QDBusContext
Q_PROPERTY(QVariantList AllApps READ AllApps NOTIFY AllAppsChanged)

inline Manager* manager() const { return static_cast<Manager*>(parent()); }
inline QVariantMap pebble() const { return manager()->dbus->pebble(); }

public:
inline explicit PebbledProxy(QObject *parent)
: QObject(parent), l(metaObject()->className()) {}

inline QString Name() const { return pebble()["Name"].toString(); }
inline QString Address() const { return pebble()["Address"].toString(); }
inline QVariantMap Info() const { return manager()->watch->versions().toMap(); }
inline bool Connected() const { return manager()->watch->isConnected(); }
inline QString Name() const { qCDebug(l) << manager()->watch->name(); return manager()->watch->name(); }
inline QString Address() const { qCDebug(l) << manager()->watch->address().toString(); return manager()->watch->address().toString(); }
inline QVariantMap Info() const { qCDebug(l) << manager()->watch->versions().toMap(); return manager()->watch->versions().toMap(); }
inline bool Connected() const { qCDebug(l) << manager()->watch->isConnected(); return manager()->watch->isConnected(); }
inline QString AppUuid() const { return manager()->currentAppUuid.toString(); }

QStringList AppSlots() const;
Expand All @@ -131,7 +124,7 @@ class PebbledProxy : public QObject, protected QDBusContext

public slots:
inline void Disconnect() { manager()->watch->disconnect(); }
inline void Reconnect() { manager()->watch->reconnect(); }
inline void Reconnect() { manager()->watch->connect(); }
inline void Ping(uint val) { manager()->watch->ping(val); }
inline void SyncTime() { manager()->watch->time(); }

Expand Down

0 comments on commit 882b7b9

Please sign in to comment.