From aede5f2afafb5e1831d76ea8bb5dc644bdee6ba2 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 6 Feb 2018 15:53:36 +0100 Subject: [PATCH] add a hack for meeting the zapf deadline disable having a device per phone endpoint. instead just register a single device and broadcast stuff to /everyone until the cloud and app are updated for this --- libguh-core/awsconnector.cpp | 4 +++- libguh-core/cloudnotifications.cpp | 33 +++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/libguh-core/awsconnector.cpp b/libguh-core/awsconnector.cpp index 22bbd8f7..e5d85f2f 100644 --- a/libguh-core/awsconnector.cpp +++ b/libguh-core/awsconnector.cpp @@ -267,7 +267,9 @@ int AWSConnector::sendPushNotification(const QString &userId, const QString &end params.insert("title", title); params.insert("body", text); params.insert("timestamp", QDateTime::currentMSecsSinceEpoch()); - publish(QString("%1/notify/user/%2/%3").arg(m_clientId, userId, endpointId), params); +// publish(QString("%1/notify/user/%2/%3").arg(m_clientId, userId, endpointId), params); + Q_UNUSED(userId) + publish(QString("%1/notify/user/%2").arg(m_clientId, endpointId), params); return m_transactionId; } diff --git a/libguh-core/cloudnotifications.cpp b/libguh-core/cloudnotifications.cpp index efafe263..34597b61 100644 --- a/libguh-core/cloudnotifications.cpp +++ b/libguh-core/cloudnotifications.cpp @@ -33,6 +33,12 @@ ParamTypeId notifyActionParamBodyId = ParamTypeId("4bd0fa87-c663-4621-8040-99b6d StateTypeId connectedStateTypeId = StateTypeId("518e27b6-c3bf-49d7-be24-05ae978c00f7"); +// FIXME: This ZAPF_HOTFIX is here to disable some features in order to meet the ZAPF deadline +// Once the cloud infrastructure is fixed to properly give out unique and persistent ids +// for push notification enabled devices, remove this complete commit (apply -r) +// It should remove all the ZAPF_HOTFIX parts in here and one line in awsconnector.cpp +#define ZAPF_HOTFIX 1 + CloudNotifications::CloudNotifications(AWSConnector* awsConnector, QObject *parent): DevicePlugin(parent), m_awsConnector(awsConnector) @@ -157,6 +163,27 @@ DeviceManager::DeviceError CloudNotifications::executeAction(Device *device, con void CloudNotifications::pushNotificationEndpointsUpdated(const QList &endpoints) { qCDebug(dcCloud()) << "Push Notification endpoint update"; +#if ZAPF_HOTFIX + if (endpoints.isEmpty() && myDevices().count() > 0) { + emit autoDeviceDisappeared(myDevices().first()->id()); + return; + } + + if (myDevices().count() > 0) { + // already have a device, ignore it + return; + } + + DeviceDescriptor descriptor(cloudNotificationsDeviceClassId, "Push notifications", ""); + ParamList params; + Param userIdParam(cloudNotificationsDeviceClassUserParamId, ""); // Not used for now + params.append(userIdParam); + Param endpointIdParam(cloudNotificationsDeviceClassEndpointParamId, "everyone"); + params.append(endpointIdParam); + descriptor.setParams(params); + emit autoDevicesAppeared(cloudNotificationsDeviceClassId, {descriptor}); + +#else QList devicesToRemove; foreach (Device *configuredDevice, myDevices()) { bool found = false; @@ -198,11 +225,14 @@ void CloudNotifications::pushNotificationEndpointsUpdated(const QList