File indexing completed on 2024-04-28 15:32:59

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