[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:28:57 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=866fdfb
The following commit has been merged in the master branch:
commit 866fdfb33fed7b93108efea97b2e2201f9750fa9
Author: Gaël Le Baccon <gael.lebaccon at gmail.com>
Date: Tue Sep 8 01:05:58 2015 -0700
Added a simple way to answer SMS messages from the notification
---
plugins/telephony/CMakeLists.txt | 1 +
plugins/telephony/sendsmsdialog.cpp | 64 ++++++++++++++++++++++
.../telephony/sendsmsdialog.h | 35 ++++++------
plugins/telephony/telephonyplugin.cpp | 44 +++++++++++----
plugins/telephony/telephonyplugin.h | 4 ++
5 files changed, 119 insertions(+), 29 deletions(-)
diff --git a/plugins/telephony/CMakeLists.txt b/plugins/telephony/CMakeLists.txt
index 7c8958c..e52da29 100644
--- a/plugins/telephony/CMakeLists.txt
+++ b/plugins/telephony/CMakeLists.txt
@@ -2,6 +2,7 @@ find_package(KF5 REQUIRED COMPONENTS Notifications)
set(kdeconnect_telephony_SRCS
telephonyplugin.cpp
+ sendsmsdialog.cpp
)
kdeconnect_add_plugin(kdeconnect_telephony JSON kdeconnect_telephony.json SOURCES ${kdeconnect_telephony_SRCS})
diff --git a/plugins/telephony/sendsmsdialog.cpp b/plugins/telephony/sendsmsdialog.cpp
new file mode 100644
index 0000000..f0be323
--- /dev/null
+++ b/plugins/telephony/sendsmsdialog.cpp
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2015 Albert Vaca <albertvaka at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "sendsmsdialog.h"
+
+#include <QPushButton>
+#include <QTextEdit>
+#include <QLineEdit>
+#include <QBoxLayout>
+
+#include <KLocalizedString>
+
+SendSmsDialog::SendSmsDialog(const QString& originalMessage, const QString& phoneNumber, const QString& contactName, QWidget* parent)
+ : QDialog(parent)
+ , mPhoneNumber(phoneNumber)
+{
+ QVBoxLayout* layout = new QVBoxLayout;
+
+ QTextEdit* textView = new QTextEdit(this);
+ textView->setReadOnly(true);
+ textView->setText(contactName + ":
" + originalMessage);
+ layout->addWidget(textView);
+
+ mTextEdit = new QTextEdit(this);
+ layout->addWidget(mTextEdit);
+
+ QPushButton* sendButton = new QPushButton(i18n("Send"), this);
+ connect(sendButton, SIGNAL(clicked(bool)), SLOT(sendButtonClicked()));
+ layout->addWidget(sendButton);
+
+ setLayout(layout);
+ setWindowTitle(contactName);
+ setWindowIcon(QIcon::fromTheme("kdeconnect"));
+ setAttribute(Qt::WA_DeleteOnClose);
+}
+
+
+void SendSmsDialog::sendButtonClicked()
+{
+ emit sendSms(mPhoneNumber, mTextEdit->toPlainText());
+ close();
+}
+
+QSize SendSmsDialog::sizeHint() const
+{
+ return QSize(512, 64);
+}
diff --git a/core/backends/lan/landevicelink.h b/plugins/telephony/sendsmsdialog.h
similarity index 61%
copy from core/backends/lan/landevicelink.h
copy to plugins/telephony/sendsmsdialog.h
index 7d31881..90acb1a 100644
--- a/core/backends/lan/landevicelink.h
+++ b/plugins/telephony/sendsmsdialog.h
@@ -1,5 +1,5 @@
/**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ * Copyright 2015 Albert Vaca <albertvaka at gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,34 +18,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef LANDEVICELINK_H
-#define LANDEVICELINK_H
+#ifndef SENDSMSDIALOG_H
+#define SENDSMSDIALOG_H
-#include <QObject>
-#include <QString>
-#include <QTcpSocket>
+#include <QDialog>
+#include <QSize>
-#include "../devicelink.h"
+class QTextEdit;
+class QLineEdit;
+class QPushButton;
-class SocketLineReader;
-
-class LanDeviceLink
- : public DeviceLink
+class SendSmsDialog : public QDialog
{
Q_OBJECT
public:
- LanDeviceLink(const QString& deviceId, LinkProvider* parent, QTcpSocket* socket);
-
- bool sendPackage(NetworkPackage& np);
- bool sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& np);
+ explicit SendSmsDialog(const QString& originalMessage, const QString& phoneNumber, const QString& contactName, QWidget *parent = 0);
+ virtual QSize sizeHint() const;
private Q_SLOTS:
- void dataReceived();
+ void sendButtonClicked();
-private:
- SocketLineReader* mSocketLineReader;
+Q_SIGNALS:
+ void sendSms(const QString& phoneNumber, const QString& messageBody);
+private:
+ QString mPhoneNumber;
+ QTextEdit *mTextEdit;
};
#endif
diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp
index 157121a..d4f8793 100644
--- a/plugins/telephony/telephonyplugin.cpp
+++ b/plugins/telephony/telephonyplugin.cpp
@@ -20,13 +20,14 @@
#include "telephonyplugin.h"
+#include "sendsmsdialog.h"
+
#include <KLocalizedString>
#include <QIcon>
#include <QDebug>
#include <KPluginFactory>
-
K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_telephony.json", registerPlugin< TelephonyPlugin >(); )
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_TELEPHONY, "kdeconnect.plugin.telephony")
@@ -39,29 +40,29 @@ TelephonyPlugin::TelephonyPlugin(QObject *parent, const QVariantList &args)
KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
{
-
const QString event = np.get<QString>("event");
const QString phoneNumber = np.get<QString>("phoneNumber", i18n("unknown number"));
+ const QString contactName = np.get<QString>("contactName", phoneNumber);
QString content, type, icon;
- KNotification::NotificationFlags flags = KNotification::CloseOnTimeout;
+ KNotification::NotificationFlags flags = KNotification::CloseOnTimeout | KNotification::CloseWhenWidgetActivated;
const QString title = device()->name();
if (event == "ringing") {
type = QStringLiteral("callReceived");
icon = QStringLiteral("call-start");
- content = i18n("Incoming call from %1", phoneNumber);
+ content = i18n("Incoming call from %1", contactName);
} else if (event == "missedCall") {
type = QStringLiteral("missedCall");
icon = QStringLiteral("call-start");
- content = i18n("Missed call from %1", phoneNumber);
+ content = i18n("Missed call from %1", contactName);
flags |= KNotification::Persistent;
} else if (event == "sms") {
type = QStringLiteral("smsReceived");
icon = QStringLiteral("mail-receive");
QString messageBody = np.get<QString>("messageBody","");
- content = i18n("SMS from %1<br>%2", phoneNumber, messageBody);
+ content = i18n("SMS from %1<br>%2", contactName, messageBody);
flags |= KNotification::Persistent;
} else if (event == "talking") {
return NULL;
@@ -86,6 +87,12 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
if (event == QLatin1String("ringing")) {
notification->setActions( QStringList(i18n("Mute Call")) );
connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePackage);
+ } else if (event == QLatin1String("sms")) {
+ notification->setActions( QStringList(i18n("Reply")) );
+ notification->setProperty("phoneNumber", phoneNumber);
+ notification->setProperty("contactName", contactName);
+ notification->setProperty("originalMessage", np.get<QString>("messageBody",""));
+ connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::showSendSmsDialog);
}
return notification;
@@ -96,15 +103,11 @@ bool TelephonyPlugin::receivePackage(const NetworkPackage& np)
{
if (np.get<bool>("isCancel")) {
- //It would be awesome to remove the old notification from the system tray here, but there is no way to do it :(
- //Now I realize why at the end of the day I have hundreds of notifications from facebook messages that I HAVE ALREADY READ,
- //...it's just because the telepathy client has no way to remove them! even when it knows that I have read those messages!
+ //TODO: Clear the old notification
} else {
-
KNotification* n = createNotification(np);
if (n != NULL) n->sendEvent();
-
}
return true;
@@ -118,4 +121,23 @@ void TelephonyPlugin::sendMutePackage()
sendPackage(package);
}
+void TelephonyPlugin::sendSms(const QString& phoneNumber, const QString& messageBody)
+{
+ NetworkPackage np(PACKAGE_TYPE_TELEPHONY);
+ np.set("sendSms", true);
+ np.set("phoneNumber", phoneNumber);
+ np.set("messageBody", messageBody);
+ sendPackage(np);
+}
+
+void TelephonyPlugin::showSendSmsDialog()
+{
+ QString phoneNumber = sender()->property("phoneNumber").toString();
+ QString contactName = sender()->property("contactName").toString();
+ QString originalMessage = sender()->property("originalMessage").toString();
+ SendSmsDialog* dialog = new SendSmsDialog(originalMessage, phoneNumber, contactName);
+ connect(dialog, SIGNAL(sendSms(QString,QString)), this, SLOT(sendSms(QString,QString)));
+ dialog->show();
+}
+
#include "telephonyplugin.moc"
diff --git a/plugins/telephony/telephonyplugin.h b/plugins/telephony/telephonyplugin.h
index ce74e9e..520b991 100644
--- a/plugins/telephony/telephonyplugin.h
+++ b/plugins/telephony/telephonyplugin.h
@@ -44,6 +44,10 @@ public Q_SLOTS:
virtual void connected() { }
void sendMutePackage();
+private Q_SLOTS:
+ void sendSms(const QString& phoneNumber, const QString& messageBody);
+ void showSendSmsDialog();
+
private:
KNotification* createNotification(const NetworkPackage& np);
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list