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

0001 /*
0002     SPDX-FileCopyrightText: 2014 Lukas Tinkl <ltinkl@redhat.com>
0003     SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef MODEMMANAGERQT_MODEMOMA_H
0009 #define MODEMMANAGERQT_MODEMOMA_H
0010 
0011 #include <modemmanagerqt_export.h>
0012 
0013 #include <QDBusPendingReply>
0014 #include <QObject>
0015 #include <QSharedPointer>
0016 
0017 #include "generictypes.h"
0018 #include "interface.h"
0019 
0020 namespace ModemManager
0021 {
0022 class ModemOmaPrivate;
0023 
0024 /**
0025  * @brief The ModemManager Open Mobile Alliance interface.
0026  *
0027  * This interface allows clients to handle device management operations as specified by the Open Mobile Alliance (OMA).
0028  *
0029  * Device management sessions are either on-demand (client-initiated), or automatically initiated by either the device
0030  * itself or the network.
0031  *
0032  * @since 1.1.92
0033  */
0034 class MODEMMANAGERQT_EXPORT ModemOma : public Interface
0035 {
0036     Q_OBJECT
0037     Q_DECLARE_PRIVATE(ModemOma)
0038     Q_FLAGS(MMOmaFeature)
0039 
0040 public:
0041     typedef QSharedPointer<ModemOma> Ptr;
0042     typedef QList<Ptr> List;
0043 
0044     Q_DECLARE_FLAGS(Features, MMOmaFeature)
0045 
0046     explicit ModemOma(const QString &path, QObject *parent = nullptr);
0047     ~ModemOma() override;
0048 
0049     // properties
0050     /**
0051      * @return MMOmaFeature flags, specifying which device management features are enabled or disabled
0052      */
0053     Features features() const;
0054 
0055     /**
0056      * @return list of network-initiated sessions which are waiting to be accepted or rejected, where:
0057      * @param the first integer is a MMOmaSessionType
0058      * @param the second integer is the unique session ID.
0059      */
0060     OmaSessionTypes pendingNetworkInitiatedSessions() const;
0061 
0062     /**
0063      * @return type of the current on-going device management session, given as a MMOmaSessionType
0064      */
0065     MMOmaSessionType sessionType() const;
0066 
0067     /**
0068      * @return state of the current on-going device management session, given as a MMOmaSessionState
0069      */
0070     MMOmaSessionState sessionState() const;
0071 
0072     // methods
0073     /**
0074      * Configures which OMA device management features should be enabled.
0075      *
0076      * @param features MMModemOmaFeature flags, specifying which device management features should get enabled or disabled.
0077      * MM_OMA_FEATURE_NONE will disable all features.
0078      */
0079     QDBusPendingReply<void> setup(Features features);
0080 
0081     /**
0082      * Starts a client-initiated device management session.
0083      *
0084      * @param sessionType type of client-initiated device management session,given as a MMOmaSessionType
0085      */
0086     QDBusPendingReply<void> startClientInitiatedSession(MMOmaSessionType sessionType);
0087 
0088     /**
0089      * Accepts or rejects a network-initiated device management session.
0090      *
0091      * @param sessionId unique ID of the network-initiated device management session
0092      * @param accept boolean specifying whether the session is accepted or rejected
0093      */
0094     QDBusPendingReply<void> acceptNetworkInitiatedSession(uint sessionId, bool accept);
0095 
0096     /**
0097      * Cancels the current on-going device management session.
0098      */
0099     QDBusPendingReply<void> cancelSession();
0100 
0101     /**
0102      * Sets the timeout in milliseconds for all async method DBus calls.
0103      * -1 means the default DBus timeout (usually 25 seconds).
0104      */
0105     void setTimeout(int timeout);
0106 
0107     /**
0108      * Returns the current value of the DBus timeout in milliseconds.
0109      * -1 means the default DBus timeout (usually 25 seconds).
0110      */
0111     int timeout() const;
0112 
0113 Q_SIGNALS:
0114     void featuresChanged(QFlags<MMOmaFeature> features);
0115     void pendingNetworkInitiatedSessionsChanged(const ModemManager::OmaSessionTypes &sessions);
0116     void sessionTypeChanged(MMOmaSessionType sessionType);
0117     /**
0118      * Emitted when the session state changed.
0119      *
0120      * @param oldState previous session state, given as a MMOmaSessionState
0121      * @param newState current session state, given as a MMOmaSessionState
0122      * @param failedReason reason of failure, given as a MMOmaSessionStateFailedReason, if sessionState() is MM_OMA_SESSION_STATE_FAILED
0123      */
0124     void sessionStateChanged(MMOmaSessionState oldState, MMOmaSessionState newState, MMOmaSessionStateFailedReason failedReason);
0125 };
0126 
0127 } // namespace ModemManager
0128 
0129 #endif