Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lipstick] Remove some obsolete notification properties. Fixes JB#51045
  • Loading branch information
pvuorela committed Sep 1, 2020
1 parent 2df81ae commit a6d7586
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 54 deletions.
8 changes: 0 additions & 8 deletions doc/src/notifications.dox
Expand Up @@ -13,14 +13,9 @@
*
* - Some optional features of the specification are not supported: body text
* containing markup is not supported.
* - Multiple actions per notification are correctly handled, but the user
* interface provides no means for displaying or activating actions other
* than "default".
* - Some standard hints are not supported. These are:
* - 'action-icons'
* - 'desktop-entry'
* - 'image-data'
* - 'sound-name'
* - 'x'
* - 'y'
*
Expand Down Expand Up @@ -85,15 +80,12 @@
* - \c x-nemo-timestamp: the timestamp for the notification. Should be set to the time when the event the notification is related to has occurred, not when the notification itself was sent.
* - \c x-nemo-preview-body: body text to be shown in the preview banner for the notification, if any.
* - \c x-nemo-preview-summary: summary text to be shown in the preview banner for the notification, if any.
* - \c x-nemo-max-content-lines: the maximum number of content lines to display in the events view, inclusive of the summary. If 1, then no body lines will be displayed.
* - \c x-nemo-remote-action-actionname: details of the D-Bus call to be made when the action "actionname" is executed. "actionname" should be listed in the notification's \c actions array. The required format is "serviceName objectPath interface methodName [argument...]", where each argument must be separately encoded by serializing to QDataStream, then encoding the resulting byte sequence to Base64.
* - \c x-nemo-visibility: the confidentiality of the notification. Currently allows "public" to make notification show even on locked device, "private" and "secret" like on Android API might come later if needed.
*
* - The following hints are used by system notifications, and may be excluded from application notifications:
* - \c x-nemo-feedback: a token used to generate a pre-defined feedback event when the notification preview is displayed
* - \c x-nemo-display-on: if true, the display will be turned on when required for the duration of the notification preview
* - \c x-nemo-led-disabled-without-body-and-summary: if false, a notification may invoke a feedback event even with empty body and summary properties
* - \c x-nemo-hidden: if true, the notification is not displayed and does not cause any feedback to be invoked
* - \c x-nemo-user-removable: a boolean value for defining whether the user is able to remove the notification manually; otherwise it may only be removed programmatically. Defaults to true.
*
* \section howto How to use notifications in various use cases
Expand Down
36 changes: 14 additions & 22 deletions src/notifications/lipsticknotification.cpp
Expand Up @@ -21,6 +21,12 @@
#include <QDataStream>
#include <QtDebug>

namespace {
// deprecated
const char *HINT_ICON = "x-nemo-icon";
const char *HINT_PREVIEW_ICON = "x-nemo-preview-icon";
}

const char *LipstickNotification::HINT_URGENCY = "urgency";
const char *LipstickNotification::HINT_CATEGORY = "category";
const char *LipstickNotification::HINT_TRANSIENT = "transient";
Expand All @@ -30,11 +36,9 @@ const char *LipstickNotification::HINT_IMAGE_DATA = "image-data";
const char *LipstickNotification::HINT_SUPPRESS_SOUND = "suppress-sound";
const char *LipstickNotification::HINT_SOUND_FILE = "sound-file";
const char *LipstickNotification::HINT_APP_ICON = "app_icon";
const char *LipstickNotification::HINT_ICON = "x-nemo-icon";
const char *LipstickNotification::HINT_ITEM_COUNT = "x-nemo-item-count";
const char *LipstickNotification::HINT_PRIORITY = "x-nemo-priority";
const char *LipstickNotification::HINT_TIMESTAMP = "x-nemo-timestamp";
const char *LipstickNotification::HINT_PREVIEW_ICON = "x-nemo-preview-icon";
const char *LipstickNotification::HINT_PREVIEW_BODY = "x-nemo-preview-body";
const char *LipstickNotification::HINT_PREVIEW_SUMMARY = "x-nemo-preview-summary";
const char *LipstickNotification::HINT_SUB_TEXT = "x-nemo-sub-text";
Expand All @@ -44,10 +48,8 @@ const char *LipstickNotification::HINT_USER_REMOVABLE = "x-nemo-user-removable";
const char *LipstickNotification::HINT_FEEDBACK = "x-nemo-feedback";
const char *LipstickNotification::HINT_DISPLAY_ON = "x-nemo-display-on";
const char *LipstickNotification::HINT_SUPPRESS_DISPLAY_ON = "x-nemo-suppress-display-on";
const char *LipstickNotification::HINT_ORIGIN = "x-nemo-origin";
const char *LipstickNotification::HINT_ORIGIN_PACKAGE = "x-nemo-origin-package";
const char *LipstickNotification::HINT_OWNER = "x-nemo-owner";
const char *LipstickNotification::HINT_MAX_CONTENT_LINES = "x-nemo-max-content-lines";
const char *LipstickNotification::HINT_RESTORED = "x-nemo-restored";
const char *LipstickNotification::HINT_PROGRESS = "x-nemo-progress";
const char *LipstickNotification::HINT_VIBRA = "x-nemo-vibrate";
Expand Down Expand Up @@ -371,21 +373,11 @@ QVariantList LipstickNotification::remoteActions() const
return rv;
}

QString LipstickNotification::origin() const
{
return m_hints.value(LipstickNotification::HINT_ORIGIN).toString();
}

QString LipstickNotification::owner() const
{
return m_hints.value(LipstickNotification::HINT_OWNER).toString();
}

int LipstickNotification::maxContentLines() const
{
return m_hints.value(LipstickNotification::HINT_MAX_CONTENT_LINES).toInt();
}

bool LipstickNotification::restored() const
{
return m_hints.value(LipstickNotification::HINT_RESTORED).toBool();
Expand Down Expand Up @@ -437,12 +429,14 @@ void LipstickNotification::updateHintValues()
// Filter out the hints that are represented by other properties
const QString &hint(it.key());

if (hint == LipstickNotification::HINT_ICON) {
qWarning() << "Notification sets deprecated hint" << LipstickNotification::HINT_ICON
<< "to" << it.value() << ", use" << LipstickNotification::HINT_APP_ICON << "instead";
} else if (hint == LipstickNotification::HINT_PREVIEW_ICON) {
qWarning() << "Notification sets deprecated hint" << LipstickNotification::HINT_PREVIEW_ICON
<< "to" << it.value() << ", use" << LipstickNotification::HINT_APP_ICON << "instead";
if (hint == HINT_ICON) {
qWarning() << "Notification sets deprecated hint" << HINT_ICON
<< "to" << it.value() << ", use" << LipstickNotification::HINT_APP_ICON << "or"
<< LipstickNotification::HINT_IMAGE_PATH << "instead";
} else if (hint == HINT_PREVIEW_ICON) {
qWarning() << "Notification sets deprecated hint" << HINT_PREVIEW_ICON
<< "to" << it.value() << ", use" << LipstickNotification::HINT_APP_ICON << "or"
<< LipstickNotification::HINT_IMAGE_PATH << "instead";
}

if (hint.compare(LipstickNotification::HINT_APP_ICON, Qt::CaseInsensitive) != 0 &&
Expand All @@ -455,9 +449,7 @@ void LipstickNotification::updateHintValues()
hint.compare(LipstickNotification::HINT_PRIORITY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_CATEGORY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_USER_REMOVABLE, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_ORIGIN, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_OWNER, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_MAX_CONTENT_LINES, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_PROGRESS, Qt::CaseInsensitive) &&
!hint.startsWith(LipstickNotification::HINT_REMOTE_ACTION_PREFIX, Qt::CaseInsensitive) &&
!hint.startsWith(LipstickNotification::HINT_REMOTE_ACTION_ICON_PREFIX, Qt::CaseInsensitive)) {
Expand Down
20 changes: 0 additions & 20 deletions src/notifications/lipsticknotification.h
Expand Up @@ -49,9 +49,7 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
Q_PROPERTY(QString category READ category NOTIFY categoryChanged)
Q_PROPERTY(bool userRemovable READ isUserRemovable NOTIFY userRemovableChanged)
Q_PROPERTY(QVariantList remoteActions READ remoteActions CONSTANT)
Q_PROPERTY(QString origin READ origin CONSTANT)
Q_PROPERTY(QString owner READ owner CONSTANT)
Q_PROPERTY(int maxContentLines READ maxContentLines CONSTANT)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool hasProgress READ hasProgress NOTIFY hasProgressChanged)

Expand Down Expand Up @@ -85,9 +83,6 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Standard hint: Icon ID of the application sending the notification.
static const char *HINT_APP_ICON;

//! \obsolete use HINT_APP_ICON instead] Nemo hint: Icon of the notification.
static const char *HINT_ICON;

//! Nemo hint: Item count represented by the notification.
static const char *HINT_ITEM_COUNT;

Expand All @@ -97,9 +92,6 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Nemo hint: Timestamp of the notification.
static const char *HINT_TIMESTAMP;

//! \obsolete Nemo hint: Icon of the preview of the notification.
static const char *HINT_PREVIEW_ICON;

//! Nemo hint: Body text of the preview of the notification.
static const char *HINT_PREVIEW_BODY;

Expand Down Expand Up @@ -127,18 +119,12 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Nemo hint: Even if priority suggests it, do not turn display on
static const char *HINT_SUPPRESS_DISPLAY_ON;

//! Nemo hint: Indicates the origin of the notification
static const char *HINT_ORIGIN;

//! Nemo hint: Indicates the Android package name from which this notification originates
static const char *HINT_ORIGIN_PACKAGE;

//! Nemo hint: Indicates the identifer of the owner for notification
static const char *HINT_OWNER;

//! \obsolete Nemo hint: Specifies the maximum number of content lines to display (including summary)
static const char *HINT_MAX_CONTENT_LINES;

//! Nemo hint: Indicates that this notification has been restored from persistent storage since the last update.
//! Internal, shouldn't be expected or allowed from d-bus
static const char *HINT_RESTORED;
Expand Down Expand Up @@ -258,15 +244,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Returns the remote actions invokable by the notification
QVariantList remoteActions() const;

//! Returns an indicator for the origin of the notification
QString origin() const;

//! Returns an indicator for the notification owner
QString owner() const;

//! \obsolete Returns the maximum number of content lines requested for display
int maxContentLines() const;

//! Returns true if the notification has been restored since it was last modified
bool restored() const;

Expand Down
2 changes: 0 additions & 2 deletions src/notifications/notificationmanager.cpp
Expand Up @@ -206,8 +206,6 @@ QStringList NotificationManager::GetCapabilities()
<< LipstickNotification::HINT_PREVIEW_SUMMARY
<< "x-nemo-remote-actions"
<< LipstickNotification::HINT_USER_REMOVABLE
<< LipstickNotification::HINT_ORIGIN
<< LipstickNotification::HINT_MAX_CONTENT_LINES
<< "x-nemo-get-notifications";
}

Expand Down
2 changes: 0 additions & 2 deletions tests/ut_notificationmanager/ut_notificationmanager.cpp
Expand Up @@ -71,8 +71,6 @@ void Ut_NotificationManager::testCapabilities()
QCOMPARE((bool)capabilities.contains("x-nemo-remote-actions"), true);
QCOMPARE((bool)capabilities.contains(LipstickNotification::HINT_USER_REMOVABLE), true);
QCOMPARE((bool)capabilities.contains("x-nemo-get-notifications"), true);
QCOMPARE((bool)capabilities.contains(LipstickNotification::HINT_ORIGIN), true);
QCOMPARE((bool)capabilities.contains(LipstickNotification::HINT_MAX_CONTENT_LINES), true);
}

void Ut_NotificationManager::testRemovingInexistingNotification()
Expand Down

0 comments on commit a6d7586

Please sign in to comment.