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

0001 /*
0002     SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
0003     SPDX-FileCopyrightText: 2013-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_MODEMTIME_H
0009 #define MODEMMANAGERQT_MODEMTIME_H
0010 
0011 #include "interface.h"
0012 #include <modemmanagerqt_export.h>
0013 
0014 #include <QDBusPendingReply>
0015 #include <QDateTime>
0016 #include <QObject>
0017 #include <QSharedPointer>
0018 
0019 namespace ModemManager
0020 {
0021 class ModemTimePrivate;
0022 
0023 /**
0024  * This class represents the timezone data provided by the network
0025  */
0026 class MODEMMANAGERQT_EXPORT NetworkTimezone
0027 {
0028 public:
0029     /**
0030      * Constructs an empty timezone data object
0031      */
0032     NetworkTimezone();
0033 
0034     /**
0035      * Destroys this NetworkTimezone object.
0036      */
0037     ~NetworkTimezone();
0038 
0039     /**
0040      * Constructs an NetworkTimezone object that is a copy of the object @p other.
0041      */
0042     NetworkTimezone(const NetworkTimezone &other);
0043 
0044     /**
0045      * Returns offset of the timezone from UTC, in minutes (including DST, if applicable)
0046      */
0047     int offset() const;
0048 
0049     /**
0050      * Sets offset of the timezone from UTC
0051      */
0052     void setOffset(int offset);
0053 
0054     /**
0055      * Returns amount of offset that is due to DST (daylight saving time)
0056      */
0057     int dstOffset() const;
0058 
0059     /**
0060      * Sets amount of offset that is due to DST
0061      */
0062     void setDstOffset(int dstOffset);
0063 
0064     /**
0065      * Returns number of leap seconds included in the network time
0066      */
0067     int leapSecond() const;
0068 
0069     /**
0070      * Sets number of leap seconds included in the network timezone
0071      */
0072     void setLeapSecond(int leapSecond);
0073     /**
0074      * Makes a copy of the NetworkTimezone object @p other.
0075      */
0076     NetworkTimezone &operator=(const NetworkTimezone &other);
0077 
0078 private:
0079     class Private;
0080     Private *const d;
0081 };
0082 
0083 /**
0084  * @brief The ModemTime class
0085  *
0086  * This class allows clients to receive network time and timezone updates broadcast by mobile networks.
0087  */
0088 class MODEMMANAGERQT_EXPORT ModemTime : public Interface
0089 {
0090     Q_OBJECT
0091     Q_DECLARE_PRIVATE(ModemTime)
0092 
0093 public:
0094     typedef QSharedPointer<ModemTime> Ptr;
0095     typedef QList<Ptr> List;
0096 
0097     explicit ModemTime(const QString &path, QObject *parent = nullptr);
0098     ~ModemTime() override;
0099 
0100     /**
0101      * @return the current network time in local time.
0102      *
0103      * This method will only work if the modem tracks, or can request, the
0104      * current network time; it will not attempt to use previously-received
0105      * network time updates on the host to guess the current network time.
0106      */
0107     QDBusPendingReply<QString> networkTime();
0108 
0109     /**
0110      * @return the timezone data provided by the network.
0111      * @see NetworkTimezone
0112      */
0113     ModemManager::NetworkTimezone networkTimezone() const;
0114 
0115     /**
0116      * Sets the timeout in milliseconds for all async method DBus calls.
0117      * -1 means the default DBus timeout (usually 25 seconds).
0118      */
0119     void setTimeout(int timeout);
0120 
0121     /**
0122      * Returns the current value of the DBus timeout in milliseconds.
0123      * -1 means the default DBus timeout (usually 25 seconds).
0124      */
0125     int timeout() const;
0126 
0127 Q_SIGNALS:
0128     /**
0129      * Sent when the network time is updated.
0130      * @param dateTime the new date and time
0131      */
0132     void networkTimeChanged(const QDateTime &dateTime);
0133     void networkTimezoneChanged(const ModemManager::NetworkTimezone &timeZone);
0134 };
0135 
0136 } // namespace ModemManager
0137 
0138 Q_DECLARE_METATYPE(ModemManager::NetworkTimezone)
0139 
0140 #endif