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

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