[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdeconnect-kde/sms-history] plugins/telephony: Remove notifications from Telephony plugin
From: Simon Redman <null () kde ! org>
Date: 2018-04-01 3:20:57
Message-ID: E1f2TY9-0005kJ-UT () code ! kde ! org
[Download RAW message or body]
Git commit ff3006fdff48fb3009cb7fb9d86d131f20235e28 by Simon Redman.
Committed on 01/04/2018 at 03:20.
Pushed by sredman into branch 'sms-history'.
Remove notifications from Telephony plugin
M +0 -87 plugins/telephony/telephonyplugin.cpp
M +0 -4 plugins/telephony/telephonyplugin.h
https://commits.kde.org/kdeconnect-kde/ff3006fdff48fb3009cb7fb9d86d131f20235e28
diff --git a/plugins/telephony/telephonyplugin.cpp \
b/plugins/telephony/telephonyplugin.cpp index 3a015a82..6f20100d 100644
--- a/plugins/telephony/telephonyplugin.cpp
+++ b/plugins/telephony/telephonyplugin.cpp
@@ -22,8 +22,6 @@
#include "sendreplydialog.h"
-#include <KLocalizedString>
-#include <QIcon>
#include <QDebug>
#include <QDBusReply>
@@ -39,88 +37,6 @@ TelephonyPlugin::TelephonyPlugin(QObject* parent, const \
QVariantList& args) {
}
-KNotification* TelephonyPlugin::createNotification(const NetworkPacket& np)
-{
- const QString event = np.get<QString>(QStringLiteral("event"));
- const QString phoneNumber = np.get<QString>(QStringLiteral("phoneNumber"), \
i18n("unknown number"));
- const QString contactName = np.get<QString>(QStringLiteral("contactName"), \
phoneNumber);
- const QByteArray phoneThumbnail = \
QByteArray::fromBase64(np.get<QByteArray>(QStringLiteral("phoneThumbnail"), \
""));
-
- // In case telepathy can handle the message, don't do anything else
- if (event == QLatin1String("sms") && m_telepathyInterface.isValid()) {
- qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Passing a text message to the \
telepathy interface";
- connect(&m_telepathyInterface, SIGNAL(messageReceived(QString,QString)), \
SLOT(sendSms(QString,QString)), Qt::UniqueConnection);
- const QString messageBody = \
np.get<QString>(QStringLiteral("messageBody"),QLatin1String(""));
- QDBusReply<bool> reply = \
m_telepathyInterface.call(QStringLiteral("sendMessage"), phoneNumber, contactName, \
messageBody);
- if (reply) {
- return nullptr;
- } else {
- qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Telepathy failed, falling back \
to the default handling";
- }
- }
-
- QString content, type, icon;
- KNotification::NotificationFlags flags = KNotification::CloseOnTimeout;
-
- const QString title = device()->name();
-
- if (event == QLatin1String("ringing")) {
- type = QStringLiteral("callReceived");
- icon = QStringLiteral("call-start");
- content = i18n("Incoming call from %1", contactName);
- } else if (event == QLatin1String("missedCall")) {
- type = QStringLiteral("missedCall");
- icon = QStringLiteral("call-start");
- content = i18n("Missed call from %1", contactName);
- flags |= KNotification::Persistent; //Note that in Unity this generates a \
message box!
- } else if (event == QLatin1String("sms")) {
- type = QStringLiteral("smsReceived");
- icon = QStringLiteral("mail-receive");
- QString messageBody = np.get<QString>(QStringLiteral("messageBody"), \
QLatin1String(""));
- content = i18n("SMS from %1<br>%2", contactName, messageBody);
- flags |= KNotification::Persistent; //Note that in Unity this generates a \
message box!
- } else if (event == QLatin1String("talking")) {
- return nullptr;
- } else {
-#ifndef NDEBUG
- return nullptr;
-#else
- type = QStringLiteral("callReceived");
- icon = QStringLiteral("phone");
- content = i18n("Unknown telephony event: %1", event);
-#endif
- }
-
- qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Creating notification with type:" << \
type;
-
- KNotification* notification = new KNotification(type, flags, this);
- if (!phoneThumbnail.isEmpty()) {
- QPixmap photo;
- photo.loadFromData(phoneThumbnail, "JPEG");
- notification->setPixmap(photo);
- } else {
- notification->setIconName(icon);
- }
- notification->setComponentName(QStringLiteral("kdeconnect"));
- notification->setTitle(title);
- notification->setText(content);
-
- if (event == QLatin1String("ringing")) {
- notification->setActions( QStringList(i18n("Mute Call")) );
- connect(notification, &KNotification::action1Activated, this, \
&TelephonyPlugin::sendMutePacket);
- } else if (event == QLatin1String("sms")) {
- const QString messageBody = \
np.get<QString>(QStringLiteral("messageBody"),QLatin1String(""));
- notification->setActions( QStringList(i18n("Reply")) );
- notification->setProperty("phoneNumber", phoneNumber);
- notification->setProperty("contactName", contactName);
- notification->setProperty("originalMessage", messageBody);
- connect(notification, &KNotification::action1Activated, this, \
&TelephonyPlugin::showSendSmsDialog);
- }
-
- return notification;
-
-}
-
bool TelephonyPlugin::receivePacket(const NetworkPacket& np)
{
if (np.get<bool>(QStringLiteral("isCancel"))) {
@@ -129,9 +45,6 @@ bool TelephonyPlugin::receivePacket(const NetworkPacket& np)
return true;
}
- KNotification* n = createNotification(np);
- if (n != nullptr) n->sendEvent();
-
return true;
}
diff --git a/plugins/telephony/telephonyplugin.h \
b/plugins/telephony/telephonyplugin.h index 43fb22fc..c07c4fd2 100644
--- a/plugins/telephony/telephonyplugin.h
+++ b/plugins/telephony/telephonyplugin.h
@@ -24,8 +24,6 @@
#include <QLoggingCategory>
#include <QDBusInterface>
-#include <KNotification>
-
#include <core/kdeconnectplugin.h>
#define PACKET_TYPE_TELEPHONY_REQUEST QStringLiteral("kdeconnect.telephony.request")
@@ -60,8 +58,6 @@ private Q_SLOTS:
void showSendSmsDialog();
private:
- KNotification* createNotification(const NetworkPacket& np);
-
QDBusInterface m_telepathyInterface;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic