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

0001 /*
0002     SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org>
0003     SPDX-FileCopyrightText: 2010 Lamarque Souza <lamarque@kde.org>
0004     SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
0005     SPDX-FileCopyrightText: 2013 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_MODEMLOCATION_H
0011 #define MODEMMANAGERQT_MODEMLOCATION_H
0012 
0013 #include <modemmanagerqt_export.h>
0014 
0015 #include <QObject>
0016 #include <QSharedPointer>
0017 
0018 #include "generictypes.h"
0019 #include "interface.h"
0020 
0021 namespace ModemManager
0022 {
0023 class ModemLocationPrivate;
0024 
0025 /**
0026  * @brief The ModemLocation class
0027  *
0028  * The Location class allows devices to provide location information to
0029  * client applications. Not all devices can provide this information, or even if
0030  * they do, they may not be able to provide it while a data session is active.
0031  */
0032 class MODEMMANAGERQT_EXPORT ModemLocation : public Interface
0033 {
0034     Q_OBJECT
0035     Q_DECLARE_PRIVATE(ModemLocation)
0036     Q_FLAGS(MMModemLocationSource)
0037 
0038 public:
0039     typedef QSharedPointer<ModemLocation> Ptr;
0040     typedef QList<Ptr> List;
0041 
0042     Q_DECLARE_FLAGS(LocationSources, MMModemLocationSource)
0043 
0044     explicit ModemLocation(const QString &path, QObject *parent = nullptr);
0045     ~ModemLocation() override;
0046 
0047     /**
0048      * Configure the location sources to use when gathering location
0049      * information. Also enable or disable location information gathering. This
0050      * method may require the client to authenticate itself.
0051      *
0052      * When signals are emitted, any client application (including malicious
0053      * ones!) can listen for location updates unless D-Bus permissions restrict
0054      * these signals from certain users. If further security is desired, the
0055      * @p signLocation argument can be set to FALSE to disable location updates
0056      * via the locationChanged() signal and require applications to call authenticated APIs
0057      * (like GetLocation() ) to get location information.
0058      */
0059     QDBusPendingReply<void> setup(ModemManager::ModemLocation::LocationSources sources, bool signalLocation);
0060 
0061     /**
0062      * @return current location information, if any. If the modem supports
0063      * multiple location types it may return more than one. See the "Location"
0064      * property for more information on the dictionary returned at location.
0065      *
0066      * This method may require the client to authenticate itself.
0067      */
0068     QDBusPendingReply<LocationInformationMap> getLocation();
0069 
0070     /**
0071      * @return QFlags of MMModemLocationSource values, specifying the supported location sources.
0072      */
0073     LocationSources capabilities() const;
0074 
0075     /**
0076      * @return QFlags specifying which of the supported MMModemLocationSource location sources is currently enabled in the device.
0077      */
0078     LocationSources enabledCapabilities() const;
0079 
0080     /**
0081      * @return whether the device has any location capabilities
0082      */
0083     bool isEnabled() const;
0084 
0085     /**
0086      * @return TRUE if location updates will be emitted via the locationChanged() signal, FALSE if location updates will not be emitted.
0087      *
0088      * See the setup() method for more information.
0089      */
0090     bool signalsLocation() const;
0091 
0092     /**
0093      * @return Dictionary of available location information when location information gathering is enabled. If the modem supports multiple
0094      *         location types it may return more than one here.
0095      * Note that if the device was told not to emit updated location information when location information gathering was initially enabled,
0096      * this property may not return any location information for security reasons.
0097      */
0098     LocationInformationMap location() const;
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 capabilitiesChanged(QFlags<MMModemLocationSource> capabilities);
0114     void enabledCapabilitiesChanged(QFlags<MMModemLocationSource> capabilities);
0115     void signalsLocationChanged(bool signalsLocation);
0116     /**
0117      * Emitted when the location has changed
0118      */
0119     void locationChanged(const ModemManager::LocationInformationMap &location);
0120 };
0121 
0122 Q_DECLARE_OPERATORS_FOR_FLAGS(ModemLocation::LocationSources)
0123 
0124 } // namespace ModemManager
0125 
0126 #endif