File indexing completed on 2025-02-02 14:20:54
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_SMS_H 0010 #define MODEMMANAGERQT_SMS_H 0011 0012 #include <modemmanagerqt_export.h> 0013 0014 #include <QDBusPendingReply> 0015 #include <QObject> 0016 #include <QSharedPointer> 0017 0018 #include "generictypes.h" 0019 0020 namespace ModemManager 0021 { 0022 class SmsPrivate; 0023 0024 /** 0025 * Provides an interface to manipulate and control an SMS 0026 * 0027 * Note: MMSmsStorage, MMSmsState, MMSmsPduType and MMSmsDeliveryState enums are defined in <ModemManager/ModemManager-enums.h> 0028 * See http://www.freedesktop.org/software/ModemManager/api/1.0.0/ModemManager-Flags-and-Enumerations.html 0029 */ 0030 class MODEMMANAGERQT_EXPORT Sms : public QObject 0031 { 0032 Q_OBJECT 0033 Q_DECLARE_PRIVATE(Sms) 0034 0035 public: 0036 typedef QSharedPointer<Sms> Ptr; 0037 typedef QList<Ptr> List; 0038 0039 explicit Sms(const QString &path, QObject *parent = nullptr); 0040 ~Sms() override; 0041 0042 QString uni() const; 0043 0044 /** 0045 * Send the SMS 0046 */ 0047 QDBusPendingReply<> send(); 0048 0049 /** 0050 * Store the SMS 0051 * 0052 * @param storage the storage location of the SMS (empty for default storage) 0053 */ 0054 QDBusPendingReply<> store(MMSmsStorage storage = MM_SMS_STORAGE_UNKNOWN); 0055 0056 /** 0057 * This method returns the state of the SMS 0058 */ 0059 MMSmsState state() const; 0060 0061 /** 0062 * This method returns the Protocol Data Unit (PDU) type of the SMS 0063 */ 0064 MMSmsPduType pduType() const; 0065 0066 /** 0067 * This method returns the phone number to which the SMS is addressed to 0068 */ 0069 QString number() const; 0070 0071 /** 0072 * This method returns the text of the SMS. text() and data() are not valid at the same time 0073 */ 0074 QString text() const; 0075 0076 /** 0077 * This method returns the SMS service center number 0078 */ 0079 QString SMSC() const; 0080 0081 /** 0082 * This method returns the SMS message data. text() and data() are not valid at the same time 0083 */ 0084 QByteArray data() const; 0085 0086 /** 0087 * This method returns the validity of the SMS 0088 * 0089 * @return A ValidityPair struct composed of a MMSmsValidityType type and a value indicating the validity of the SMS 0090 */ 0091 ValidityPair validity() const; 0092 0093 /** 0094 * This method returns the 3GPP class of the SMS 0095 */ 0096 int smsClass() const; 0097 0098 /** 0099 * @return @c true if a delivery report is requested, @c false otherwise 0100 */ 0101 bool deliveryReportRequest() const; 0102 0103 /** 0104 * This method returns the message reference of the last PDU sent/received in the SMS. 0105 * The message reference is the number used to identify the SMS in the SMSC. 0106 * If the PDU type is MM_SMS_PDU_TYPE_STATUS_REPORT, this field identifies the Message Reference of the PDU associated to the status report 0107 */ 0108 uint messageReference() const; 0109 0110 /** 0111 * Time when the SMS arrived at the SMSC 0112 */ 0113 QDateTime timestamp() const; 0114 0115 /** 0116 * Time when the SMS left the SMSC 0117 */ 0118 QDateTime dischargeTimestamp() const; 0119 0120 /** 0121 * This method returns the delivery state of the SMS 0122 */ 0123 MMSmsDeliveryState deliveryState() const; 0124 0125 /** 0126 * This method returns the storage area/location of the SMS 0127 */ 0128 MMSmsStorage storage() const; 0129 #if MM_CHECK_VERSION(1, 2, 0) 0130 /** 0131 * @return service category for CDMA SMS, as defined in 3GPP2 C.R1001-D (section 9.3). 0132 * @since 1.1.91 0133 */ 0134 MMSmsCdmaServiceCategory serviceCategory() const; 0135 0136 /** 0137 * @return teleservice IDs supported for CDMA SMS, as defined in 3GPP2 X.S0004-550-E 0138 * (section 2.256) and 3GPP2 C.S0015-B (section 3.4.3.1) 0139 * @since 1.1.91 0140 */ 0141 MMSmsCdmaTeleserviceId teleserviceId() const; 0142 #endif 0143 0144 /** 0145 * Sets the timeout in milliseconds for all async method DBus calls. 0146 * -1 means the default DBus timeout (usually 25 seconds). 0147 */ 0148 void setTimeout(int timeout); 0149 0150 /** 0151 * Returns the current value of the DBus timeout in milliseconds. 0152 * -1 means the default DBus timeout (usually 25 seconds). 0153 */ 0154 int timeout() const; 0155 0156 Q_SIGNALS: 0157 /** 0158 * This signal is emitted when the state of the SMS has changed 0159 * 0160 * @param newState the new state of the SMS 0161 */ 0162 void stateChanged(MMSmsState newState); 0163 void pduTypeChanged(MMSmsPduType pduType); 0164 void numberChanged(const QString &number); 0165 void SMSCChanged(const QString &smsc); 0166 void dataChanged(const QByteArray &data); 0167 void textChanged(const QString &text); 0168 void validityChanged(const ModemManager::ValidityPair &validity); 0169 void smsClassChanged(int smsClass); 0170 void deliveryReportRequestChanged(bool deliveryReportRequest); 0171 void messageReferenceChanged(uint messageReference); 0172 void timestampChanged(const QDateTime ×tamp); 0173 void dischargeTimestampChanged(const QDateTime &dischargeTimestamp); 0174 /** 0175 * This signal is emitted when the delivery state of the SMS has changed 0176 * 0177 * @param newDeliveryState the new delivery state of the SMS 0178 */ 0179 void deliveryStateChanged(MMSmsDeliveryState newDeliveryState); 0180 void storageChanged(MMSmsStorage storage); 0181 void serviceCategoryChanged(MMSmsCdmaServiceCategory serviceCategory); 0182 void teleserviceIdChanged(MMSmsCdmaTeleserviceId teleserviceId); 0183 0184 private: 0185 SmsPrivate *const d_ptr; 0186 }; 0187 0188 } // namespace ModemManager 0189 0190 #endif