diff options
Diffstat (limited to 'daemon')
| -rw-r--r-- | daemon/daemon.cpp | 12 | ||||
| -rw-r--r-- | daemon/manager.cpp | 32 | ||||
| -rw-r--r-- | daemon/manager.h | 3 | ||||
| -rw-r--r-- | daemon/settings.h | 6 | ||||
| -rw-r--r-- | daemon/voicecallhandler.cpp | 30 | ||||
| -rw-r--r-- | daemon/voicecallhandler.h | 4 | ||||
| -rw-r--r-- | daemon/watchconnector.cpp | 66 | ||||
| -rw-r--r-- | daemon/watchconnector.h | 18 |
8 files changed, 130 insertions, 41 deletions
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 85af751..78050d3 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -50,18 +50,14 @@ int main(int argc, char *argv[]) app.setApplicationName("pebble"); // Use the same appname as the UI. app.setOrganizationName(""); - QStringList filterRules; - - filterRules << (argc > 1 and QString("-d") == argv[0] ? - "*.debug=false" : "*.debug=true"); - - // Init logging should be called after app object creation - QLoggingCategory::setFilterRules(filterRules.join("\n")); - QLoggingCategory l("main"); qCDebug(l) << argv[0] << APP_VERSION; Settings settings; + + QLoggingCategory::setFilterRules(settings.property("debug").toBool() ? + "*.debug=true" : "*.debug=false"); + Manager manager(&settings); Q_UNUSED(manager); diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 179d05e..b02264e 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -123,7 +123,7 @@ void Manager::onActiveVoiceCallChanged() if (handler) { connect(handler, SIGNAL(statusChanged()), SLOT(onActiveVoiceCallStatusChanged())); connect(handler, SIGNAL(destroyed()), SLOT(onActiveVoiceCallStatusChanged())); - return; + if (handler->status()) onActiveVoiceCallStatusChanged(); } } @@ -259,6 +259,36 @@ void Manager::applyProfile() } } +void Manager::ping(uint val) +{ + qCDebug(l) << "ping" << val; + + if (settings->property("debug").toBool()) { + // magic here! + // I do not want to add specific debugging methods to pebbled + // so just provide some magic Ping() method handling here :-) + switch (val) { + case 128: + watch->sendSMSNotification("SMS", "lorem ipsum"); + return; + case 129: + watch->sendEmailNotification("e-mail", "lorem ipsum", "subject"); + return; + case 130: + watch->sendFacebookNotification("Facebook", "lorem ipsum"); + return; + case 131: + watch->sendTwitterNotification("Twitter", "lorem ipsum"); + return; + case 132: + watch->sendMusicNowPlaying("artist", "album", "track name"); + return; + } + } + + watch->ping(val); +} + void Manager::transliterateMessage(const QString &text) { if (transliterator.isNull()) { diff --git a/daemon/manager.h b/daemon/manager.h index a605ed1..e3143b1 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -70,6 +70,7 @@ protected: public slots: void applyProfile(); + void ping(uint val); private slots: void onSettingChanged(const QString &key); @@ -125,7 +126,7 @@ public: public slots: inline void Disconnect() { manager()->watch->disconnect(); } inline void Reconnect() { manager()->watch->connect(); } - inline void Ping(uint val) { manager()->watch->ping(val); } + inline void Ping(uint val) { manager()->ping(val); } inline void SyncTime() { manager()->watch->time(); } inline void LaunchApp(const QString &uuid) { manager()->appmsg->launchApp(uuid); } diff --git a/daemon/settings.h b/daemon/settings.h index a247dc5..4534a54 100644 --- a/daemon/settings.h +++ b/daemon/settings.h @@ -21,6 +21,7 @@ class Settings : public MDConfGroup Q_PROPERTY(bool notificationsOther MEMBER notificationsOther NOTIFY notificationsOtherChanged) Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged) Q_PROPERTY(QString accountToken MEMBER accountToken NOTIFY accountTokenChanged) + Q_PROPERTY(bool debug MEMBER debug NOTIFY debugChanged) QString profileWhenConnected; QString profileWhenDisconnected; @@ -36,6 +37,7 @@ class Settings : public MDConfGroup bool notificationsOther; bool notificationsAll; QString accountToken; + bool debug; public: explicit Settings(QObject *parent = 0) : @@ -50,7 +52,8 @@ public: notificationsTwitter(true), notificationsFacebook(true), notificationsOther(true), - notificationsAll(false) + notificationsAll(false), + debug(false) { resolveMetaObject(); QMetaObject::invokeMethod(this, "propertyChanged", Qt::DirectConnection); @@ -72,6 +75,7 @@ signals: void notificationsOtherChanged(); void notificationsAllChanged(); void accountTokenChanged(); + void debugChanged(); }; #endif // SETTINGS_H diff --git a/daemon/voicecallhandler.cpp b/daemon/voicecallhandler.cpp index cce1792..180fa5b 100644 --- a/daemon/voicecallhandler.cpp +++ b/daemon/voicecallhandler.cpp @@ -19,7 +19,8 @@ class VoiceCallHandlerPrivate public: VoiceCallHandlerPrivate(VoiceCallHandler *q, const QString &pHandlerId) : q_ptr(q), handlerId(pHandlerId), interface(NULL) - , duration(0), status(0), emergency(false), multiparty(false), forwarded(false) + , duration(0), status(0), emergency(false), incoming(false) + , multiparty(false) , forwarded(false), remoteHeld(false) { /* ... */ } VoiceCallHandler *q_ptr; @@ -35,8 +36,10 @@ public: QString providerId; QDateTime startedAt; bool emergency; + bool incoming; bool multiparty; bool forwarded; + bool remoteHeld; }; /*! @@ -83,6 +86,7 @@ void VoiceCallHandler::initialize(bool notifyError) connect(d->interface, SIGNAL(emergencyChanged(bool)), SLOT(onEmergencyChanged(bool))); connect(d->interface, SIGNAL(multipartyChanged(bool)), SLOT(onMultipartyChanged(bool))); connect(d->interface, SIGNAL(forwardedChanged(bool)), SLOT(onForwardedChanged(bool))); + connect(d->interface, SIGNAL(remoteHeldChanged(bool)), SLOT(onRemoteHeldChanged(bool))); } else { if (notifyError) emit this->error("Failed to get VoiceCall properties from VCM D-Bus service."); @@ -113,6 +117,8 @@ bool VoiceCallHandler::getProperties() d->multiparty = props["isMultiparty"].toBool(); d->emergency = props["isEmergency"].toBool(); d->forwarded = props["isForwarded"].toBool(); + d->incoming = props["isIncoming"].toBool(); + d->remoteHeld = props["isIncoming"].toBool(); return true; } else { @@ -135,8 +141,7 @@ void VoiceCallHandler::onStatusChanged(int status, QString statusText) qCDebug(l) <<"onStatusChanged" << status << statusText; d->status = status; d->statusText = statusText; - // we still fetch all properties to be sure all properties are present. - getProperties(); + if (status) getProperties(); // make sure all properties are present emit statusChanged(); } @@ -180,6 +185,14 @@ void VoiceCallHandler::onForwardedChanged(bool isForwarded) emit forwardedChanged(); } +void VoiceCallHandler::onRemoteHeldChanged(bool isRemoteHeld) +{ + Q_D(VoiceCallHandler); + qCDebug(l) << "onRemoteHeldChanged" << isRemoteHeld; + d->forwarded = isRemoteHeld; + emit remoteHeldChanged(); +} + /*! Returns this voice calls' handler id. */ @@ -249,7 +262,7 @@ int VoiceCallHandler::duration() const bool VoiceCallHandler::isIncoming() const { Q_D(const VoiceCallHandler); - return d->interface->property("isIncoming").toBool(); + return d->incoming; } /*! @@ -280,6 +293,15 @@ bool VoiceCallHandler::isEmergency() const } /*! + Returns this voice calls' remoteHeld flag property. + */ +bool VoiceCallHandler::isRemoteHeld() const +{ + Q_D(const VoiceCallHandler); + return d->remoteHeld; +} + +/*! Initiates answering this call, if the call is an incoming call. */ void VoiceCallHandler::answer() diff --git a/daemon/voicecallhandler.h b/daemon/voicecallhandler.h index fb20ac7..6d671ce 100644 --- a/daemon/voicecallhandler.h +++ b/daemon/voicecallhandler.h @@ -24,6 +24,7 @@ class VoiceCallHandler : public QObject Q_PROPERTY(bool isEmergency READ isEmergency NOTIFY emergencyChanged) Q_PROPERTY(bool isMultiparty READ isMultiparty NOTIFY multipartyChanged) Q_PROPERTY(bool isForwarded READ isForwarded NOTIFY forwardedChanged) + Q_PROPERTY(bool isRemoteHeld READ isRemoteHeld NOTIFY remoteHeldChanged) public: enum VoiceCallStatus { @@ -51,6 +52,7 @@ public: bool isMultiparty() const; bool isEmergency() const; bool isForwarded() const; + bool isRemoteHeld() const; Q_SIGNALS: void error(const QString &error); @@ -61,6 +63,7 @@ Q_SIGNALS: void emergencyChanged(); void multipartyChanged(); void forwardedChanged(); + void remoteHeldChanged(); public Q_SLOTS: void answer(); @@ -81,6 +84,7 @@ protected Q_SLOTS: void onEmergencyChanged(bool isEmergency); void onMultipartyChanged(bool isMultiparty); void onForwardedChanged(bool isForwarded); + void onRemoteHeldChanged(bool isRemoteHeld); private: class VoiceCallHandlerPrivate *d_ptr; diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index 09006c0..9993a38 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -71,7 +71,8 @@ bool WatchConnector::WatchVersions::isEmpty() const WatchConnector::WatchConnector(QObject *parent) : QObject(parent), l(metaObject()->className()), - socket(nullptr), is_connected(false), currentPebble(0), _last_address(0) + socket(nullptr), is_connected(false), + currentPebble(0), _last_address(0), platform(HP_UNKNOWN) { reconnectTimer.setSingleShot(true); QObject::connect(&reconnectTimer, SIGNAL(timeout()), SLOT(connect())); @@ -79,19 +80,19 @@ WatchConnector::WatchConnector(QObject *parent) : QObject::connect(&timeSyncTimer, SIGNAL(timeout()), SLOT(time())); timeSyncTimer.setInterval(4 * 60 * 60 * 1000); // sync time every 4 hours - firmwareMapping.insert(UNKNOWN, "unknown"); - firmwareMapping.insert(TINTIN_EV1, "ev1"); - firmwareMapping.insert(TINTIN_EV2, "ev2"); - firmwareMapping.insert(TINTIN_EV2_3, "ev2_3"); - firmwareMapping.insert(TINTIN_EV2_4, "ev2_4"); - firmwareMapping.insert(TINTIN_V1_5, "v1_5"); - firmwareMapping.insert(BIANCA, "v2_0"); - firmwareMapping.insert(SNOWY_EVT2, "snowy_evt2"); - firmwareMapping.insert(SNOWY_DVT, "snowy_dvt"); - firmwareMapping.insert(TINTIN_BB, "bigboard"); - firmwareMapping.insert(TINTIN_BB2, "bb2"); - firmwareMapping.insert(SNOWY_BB, "snowy_bb"); - firmwareMapping.insert(SNOWY_BB2, "snowy_bb2"); + hardwareMapping.insert(HR_UNKNOWN, HWMap(HP_UNKNOWN, "unknown")); + hardwareMapping.insert(TINTIN_EV1, HWMap(APLITE, "ev1")); + hardwareMapping.insert(TINTIN_EV2, HWMap(APLITE, "ev2")); + hardwareMapping.insert(TINTIN_EV2_3, HWMap(APLITE, "ev2_3")); + hardwareMapping.insert(TINTIN_EV2_4, HWMap(APLITE, "ev2_4")); + hardwareMapping.insert(TINTIN_V1_5, HWMap(APLITE, "v1_5")); + hardwareMapping.insert(BIANCA, HWMap(APLITE, "v2_0")); + hardwareMapping.insert(SNOWY_EVT2, HWMap(BASALT, "snowy_evt2")); + hardwareMapping.insert(SNOWY_DVT, HWMap(BASALT, "snowy_dvt")); + hardwareMapping.insert(TINTIN_BB, HWMap(APLITE, "bigboard")); + hardwareMapping.insert(TINTIN_BB2, HWMap(APLITE, "bb2")); + hardwareMapping.insert(SNOWY_BB, HWMap(BASALT, "snowy_bb")); + hardwareMapping.insert(SNOWY_BB2, HWMap(BASALT, "snowy_bb2")); setEndpointHandler(watchVERSION, [this](const QByteArray &data) { Unpacker u(data); @@ -103,7 +104,7 @@ WatchConnector::WatchConnector(QObject *parent) : _versions.main.commit = u.readFixedString(8); _versions.main.is_recovery = u.read<quint8>(); _versions.main.hw_revision = HardwareRevision(u.read<quint8>()); - _versions.main.hw_string = firmwareMapping.value(_versions.main.hw_revision); + _versions.main.hw_string = hardwareMapping.value(_versions.main.hw_revision).second; _versions.main.metadata_version = u.read<quint8>(); _versions.safe.build = QDateTime::fromTime_t(u.read<quint32>()); @@ -111,7 +112,7 @@ WatchConnector::WatchConnector(QObject *parent) : _versions.safe.commit = u.readFixedString(8); _versions.safe.is_recovery = u.read<quint8>(); _versions.safe.hw_revision = HardwareRevision(u.read<quint8>()); - _versions.safe.hw_string = firmwareMapping.value(_versions.safe.hw_revision); + _versions.safe.hw_string = hardwareMapping.value(_versions.safe.hw_revision).second; _versions.safe.metadata_version = u.read<quint8>(); _versions.bootLoaderBuild = QDateTime::fromTime_t(u.read<quint32>()); @@ -119,6 +120,8 @@ WatchConnector::WatchConnector(QObject *parent) : _versions.serialNumber = u.readFixedString(12); _versions.address = u.readBytes(6); + platform = hardwareMapping.value(_versions.safe.hw_revision).first; + if (u.bad()) { qCWarning(l) << "short read while reading firmware version"; } else { @@ -428,6 +431,7 @@ void WatchConnector::onError(QBluetoothSocket::SocketError error) } else { qCCritical(l) << "error connecting Pebble:" << error << socket->errorString(); } + scheduleReconnect(); } void WatchConnector::sendData(const QByteArray &data) @@ -576,15 +580,31 @@ QString WatchConnector::timeStamp() void WatchConnector::sendNotification(uint lead, QString sender, QString data, QString subject) { - QStringList tmp; - tmp.append(sender); - tmp.append(data); - tmp.append(timeStamp()); - if (lead == leadEMAIL) tmp.append(subject); + switch (platform) { + case HP_UNKNOWN: + qCWarning(l) << "Tried sending notification to UNKNOWN watch platform" << lead << sender << data << subject; + break; + case APLITE: { + QStringList tmp; + tmp.append(sender); + tmp.append(data); + tmp.append(timeStamp()); + if (lead == leadEMAIL) tmp.append(subject); + + QByteArray res = buildMessageData(lead, tmp); - QByteArray res = buildMessageData(lead, tmp); + sendMessage(watchNOTIFICATION, res); + } + break; + case BASALT: { + qCWarning(l) << "Tried sending notification to unsupported watch platform" << lead << sender << data << subject; + } + break; + default: + qCWarning(l) << "Tried sending notification to unsupported watch platform" << platform << ":" << lead << sender << data << subject; + break; + } - sendMessage(watchNOTIFICATION, res); } void WatchConnector::sendSMSNotification(QString sender, QString data) diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index fa65f6b..4369d87 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -39,12 +39,17 @@ public: watchAPP = 2004, watchAPP_LOGS = 2006, watchNOTIFICATION = 3000, + watchEXTENSIBLE_NOTIFS = 3010, // Deprecated in 3.x watchRESOURCE = 4000, - watchAPP_MANAGER = 6000, + watchFACTORY_SETTINGS = 5001, + watchAPP_MANAGER = 6000, // Deprecated in 3.x + watchAPP_FETCH = 6001, // New in 3.x watchDATA_LOGGING = 6778, watchSCREENSHOT = 8000, watchFILE_MANAGER = 8181, watchCORE_DUMP = 9000, + watchAUDIO = 10000, // New in 3.x + watchBLOB_DB = 45531, // New in 3.x watchPUTBYTES = 48879 }; enum { @@ -147,7 +152,7 @@ public: }; enum HardwareRevision { - UNKNOWN = 0, + HR_UNKNOWN = 0, TINTIN_EV1 = 1, TINTIN_EV2 = 2, TINTIN_EV2_3 = 3, @@ -162,7 +167,13 @@ public: SNOWY_BB = 0xFD, SNOWY_BB2 = 0xFC }; - QMap<HardwareRevision, QString> firmwareMapping; + enum HardwarePlatform { + HP_UNKNOWN = 0, + APLITE, + BASALT + }; + typedef QPair<HardwarePlatform,QString> HWMap; + QMap<HardwareRevision, HWMap> hardwareMapping; struct SoftwareVersion { QDateTime build; @@ -268,6 +279,7 @@ private: int currentPebble; quint64 _last_address; WatchVersions _versions; + HardwarePlatform platform; }; QDebug operator<< (QDebug d, const WatchConnector::SoftwareVersion &ver); |
