Changeset View
Changeset View
Standalone View
Standalone View
plugins/notifications/notificationsdbusinterface.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | void NotificationsDbusInterface::processPacket(const NetworkPacket& np) | 69 | void NotificationsDbusInterface::processPacket(const NetworkPacket& np) | ||
70 | { | 70 | { | ||
71 | if (np.get<bool>(QStringLiteral("isCancel"))) { | 71 | if (np.get<bool>(QStringLiteral("isCancel"))) { | ||
72 | QString id = np.get<QString>(QStringLiteral("id")); | 72 | QString id = np.get<QString>(QStringLiteral("id")); | ||
73 | // cut off kdeconnect-android's prefix if there: | 73 | // cut off kdeconnect-android's prefix if there: | ||
74 | if (id.startsWith(QLatin1String("org.kde.kdeconnect_tp::"))) | 74 | if (id.startsWith(QLatin1String("org.kde.kdeconnect_tp::"))) | ||
75 | id = id.mid(id.indexOf(QLatin1String("::")) + 2); | 75 | id = id.mid(id.indexOf(QLatin1String("::")) + 2); | ||
76 | removeNotification(id); | 76 | removeNotification(id); | ||
77 | } else { | 77 | return; | ||
78 | } | ||||
79 | | ||||
78 | QString id = np.get<QString>(QStringLiteral("id")); | 80 | QString id = np.get<QString>(QStringLiteral("id")); | ||
79 | 81 | | |||
82 | Notification* noti = nullptr; | ||||
83 | | ||||
80 | if (!m_internalIdToPublicId.contains(id)) { | 84 | if (!m_internalIdToPublicId.contains(id)) { | ||
81 | Notification* noti = new Notification(np, this); | 85 | noti = new Notification(np, this); | ||
82 | 86 | | |||
83 | if (noti->isReady()) { | 87 | if (noti->isReady()) { | ||
84 | addNotification(noti); | 88 | addNotification(noti); | ||
85 | } else { | 89 | } else { | ||
86 | connect(noti, &Notification::ready, this, &NotificationsDbusInterface::notificationReady); | 90 | connect(noti, &Notification::ready, this, &NotificationsDbusInterface::notificationReady); | ||
87 | } | 91 | } | ||
88 | } else { | 92 | } else { | ||
89 | QString pubId = m_internalIdToPublicId.value(id); | 93 | QString pubId = m_internalIdToPublicId.value(id); | ||
90 | Notification* noti = m_notifications.value(pubId); | 94 | noti = m_notifications.value(pubId); | ||
91 | if (!noti) | | |||
92 | return; | | |||
93 | | ||||
94 | noti->update(np); | | |||
95 | | ||||
96 | if (noti->isReady()) { | | |||
97 | Q_EMIT notificationUpdated(pubId); | | |||
98 | } else { | | |||
99 | connect(noti, &Notification::ready, this, [this, pubId]{ | | |||
100 | Q_EMIT notificationUpdated(pubId); | | |||
101 | }); | | |||
102 | } | | |||
103 | } | | |||
104 | | ||||
105 | } | 95 | } | ||
96 | noti->update(np); | ||||
106 | } | 97 | } | ||
107 | 98 | | |||
108 | void NotificationsDbusInterface::addNotification(Notification* noti) | 99 | void NotificationsDbusInterface::addNotification(Notification* noti) | ||
109 | { | 100 | { | ||
110 | const QString& internalId = noti->internalId(); | 101 | const QString& internalId = noti->internalId(); | ||
111 | 102 | | |||
112 | if (m_internalIdToPublicId.contains(internalId)) { | 103 | if (m_internalIdToPublicId.contains(internalId)) { | ||
113 | removeNotification(internalId); | 104 | removeNotification(internalId); | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |