File indexing completed on 2025-03-09 03:44:55
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org> 0003 SPDX-FileCopyrightText: 2010-2011 Lamarque Souza <lamarque@kde.org> 0004 SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com> 0005 SPDX-FileCopyrightText: 2013-2015 Jan Grulich <jgrulich@redhat.com> 0006 0007 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0008 */ 0009 0010 #ifndef MODEMMANAGERQT_SIM_H 0011 #define MODEMMANAGERQT_SIM_H 0012 0013 #include <modemmanagerqt_export.h> 0014 0015 #include <QDBusPendingReply> 0016 #include <QObject> 0017 #include <QSharedPointer> 0018 0019 #include "generictypes.h" 0020 0021 namespace ModemManager 0022 { 0023 class SimPrivate; 0024 0025 /** 0026 * @brief The Sim class 0027 * 0028 * The SIM class handles communication with SIM, USIM, and RUIM (CDMA SIM) cards. 0029 */ 0030 class MODEMMANAGERQT_EXPORT Sim : public QObject 0031 { 0032 Q_OBJECT 0033 Q_DECLARE_PRIVATE(Sim) 0034 0035 public: 0036 typedef QSharedPointer<Sim> Ptr; 0037 typedef QList<Ptr> List; 0038 0039 explicit Sim(const QString &path, QObject *parent = nullptr); 0040 ~Sim() override; 0041 0042 /** 0043 * @return Boolean indicating whether the SIM is currently active. 0044 * 0045 * On systems that support Multi SIM Single Standby, only one SIM may be 0046 * active at any given time, which will be the one considered primary. 0047 0048 * On systems that support Multi SIM Multi Standby, more than one SIM may 0049 * be active at any given time, but only one of them is considered primary. 0050 */ 0051 bool active() const; 0052 0053 /** 0054 * @return The ICCID of the SIM card. 0055 * 0056 * This may be available before the PIN has been entered depending on the device itself. 0057 */ 0058 QString simIdentifier() const; 0059 0060 /** 0061 * @return The IMSI of the SIM card, if any. 0062 */ 0063 QString imsi() const; 0064 0065 /** 0066 * @return The EID of the SIM card, if any. 0067 */ 0068 QString eid() const; 0069 0070 /** 0071 * @return The ID of the network operator, as given by the SIM card, if known. 0072 */ 0073 QString operatorIdentifier() const; 0074 0075 /** 0076 * @return The name of the network operator, as given by the SIM card, if known. 0077 */ 0078 QString operatorName() const; 0079 0080 /** 0081 * @return List of emergency numbers programmed in the SIM card. 0082 * 0083 * These numbers should be treated as numbers for emergency calls in 0084 * addition to 112 and 911. 0085 */ 0086 QStringList emergencyNumbers() const; 0087 0088 /** 0089 * @return Map of preferred networks with access technologies configured in the SIM card. 0090 * 0091 * Each entry contains an operator id string key "MCCMNC" 0092 * consisting of 5 or 6 digits, to an MMModemAccessTechnology mask value. 0093 * If the SIM card does not support access technology storage, the mask will be 0094 * set to MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN. 0095 */ 0096 QVariantMap preferredNetworks() const; 0097 0098 #if MM_CHECK_VERSION(1, 20, 0) 0099 /** 0100 * @return Group identifier 1evel 1. 0101 */ 0102 QByteArray gid1() const; 0103 0104 /** 0105 * @return Group identifier 1evel 2. 0106 */ 0107 QByteArray gid2() const; 0108 0109 /** 0110 * @return Indicates whether the current primary SIM is a ESIM or a physical SIM. 0111 */ 0112 MMSimType simType() const; 0113 0114 /** 0115 * @return If current SIM is ESIM then this indicates whether there is a profile or not. 0116 */ 0117 MMSimEsimStatus esimStatus() const; 0118 0119 /** 0120 * @return Indicates whether the current SIM is a removable SIM or not. 0121 */ 0122 MMSimRemovability removability() const; 0123 #endif 0124 0125 /** 0126 * Send the PIN to unlock the SIM card. 0127 * @param pin A string containing the PIN code. 0128 */ 0129 QDBusPendingReply<> sendPin(const QString &pin); 0130 0131 /** 0132 * Send the PUK and a new PIN to unlock the SIM card. 0133 * @param puk A string containing the PUK code. 0134 * @param pin A string containing the PIN code. 0135 */ 0136 QDBusPendingReply<> sendPuk(const QString &puk, const QString &pin); 0137 0138 /** 0139 * Enable or disable the PIN checking. 0140 * @param pin A string containing the PIN code. 0141 * @param enabled TRUE to enable PIN checking, FALSE otherwise. 0142 */ 0143 QDBusPendingReply<> enablePin(const QString &pin, bool enabled); 0144 0145 /** 0146 * Change the PIN code. 0147 * @param oldPin A string containing the current PIN code. 0148 * @param newPin A string containing the new PIN code. 0149 */ 0150 QDBusPendingReply<> changePin(const QString &oldPin, const QString &newPin); 0151 0152 /** 0153 * @param preferred_plmns List of preferred networks. 0154 * 0155 * Stores the provided preferred network list to the SIM card. Each entry contains 0156 * an operator id string ("MCCMNC") consisting of 5 or 6 digits, 0157 * and an MMModemAccessTechnology mask to store to SIM card if supported. 0158 * 0159 * This method removes any pre-existing entries of the preferred network list. Note 0160 * that even if this operation fails, the preferred network list on the SIM card may 0161 * have changed. 0162 */ 0163 QDBusPendingReply<> setPreferredNetworks(QVariantMap preferredNetworks); 0164 0165 QString uni() const; 0166 0167 /** 0168 * Sets the timeout in milliseconds for all async method DBus calls. 0169 * -1 means the default DBus timeout (usually 25 seconds). 0170 */ 0171 void setTimeout(int timeout); 0172 0173 /** 0174 * Returns the current value of the DBus timeout in milliseconds. 0175 * -1 means the default DBus timeout (usually 25 seconds). 0176 */ 0177 int timeout() const; 0178 0179 Q_SIGNALS: 0180 void activeChanged(bool active); 0181 void simIdentifierChanged(const QString &identifier); 0182 void imsiChanged(const QString &imsi); 0183 void eidChanged(const QString &eid); 0184 void operatorIdentifierChanged(const QString &identifier); 0185 void operatorNameChanged(const QString &name); 0186 void emergencyNumbersChanged(const QStringList &emergencyNumbers); 0187 void preferredNetworksChanged(const QVariantMap &preferredNetworks); 0188 #if MM_CHECK_VERSION(1, 20, 0) 0189 void gid1Changed(const QByteArray &gid1); 0190 void gid2Changed(const QByteArray &gid2); 0191 void simTypeChanged(MMSimType simType); 0192 void esimStatusChanged(MMSimEsimStatus esimStatus); 0193 void removabilityChanged(MMSimRemovability removability); 0194 #endif 0195 0196 private: 0197 SimPrivate *const d_ptr; 0198 }; 0199 } // namespace ModemManager 0200 0201 #endif