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

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