summaryrefslogtreecommitdiff
path: root/daemon/manager.cpp
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-11-30 17:27:08 +0100
committerJavier <dev.git@javispedro.com>2014-11-30 17:37:19 +0100
commit49f1261bf9d635d5e3d881e87a93ed4e76abfe90 (patch)
tree4432ecd771a3aca533914d02f9947cb497493395 /daemon/manager.cpp
parentd55d1d472d5876f90dd95301d9f3b6bef6f4c494 (diff)
allow receiving responses to commands in watchconnector
* the skeleton is in place for watchconnector to allow query->response messages. I've used call/cc style because it is impossible to make QBluetoothSocket synchronous (waitForReadyRead() is a no-op) * remove watchcommands, instead create musicmanager to listen for the music endpoint. The other (simpler) endpoints are now listened in watchconnector itself. hangupAll() slot is moved to voicecallmanager. * instead of emitting signals for each received message, listeners can now register for receiving messages targeted towards a given endpoint * when reading from bluetoothsocket, properly handle short reads * remove useless 'watch' namespace * create appmanager, which mantains a database of installed apps (installed on the phone, that is; watch installed apps will come later) * all the *Managers are now instantiated by the main Manager itself * introduce Unpacker helper class for decoding watch messages * implement getAppbankStatus and getAppbankUuids messages and response parsers * remove file logging for now (20MB is bad for eMMC!) * use dbus object path /org/pebbled instead of /
Diffstat (limited to 'daemon/manager.cpp')
-rw-r--r--daemon/manager.cpp66
1 files changed, 51 insertions, 15 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index 7761864..8a8acf4 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -5,9 +5,15 @@
#include <QtContacts/QContact>
#include <QtContacts/QContactPhoneNumber>
-Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications, AppManager *apps, Settings *settings) :
- QObject(0), watch(watch), dbus(dbus), voice(voice), notifications(notifications), apps(apps),
- commands(new WatchCommands(watch, this)), settings(settings), notification(MNotification::DeviceEvent)
+Manager::Manager(Settings *settings, QObject *parent) :
+ QObject(parent), settings(settings),
+ watch(new WatchConnector(this)),
+ dbus(new DBusConnector(this)),
+ voice(new VoiceCallManager(settings, this)),
+ notifications(new NotificationManager(settings, this)),
+ music(new MusicManager(watch, this)),
+ apps(new AppManager(this)),
+ notification(MNotification::DeviceEvent)
{
connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&)));
connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged()));
@@ -22,6 +28,24 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
numberFilter.setMatchFlags(QContactFilter::MatchPhoneNumber);
connect(watch, SIGNAL(connectedChanged()), SLOT(onConnectedChanged()));
+ watch->setEndpointHandler(WatchConnector::watchPHONE_VERSION,
+ [this](const QByteArray& data) {
+ Q_UNUSED(data);
+ watch->sendPhoneVersion();
+ return true;
+ });
+ watch->setEndpointHandler(WatchConnector::watchPHONE_CONTROL,
+ [this](const QByteArray& data) {
+ if (data.at(0) == WatchConnector::callHANGUP) {
+ voice->hangupAll();
+ }
+ return true;
+ });
+ watch->setEndpointHandler(WatchConnector::watchDATA_LOGGING,
+ [this](const QByteArray& data) {
+ //logger()->debug() << data.toHex();
+ return true;
+ });
connect(voice, SIGNAL(activeVoiceCallChanged()), SLOT(onActiveVoiceCallChanged()));
connect(voice, SIGNAL(error(const QString &)), SLOT(onVoiceError(const QString &)));
@@ -32,13 +56,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
connect(notifications, SIGNAL(twitterNotify(const QString &,const QString &)), SLOT(onTwitterNotify(const QString &,const QString &)));
connect(notifications, SIGNAL(facebookNotify(const QString &,const QString &)), SLOT(onFacebookNotify(const QString &,const QString &)));
- connect(watch, SIGNAL(messageDecoded(uint,QByteArray)), commands, SLOT(processMessage(uint,QByteArray)));
- connect(commands, SIGNAL(hangup()), SLOT(hangupAll()));
-
PebbledProxy *proxy = new PebbledProxy(this);
PebbledAdaptor *adaptor = new PebbledAdaptor(proxy);
QDBusConnection session = QDBusConnection::sessionBus();
- session.registerObject("/", proxy);
+ session.registerObject("/org/pebbled", proxy);
session.registerService("org.pebbled");
connect(dbus, SIGNAL(pebbleChanged()), adaptor, SIGNAL(pebbleChanged()));
connect(watch, SIGNAL(connectedChanged()), adaptor, SIGNAL(connectedChanged()));
@@ -52,7 +73,7 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
"org.freedesktop.DBus.Properties", "PropertiesChanged",
this, SLOT(onMprisPropertiesChanged(QString,QMap<QString,QVariant>,QStringList)));
- connect(this, SIGNAL(mprisMetadataChanged(QVariantMap)), commands, SLOT(onMprisMetadataChanged(QVariantMap)));
+ connect(this, SIGNAL(mprisMetadataChanged(QVariantMap)), music, SLOT(onMprisMetadataChanged(QVariantMap)));
// Set BT icon for notification
notification.setImage("icon-system-bluetooth-device");
@@ -62,7 +83,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
dbus->findPebble();
}
+}
+Manager::~Manager()
+{
}
void Manager::onSettingChanged(const QString &key)
@@ -247,13 +271,6 @@ void Manager::onEmailNotify(const QString &sender, const QString &data,const QSt
watch->sendEmailNotification(sender, data, subject);
}
-void Manager::hangupAll()
-{
- foreach (VoiceCallHandler* handler, voice->voiceCalls()) {
- handler->hangup();
- }
-}
-
void Manager::onMprisPropertiesChanged(QString interface, QMap<QString,QVariant> changed, QStringList invalidated)
{
logger()->debug() << interface << changed << invalidated;
@@ -369,3 +386,22 @@ void Manager::transliterateMessage(const QString &text)
logger()->debug() << "String after transliteration:" << text;
}
}
+
+bool Manager::uploadApp(const QUuid &uuid, int slot)
+{
+ // TODO
+ return false;
+}
+
+void Manager::test()
+{
+ logger()->debug() << "Starting test";
+
+ watch->getAppbankStatus([this](const QString &s) {
+ logger()->debug() << "Callback invoked" << s;
+ });
+
+ watch->getAppbankUuids([this](const QList<QUuid> &uuids) {
+ logger()->debug() << "Callback invoked. UUIDs:" << uuids.size();
+ });
+}