[55401] | 1 | /* $Id: UIUpdateDefs.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
[10459] | 2 | /** @file
|
---|
[52727] | 3 | * VBox Qt GUI - Update routine related declarations.
|
---|
[10459] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[10459] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[10459] | 26 | */
|
---|
| 27 |
|
---|
[86996] | 28 | #ifndef FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[10459] | 33 |
|
---|
[70824] | 34 | /* Qt includes: */
|
---|
[38222] | 35 | #include <QDate>
|
---|
[26079] | 36 |
|
---|
[70824] | 37 | /* GUI includes: */
|
---|
[71630] | 38 | #include "UILibraryDefs.h"
|
---|
[70824] | 39 | #include "UIVersion.h"
|
---|
[39473] | 40 |
|
---|
[94725] | 41 | /* COM includes: */
|
---|
[94760] | 42 | #include "CHost.h"
|
---|
[103803] | 43 | #include "KUpdateChannel.h"
|
---|
[70824] | 44 |
|
---|
[94733] | 45 | /** Update period types. */
|
---|
| 46 | enum UpdatePeriodType
|
---|
| 47 | {
|
---|
| 48 | UpdatePeriodType_Never = -1,
|
---|
| 49 | UpdatePeriodType_1Day = 0,
|
---|
| 50 | UpdatePeriodType_2Days = 1,
|
---|
| 51 | UpdatePeriodType_3Days = 2,
|
---|
| 52 | UpdatePeriodType_4Days = 3,
|
---|
| 53 | UpdatePeriodType_5Days = 4,
|
---|
| 54 | UpdatePeriodType_6Days = 5,
|
---|
| 55 | UpdatePeriodType_1Week = 6,
|
---|
| 56 | UpdatePeriodType_2Weeks = 7,
|
---|
| 57 | UpdatePeriodType_3Weeks = 8,
|
---|
| 58 | UpdatePeriodType_1Month = 9
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | /** Structure to store retranslated period type values. */
|
---|
[38476] | 63 | struct VBoxUpdateDay
|
---|
[10459] | 64 | {
|
---|
[94760] | 65 | VBoxUpdateDay(const QString &strVal, const QString &strKey, ULONG uLength)
|
---|
[94733] | 66 | : val(strVal)
|
---|
| 67 | , key(strKey)
|
---|
[94760] | 68 | , length(uLength)
|
---|
[94733] | 69 | {}
|
---|
[10459] | 70 |
|
---|
[94733] | 71 | bool operator==(const VBoxUpdateDay &other) const
|
---|
| 72 | {
|
---|
| 73 | return val == other.val
|
---|
[94760] | 74 | || key == other.key
|
---|
| 75 | || length == other.length;
|
---|
[94733] | 76 | }
|
---|
[38222] | 77 |
|
---|
[94740] | 78 | QString val;
|
---|
| 79 | QString key;
|
---|
[94760] | 80 | ULONG length;
|
---|
[10459] | 81 | };
|
---|
[38476] | 82 | typedef QList<VBoxUpdateDay> VBoxUpdateDayList;
|
---|
[10459] | 83 |
|
---|
[70824] | 84 |
|
---|
[71528] | 85 | /** Class used to encode/decode update data. */
|
---|
[71630] | 86 | class SHARED_LIBRARY_STUFF VBoxUpdateData
|
---|
[10459] | 87 | {
|
---|
| 88 | public:
|
---|
| 89 |
|
---|
[71528] | 90 | /** Populates a set of update options. */
|
---|
[10459] | 91 | static void populate();
|
---|
[71528] | 92 | /** Returns a list of update options. */
|
---|
[10459] | 93 | static QStringList list();
|
---|
| 94 |
|
---|
[71528] | 95 | /** Constructs update description on the basis of passed @a strData. */
|
---|
[101452] | 96 | VBoxUpdateData(const QString &strData = QString("never"));
|
---|
[94750] | 97 | /** Constructs update description on the basis of passed @a fCheckEnabled, @a enmUpdatePeriod and @a enmUpdateChannel. */
|
---|
| 98 | VBoxUpdateData(bool fCheckEnabled, UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel);
|
---|
[10459] | 99 |
|
---|
[94760] | 100 | /** Loads data from IHost. */
|
---|
| 101 | bool load(const CHost &comHost);
|
---|
| 102 | /** Saves data to IHost. */
|
---|
| 103 | bool save(const CHost &comHost) const;
|
---|
| 104 |
|
---|
[94740] | 105 | /** Returns whether check is enabled. */
|
---|
| 106 | bool isCheckEnabled() const;
|
---|
| 107 | /** Returns whether check is required. */
|
---|
| 108 | bool isCheckRequired() const;
|
---|
[94733] | 109 |
|
---|
[71528] | 110 | /** Returns update data. */
|
---|
[10515] | 111 | QString data() const;
|
---|
[94733] | 112 |
|
---|
| 113 | /** Returns update period. */
|
---|
| 114 | UpdatePeriodType updatePeriod() const;
|
---|
[71528] | 115 | /** Returns update date. */
|
---|
[94738] | 116 | QDate date() const;
|
---|
| 117 | /** Returns update date as string. */
|
---|
| 118 | QString dateToString() const;
|
---|
[94725] | 119 | /** Returns update channel. */
|
---|
| 120 | KUpdateChannel updateChannel() const;
|
---|
| 121 | /** Returns update channel name. */
|
---|
| 122 | QString updateChannelName() const;
|
---|
[71528] | 123 | /** Returns version. */
|
---|
[70824] | 124 | UIVersion version() const;
|
---|
[10459] | 125 |
|
---|
[94851] | 126 | /** Returns supported update chennels. */
|
---|
| 127 | QVector<KUpdateChannel> supportedUpdateChannels() const;
|
---|
| 128 |
|
---|
[86128] | 129 | /** Returns whether this item equals to @a another one. */
|
---|
| 130 | bool isEqual(const VBoxUpdateData &another) const;
|
---|
| 131 | /** Returns whether this item equals to @a another one. */
|
---|
| 132 | bool operator==(const VBoxUpdateData &another) const;
|
---|
| 133 | /** Returns whether this item isn't equal to @a another one. */
|
---|
| 134 | bool operator!=(const VBoxUpdateData &another) const;
|
---|
| 135 |
|
---|
[94725] | 136 | /** Converts passed @a enmUpdateChannel to internal QString value.
|
---|
| 137 | * @note This isn't a member of UIConverter since it's used for
|
---|
| 138 | * legacy extra-data settings saving routine only. */
|
---|
| 139 | static QString updateChannelToInternalString(KUpdateChannel enmUpdateChannel);
|
---|
| 140 | /** Converts passed @a strUpdateChannel to KUpdateChannel value.
|
---|
| 141 | * @note This isn't a member of UIConverter since it's used for
|
---|
| 142 | * legacy extra-data settings saving routine only. */
|
---|
| 143 | static KUpdateChannel updateChannelFromInternalString(const QString &strUpdateChannel);
|
---|
| 144 |
|
---|
[10459] | 145 | private:
|
---|
| 146 |
|
---|
[94760] | 147 | /** Gathers period suitable to passed @a uFrequency rounding up. */
|
---|
| 148 | static UpdatePeriodType gatherSuitablePeriod(ULONG uFrequency);
|
---|
| 149 |
|
---|
[94733] | 150 | /** Holds the populated list of update period options. */
|
---|
[94738] | 151 | static VBoxUpdateDayList s_days;
|
---|
[71528] | 152 |
|
---|
| 153 | /** Holds the update data. */
|
---|
[94738] | 154 | QString m_strData;
|
---|
[94740] | 155 |
|
---|
[94750] | 156 | /** Holds whether check is enabled. */
|
---|
| 157 | bool m_fCheckEnabled;
|
---|
| 158 | /** Holds whether it's need to check for update. */
|
---|
| 159 | bool m_fCheckRequired;
|
---|
| 160 |
|
---|
[94733] | 161 | /** Holds the update period. */
|
---|
[94851] | 162 | UpdatePeriodType m_enmUpdatePeriod;
|
---|
[71528] | 163 | /** Holds the update date. */
|
---|
[94851] | 164 | QDate m_date;
|
---|
[94725] | 165 | /** Holds the update channel. */
|
---|
[94851] | 166 | KUpdateChannel m_enmUpdateChannel;
|
---|
[71528] | 167 | /** Holds the update version. */
|
---|
[94851] | 168 | UIVersion m_version;
|
---|
| 169 |
|
---|
| 170 | /** Holds the supported update chennels. */
|
---|
| 171 | QVector<KUpdateChannel> m_supportedUpdateChannels;
|
---|
[10459] | 172 | };
|
---|
| 173 |
|
---|
[71528] | 174 |
|
---|
[86996] | 175 | #endif /* !FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h */
|
---|