File indexing completed on 2024-04-28 15:33:00

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 namespace ModemManager
0020 {
0021 class SimPrivate;
0022 
0023 /**
0024  * @brief The Sim class
0025  *
0026  * The SIM class handles communication with SIM, USIM, and RUIM (CDMA SIM) cards.
0027  */
0028 class MODEMMANAGERQT_EXPORT Sim : public QObject
0029 {
0030     Q_OBJECT
0031     Q_DECLARE_PRIVATE(Sim)
0032 
0033 public:
0034     typedef QSharedPointer<Sim> Ptr;
0035     typedef QList<Ptr> List;
0036 
0037     explicit Sim(const QString &path, QObject *parent = nullptr);
0038     ~Sim() override;
0039 
0040     /**
0041      * @return An obfuscated SIM identifier based on the IMSI or the ICCID.
0042      *
0043      * This may be available before the PIN has been entered depending on the device itself.
0044      */
0045     QString simIdentifier() const;
0046 
0047     /**
0048      * @return The IMSI of the SIM card, if any.
0049      */
0050     QString imsi() const;
0051 
0052     /**
0053      * @return The ID of the network operator, as given by the SIM card, if known.
0054      */
0055     QString operatorIdentifier() const;
0056 
0057     /**
0058      * @return The name of the network operator, as given by the SIM card, if known.
0059      */
0060     QString operatorName() const;
0061 
0062     /**
0063      * Send the PIN to unlock the SIM card.
0064      * @param pin A string containing the PIN code.
0065      */
0066     QDBusPendingReply<> sendPin(const QString &pin);
0067 
0068     /**
0069      * Send the PUK and a new PIN to unlock the SIM card.
0070      * @param puk A string containing the PUK code.
0071      * @param pin A string containing the PIN code.
0072      */
0073     QDBusPendingReply<> sendPuk(const QString &puk, const QString &pin);
0074 
0075     /**
0076      * Enable or disable the PIN checking.
0077      * @param pin A string containing the PIN code.
0078      * @param enabled TRUE to enable PIN checking, FALSE otherwise.
0079      */
0080     QDBusPendingReply<> enablePin(const QString &pin, bool enabled);
0081 
0082     /**
0083      * Change the PIN code.
0084      * @param oldPin A string containing the current PIN code.
0085      * @param newPin A string containing the new PIN code.
0086      */
0087     QDBusPendingReply<> changePin(const QString &oldPin, const QString &newPin);
0088 
0089     QString uni() const;
0090 
0091     /**
0092      * Sets the timeout in milliseconds for all async method DBus calls.
0093      * -1 means the default DBus timeout (usually 25 seconds).
0094      */
0095     void setTimeout(int timeout);
0096 
0097     /**
0098      * Returns the current value of the DBus timeout in milliseconds.
0099      * -1 means the default DBus timeout (usually 25 seconds).
0100      */
0101     int timeout() const;
0102 
0103 Q_SIGNALS:
0104     void simIdentifierChanged(const QString &identifier);
0105     void imsiChanged(const QString &imsi);
0106     void operatorIdentifierChanged(const QString &identifier);
0107     void operatorNameChanged(const QString &name);
0108 
0109 private:
0110     SimPrivate *const d_ptr;
0111 };
0112 } // namespace ModemManager
0113 
0114 #endif