| 1 |
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "dnotifysender.h" |
| 6 |
#include "ddbussender.h" |
| 7 |
|
| 8 |
DCORE_BEGIN_NAMESPACE |
| 9 |
|
| 10 |
namespace DUtil { |
| 11 |
|
| 12 |
struct DNotifyData { |
| 13 |
uint m_replaceId; |
| 14 |
int m_timeOut; |
| 15 |
QString m_body; |
| 16 |
QString m_summary; |
| 17 |
QString m_appIcon; |
| 18 |
QString m_appName; |
| 19 |
QStringList m_actions; |
| 20 |
QVariantMap m_hints; |
| 21 |
}; |
| 22 |
|
| 23 |
DNotifySender::DNotifySender(const QString &summary) : m_dbusData(std::make_shared<DNotifyData>()) |
| 24 |
{ |
| 25 |
m_dbusData->m_summary = summary; |
| 26 |
} |
| 27 |
|
| 28 |
DNotifySender DNotifySender::appName(const QString &appName) |
| 29 |
{ |
| 30 |
m_dbusData->m_appName = appName; |
| 31 |
|
| 32 |
return *this; |
| 33 |
} |
| 34 |
|
| 35 |
DNotifySender DNotifySender::appIcon(const QString &appIcon) |
| 36 |
{ |
| 37 |
m_dbusData->m_appIcon = appIcon; |
| 38 |
|
| 39 |
return *this; |
| 40 |
} |
| 41 |
|
| 42 |
DNotifySender DNotifySender::appBody(const QString &appBody) |
| 43 |
{ |
| 44 |
m_dbusData->m_body = appBody; |
| 45 |
|
| 46 |
return *this; |
| 47 |
} |
| 48 |
|
| 49 |
DNotifySender DNotifySender::replaceId(const uint replaceId) |
| 50 |
{ |
| 51 |
m_dbusData->m_replaceId = replaceId; |
| 52 |
|
| 53 |
return *this; |
| 54 |
} |
| 55 |
|
| 56 |
DNotifySender DNotifySender::timeOut(const int timeOut) |
| 57 |
{ |
| 58 |
m_dbusData->m_timeOut = timeOut; |
| 59 |
|
| 60 |
return *this; |
| 61 |
} |
| 62 |
|
| 63 |
DNotifySender DNotifySender::actions(const QStringList &actions) |
| 64 |
{ |
| 65 |
m_dbusData->m_actions = actions; |
| 66 |
|
| 67 |
return *this; |
| 68 |
} |
| 69 |
|
| 70 |
DNotifySender DNotifySender::hints(const QVariantMap &hints) |
| 71 |
{ |
| 72 |
m_dbusData->m_hints = hints; |
| 73 |
|
| 74 |
return *this; |
| 75 |
} |
| 76 |
|
| 77 |
QDBusPendingCall DNotifySender::call() |
| 78 |
{ |
| 79 |
return DDBusSender() |
| 80 |
.service("org.freedesktop.Notifications") |
| 81 |
.path("/org/freedesktop/Notifications") |
| 82 |
.interface("org.freedesktop.Notifications") |
| 83 |
.method(QString("Notify")) |
| 84 |
.arg(m_dbusData->m_appName) |
| 85 |
.arg(m_dbusData->m_replaceId) |
| 86 |
.arg(m_dbusData->m_appIcon) |
| 87 |
.arg(m_dbusData->m_summary) |
| 88 |
.arg(m_dbusData->m_body) |
| 89 |
.arg(m_dbusData->m_actions) |
| 90 |
.arg(m_dbusData->m_hints) |
| 91 |
.arg(m_dbusData->m_timeOut) |
| 92 |
.call(); |
| 93 |
} |
| 94 |
|
| 95 |
} // namespace DUtil |
| 96 |
|
| 97 |
DCORE_END_NAMESPACE |