File indexing completed on 2024-04-21 03:59:51

0001 /*
0002     SPDX-FileCopyrightText: 2013 Anant Kamath <kamathanant@gmail.com>
0003     SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
0004     SPDX-FileCopyrightText: 2013-2015 Jan Grulich <jgrulich@redhat.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef MODEMMANAGERQT_MODEMMESSAGING_H
0010 #define MODEMMANAGERQT_MODEMMESSAGING_H
0011 
0012 #include <modemmanagerqt_export.h>
0013 
0014 #include <QObject>
0015 #include <QSharedPointer>
0016 
0017 #include "generictypes.h"
0018 #include "interface.h"
0019 #include "sms.h"
0020 
0021 namespace ModemManager
0022 {
0023 class ModemMessagingPrivate;
0024 
0025 /**
0026  * @brief The ModemMessaging class
0027  *
0028  * The Messaging interface handles sending SMS messages and notification of new incoming messages.
0029  */
0030 class MODEMMANAGERQT_EXPORT ModemMessaging : public Interface
0031 {
0032     Q_OBJECT
0033     Q_DECLARE_PRIVATE(ModemMessaging)
0034 
0035 public:
0036     struct Message {
0037         QString number;
0038         QString text;
0039         QByteArray data;
0040     };
0041 
0042     typedef QSharedPointer<ModemMessaging> Ptr;
0043     typedef QList<Ptr> List;
0044 
0045     explicit ModemMessaging(const QString &path, QObject *parent = nullptr);
0046     ~ModemMessaging() override;
0047 
0048     /**
0049      * @return A list of MMSmsStorage values, specifying the storages supported by this
0050      * modem for storing and receiving SMS.
0051      */
0052     QList<MMSmsStorage> supportedStorages() const;
0053 
0054     /**
0055      * @return A MMSmsStorage value, specifying the storage to be used when receiving or storing SMS.
0056      */
0057     MMSmsStorage defaultStorage() const;
0058 
0059     /**
0060      * Retrieve all SMS messages.
0061      *
0062      * This method should only be used once and subsequent information retrieved
0063      * either by listening for the messageAdded() signal, or by
0064      * querying the specific SMS object of interest using findMessage()
0065      */
0066     ModemManager::Sms::List messages() const;
0067 
0068     /**
0069      * Creates a new message object.
0070      * @param message Message structure with the 'number' and either 'text' or 'data' properties
0071      */
0072     QDBusPendingReply<QDBusObjectPath> createMessage(const Message &message);
0073     /**
0074      * Creates a new message object.
0075      * @param message QVariantMap containing message properties
0076      * The 'number' and either 'text' or 'data' properties are mandatory, others are optional.
0077      */
0078     QDBusPendingReply<QDBusObjectPath> createMessage(const QVariantMap &message);
0079 
0080     /**
0081      * Delete an SMS message.
0082      *
0083      * @param uni path to the Sms object
0084      */
0085     QDBusPendingReply<void> deleteMessage(const QString &uni);
0086 
0087     /**
0088      * @param uni path to the Sms object
0089      * @return pointer to the found Sms (may be null if not found)
0090      */
0091     ModemManager::Sms::Ptr findMessage(const QString &uni);
0092 
0093     /**
0094      * Sets the timeout in milliseconds for all async method DBus calls.
0095      * -1 means the default DBus timeout (usually 25 seconds).
0096      */
0097     void setTimeout(int timeout);
0098 
0099     /**
0100      * Returns the current value of the DBus timeout in milliseconds.
0101      * -1 means the default DBus timeout (usually 25 seconds).
0102      */
0103     int timeout() const;
0104 
0105 Q_SIGNALS:
0106     /**
0107      * Emitted when any part of a new SMS has been received or added (but not
0108      * for subsequent parts, if any). For messages received from the network,
0109      * not all parts may have been received and the message may not be
0110      * complete.
0111      *
0112      * Check the 'State' property to determine if the message is complete.
0113      *
0114      * @param uni path to the Sms object
0115      * @param received @p true if the message was received from the network, as opposed to being added locally.
0116      */
0117     void messageAdded(const QString &uni, bool received);
0118 
0119     /**
0120      * Emitted when a message has been deleted.
0121      * @param uni path to the Sms object
0122      */
0123     void messageDeleted(const QString &uni);
0124 };
0125 
0126 } // namespace ModemManager
0127 
0128 #endif