File indexing completed on 2024-04-28 08:49:13

0001 /**
0002  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
0003  * SPDX-FileCopyrightText: 2018 Simon Redman <simon@ergotech.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 #pragma once
0009 
0010 #include <QPointer>
0011 
0012 #include <KNotification>
0013 
0014 #include <core/kdeconnectplugin.h>
0015 
0016 /**
0017  * Packet used for simple telephony events
0018  *
0019  * It contains the key "event" which maps to a string indicating the type of event:
0020  *  - "ringing" - A phone call is incoming
0021  *  - "missedCall" - An incoming call was not answered
0022  *
0023  * Historically, "sms" was a valid event, but support for that has been dropped in favour
0024  * of the SMS plugin's more expressive interfaces
0025  *
0026  * Depending on the event, other fields may be defined
0027  */
0028 #define PACKET_TYPE_TELEPHONY QStringLiteral("kdeconnect.telephony")
0029 
0030 #define PACKET_TYPE_TELEPHONY_REQUEST_MUTE QStringLiteral("kdeconnect.telephony.request_mute")
0031 
0032 class TelephonyPlugin : public KdeConnectPlugin
0033 {
0034     Q_OBJECT
0035     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony")
0036 
0037 public:
0038     using KdeConnectPlugin::KdeConnectPlugin;
0039 
0040     void receivePacket(const NetworkPacket &np) override;
0041     QString dbusPath() const override;
0042 
0043 public:
0044 Q_SIGNALS:
0045     Q_SCRIPTABLE void callReceived(const QString &event, const QString &number, const QString contactName);
0046 
0047 private Q_SLOTS:
0048     void sendMutePacket();
0049 
0050 private:
0051     /**
0052      * Create a notification for:
0053      *  - Incoming call (with the option to mute the ringing)
0054      *  - Missed call
0055      */
0056     void createNotification(const NetworkPacket &np);
0057 
0058     QPointer<KNotification> m_currentCallNotification;
0059 };