File indexing completed on 2024-04-14 03:57:25

0001 /*
0002     SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef MODEMMANAGERQT_MODEM_SIMPLE_H
0008 #define MODEMMANAGERQT_MODEM_SIMPLE_H
0009 
0010 #include <ModemManager/ModemManager.h>
0011 
0012 #include <modemmanagerqt_export.h>
0013 
0014 #include "generictypes.h"
0015 #include "interface.h"
0016 
0017 #include <QDBusPendingReply>
0018 
0019 namespace ModemManager
0020 {
0021 class ModemSimplePrivate;
0022 
0023 /**
0024  * @brief The ModemSimple class
0025  *
0026  * The Simple interface allows controlling and querying the status of Modems.
0027  */
0028 class MODEMMANAGERQT_EXPORT ModemSimple : public Interface
0029 {
0030     Q_OBJECT
0031     Q_DECLARE_PRIVATE(ModemSimple)
0032 
0033 public:
0034     typedef QSharedPointer<ModemSimple> Ptr;
0035     typedef QList<Ptr> List;
0036 
0037     explicit ModemSimple(const QString &path, QObject *parent = nullptr);
0038     ~ModemSimple() override;
0039 
0040     QString uni() const;
0041 
0042     /**
0043      * Do everything needed to connect the modem using the given properties.
0044      *
0045      * This method will attempt to find a matching packet data bearer and activate it if necessary,
0046      * returning the bearer's IP details. If no matching bearer is found, a new bearer will be created
0047      * and activated, but this operation may fail if no resources are available to complete this connection
0048      * attempt (ie, if a conflicting bearer is already active).
0049      *
0050      * This call may make a large number of changes to modem configuration based on properties passed in. For
0051      * example, given a PIN-locked, disabled GSM/UMTS modem, this call may unlock the SIM PIN, alter the access
0052      * technology preference, wait for network registration (or force registration to a specific provider), create
0053      * a new packet data bearer using the given "apn", and connect that bearer.
0054      *
0055      * Dictionary of properties needed to get the modem connected.
0056      * Each implementation is free to add its own specific key-value pairs. The predefined
0057      * common ones are:
0058      *
0059      * @param pin SIM-PIN unlock code, given as a string value (signature "s").
0060      * @param operator-id ETSI MCC-MNC of a network to force registration with, given as a string value (signature "s").
0061      * @param apn For GSM/UMTS and LTE devices the APN to use, given as a string value (signature "s").
0062      * @param ip-type For GSM/UMTS and LTE devices the IP addressing type to use, given as a MMBearerIpFamily value (signature "u").
0063      * @param allowed-auth The authentication method to use, given as a MMBearerAllowedAuth value (signature "u"). Optional in 3GPP.
0064      * @param user User name (if any) required by the network, given as a string value (signature "s"). Optional in 3GPP.
0065      * @param password Password (if any) required by the network, given as a string value (signature "s"). Optional in 3GPP.
0066      * @param number For POTS devices the number to dial,, given as a string value (signature "s").
0067      * @param allow-roaming FALSE to allow only connections to home networks, given as a boolean value (signature "b").
0068      * @param rm-protocol For CDMA devices, the protocol of the Rm interface, given as a MMModemCdmaRmProtocol value (signature "u").
0069      *
0070      * @return On successful connect, returns the object path of the connected packet data bearer used for the connection attempt.
0071      */
0072     QDBusPendingReply<QDBusObjectPath> connectModem(const QVariantMap &properties);
0073 
0074     /**
0075      *  Dictionary of properties.
0076      *  Each implementation is free to add it's own specific key-value pairs. The predefined
0077      *  common ones are:
0078      *
0079      * @param state A MMModemState value specifying the overall state of the modem, given as an unsigned integer value (signature "u").
0080      * @param signal-quality Signal quality value, given only when registered, as an unsigned integer value (signature "u").
0081      * @param current-bands List of MMModemBand values, given only when registered, as a list of unsigned integer values (signature "au").
0082      * @param access-technology A MMModemAccessTechnology value, given only when registered, as an unsigned integer value (signature "u").
0083      * @param m3gpp-registration-state A MMModem3gppRegistrationState value specifying the state of the registration,
0084      *   given only when registered in a 3GPP network, as an unsigned integer value (signature "u").
0085      * @param m3gpp-operator-code Operator MCC-MNC, given only when registered in a 3GPP network, as a string value (signature "s").
0086      * @param m3gpp-operator-name Operator name, given only when registered in a 3GPP network, as a string value (signature "s").
0087      * @param cdma-cdma1x-registration-state A MMModemCdmaRegistrationState value specifying the state of the registration,
0088      *   given only when registered in a CDMA1x network, as an unsigned integer value (signature "u").
0089      * @param cdma-evdo-registration-state A MMModemCdmaRegistrationState value specifying the state of the registration,
0090      *   given only when registered in a EV-DO network, as an unsigned integer value (signature "u").
0091      * @param cdma-sid The System Identifier of the serving network, if registered in a CDMA1x network and if known.
0092      *   Given as an unsigned integer value (signature "u").
0093      * @param cdma-nid The Network Identifier of the serving network, if registered in a CDMA1x network and if known.
0094      *   Given as an unsigned integer value (signature "u").
0095      */
0096     QDBusPendingReply<QVariantMap> getStatus();
0097 
0098     /**
0099      * Disconnect an active packet data connection.
0100      */
0101     QDBusPendingReply<void> disconnectModem(const QString &bearer);
0102 
0103     /**
0104      * Convenient method calling disconnectModem with "/" to make ModemManager disconnect all modems
0105      */
0106     QDBusPendingReply<void> disconnectAllModems();
0107 
0108     /**
0109      * Sets the timeout in milliseconds for all async method DBus calls.
0110      * -1 means the default DBus timeout (usually 25 seconds).
0111      */
0112     void setTimeout(int timeout);
0113 
0114     /**
0115      * Returns the current value of the DBus timeout in milliseconds.
0116      * -1 means the default DBus timeout (usually 25 seconds).
0117      */
0118     int timeout() const;
0119 };
0120 
0121 } // namespace ModemManager
0122 
0123 #endif