Changeset View
Changeset View
Standalone View
Standalone View
plugins/notifications/notificationsdbusinterface.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 48 | { | |||
---|---|---|---|---|---|
51 | Q_EMIT allNotificationsRemoved(); | 51 | Q_EMIT allNotificationsRemoved(); | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | QStringList NotificationsDbusInterface::activeNotifications() | 54 | QStringList NotificationsDbusInterface::activeNotifications() | ||
55 | { | 55 | { | ||
56 | return m_notifications.keys(); | 56 | return m_notifications.keys(); | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | void NotificationsDbusInterface::processPackage(const NetworkPackage& np) | 59 | void NotificationsDbusInterface::processPacket(const NetworkPacket& np) | ||
60 | { | 60 | { | ||
61 | if (np.get<bool>(QStringLiteral("isCancel"))) { | 61 | if (np.get<bool>(QStringLiteral("isCancel"))) { | ||
62 | QString id = np.get<QString>(QStringLiteral("id")); | 62 | QString id = np.get<QString>(QStringLiteral("id")); | ||
63 | // cut off kdeconnect-android's prefix if there: | 63 | // cut off kdeconnect-android's prefix if there: | ||
64 | if (id.startsWith(QLatin1String("org.kde.kdeconnect_tp::"))) | 64 | if (id.startsWith(QLatin1String("org.kde.kdeconnect_tp::"))) | ||
65 | id = id.mid(id.indexOf(QLatin1String("::")) + 2); | 65 | id = id.mid(id.indexOf(QLatin1String("::")) + 2); | ||
66 | removeNotification(id); | 66 | removeNotification(id); | ||
67 | } else { | 67 | } else { | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 126 | { | |||
143 | //QDBusConnection::sessionBus().unregisterObject(mDevice->dbusPath()+"/notifications/"+publicId); | 143 | //QDBusConnection::sessionBus().unregisterObject(mDevice->dbusPath()+"/notifications/"+publicId); | ||
144 | noti->deleteLater(); | 144 | noti->deleteLater(); | ||
145 | 145 | | |||
146 | Q_EMIT notificationRemoved(publicId); | 146 | Q_EMIT notificationRemoved(publicId); | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | void NotificationsDbusInterface::dismissRequested(const QString& internalId) | 149 | void NotificationsDbusInterface::dismissRequested(const QString& internalId) | ||
150 | { | 150 | { | ||
151 | NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REQUEST); | 151 | NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST); | ||
152 | np.set<QString>(QStringLiteral("cancel"), internalId); | 152 | np.set<QString>(QStringLiteral("cancel"), internalId); | ||
153 | m_plugin->sendPackage(np); | 153 | m_plugin->sendPacket(np); | ||
154 | 154 | | |||
155 | //Workaround: we erase notifications without waiting a repsonse from the | 155 | //Workaround: we erase notifications without waiting a repsonse from the | ||
156 | //phone because we won't receive a response if we are out of sync and this | 156 | //phone because we won't receive a response if we are out of sync and this | ||
157 | //notification no longer exists. Ideally, each time we reach the phone | 157 | //notification no longer exists. Ideally, each time we reach the phone | ||
158 | //after some time disconnected we should re-sync all the notifications. | 158 | //after some time disconnected we should re-sync all the notifications. | ||
159 | removeNotification(internalId); | 159 | removeNotification(internalId); | ||
160 | } | 160 | } | ||
161 | 161 | | |||
162 | void NotificationsDbusInterface::replyRequested(Notification* noti) | 162 | void NotificationsDbusInterface::replyRequested(Notification* noti) | ||
163 | { | 163 | { | ||
164 | QString replyId = noti->replyId(); | 164 | QString replyId = noti->replyId(); | ||
165 | QString appName = noti->appName(); | 165 | QString appName = noti->appName(); | ||
166 | QString originalMessage = noti->ticker(); | 166 | QString originalMessage = noti->ticker(); | ||
167 | SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName); | 167 | SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName); | ||
168 | connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply); | 168 | connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply); | ||
169 | dialog->show(); | 169 | dialog->show(); | ||
170 | dialog->raise(); | 170 | dialog->raise(); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message) | 173 | void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message) | ||
174 | { | 174 | { | ||
175 | NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REPLY); | 175 | NetworkPacket np(PACKET_TYPE_NOTIFICATION_REPLY); | ||
176 | np.set<QString>(QStringLiteral("requestReplyId"), replyId); | 176 | np.set<QString>(QStringLiteral("requestReplyId"), replyId); | ||
177 | np.set<QString>(QStringLiteral("message"), message); | 177 | np.set<QString>(QStringLiteral("message"), message); | ||
178 | m_plugin->sendPackage(np); | 178 | m_plugin->sendPacket(np); | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | QString NotificationsDbusInterface::newId() | 181 | QString NotificationsDbusInterface::newId() | ||
182 | { | 182 | { | ||
183 | return QString::number(++m_lastId); | 183 | return QString::number(++m_lastId); | ||
184 | } | 184 | } |