1 | /* $Id: UIUpdateDefs.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - Update routine related declarations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
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
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h
|
---|
29 | #define FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QDate>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UILibraryDefs.h"
|
---|
39 | #include "UIVersion.h"
|
---|
40 |
|
---|
41 | /* COM includes: */
|
---|
42 | #include "CHost.h"
|
---|
43 | #include "KUpdateChannel.h"
|
---|
44 |
|
---|
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. */
|
---|
63 | struct VBoxUpdateDay
|
---|
64 | {
|
---|
65 | VBoxUpdateDay(const QString &strVal, const QString &strKey, ULONG uLength)
|
---|
66 | : val(strVal)
|
---|
67 | , key(strKey)
|
---|
68 | , length(uLength)
|
---|
69 | {}
|
---|
70 |
|
---|
71 | bool operator==(const VBoxUpdateDay &other) const
|
---|
72 | {
|
---|
73 | return val == other.val
|
---|
74 | || key == other.key
|
---|
75 | || length == other.length;
|
---|
76 | }
|
---|
77 |
|
---|
78 | QString val;
|
---|
79 | QString key;
|
---|
80 | ULONG length;
|
---|
81 | };
|
---|
82 | typedef QList<VBoxUpdateDay> VBoxUpdateDayList;
|
---|
83 |
|
---|
84 |
|
---|
85 | /** Class used to encode/decode update data. */
|
---|
86 | class SHARED_LIBRARY_STUFF VBoxUpdateData
|
---|
87 | {
|
---|
88 | public:
|
---|
89 |
|
---|
90 | /** Populates a set of update options. */
|
---|
91 | static void populate();
|
---|
92 | /** Returns a list of update options. */
|
---|
93 | static QStringList list();
|
---|
94 |
|
---|
95 | /** Constructs update description on the basis of passed @a strData. */
|
---|
96 | VBoxUpdateData(const QString &strData = QString("never"));
|
---|
97 | /** Constructs update description on the basis of passed @a fCheckEnabled, @a enmUpdatePeriod and @a enmUpdateChannel. */
|
---|
98 | VBoxUpdateData(bool fCheckEnabled, UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel);
|
---|
99 |
|
---|
100 | /** Loads data from IHost. */
|
---|
101 | bool load(const CHost &comHost);
|
---|
102 | /** Saves data to IHost. */
|
---|
103 | bool save(const CHost &comHost) const;
|
---|
104 |
|
---|
105 | /** Returns whether check is enabled. */
|
---|
106 | bool isCheckEnabled() const;
|
---|
107 | /** Returns whether check is required. */
|
---|
108 | bool isCheckRequired() const;
|
---|
109 |
|
---|
110 | /** Returns update data. */
|
---|
111 | QString data() const;
|
---|
112 |
|
---|
113 | /** Returns update period. */
|
---|
114 | UpdatePeriodType updatePeriod() const;
|
---|
115 | /** Returns update date. */
|
---|
116 | QDate date() const;
|
---|
117 | /** Returns update date as string. */
|
---|
118 | QString dateToString() const;
|
---|
119 | /** Returns update channel. */
|
---|
120 | KUpdateChannel updateChannel() const;
|
---|
121 | /** Returns update channel name. */
|
---|
122 | QString updateChannelName() const;
|
---|
123 | /** Returns version. */
|
---|
124 | UIVersion version() const;
|
---|
125 |
|
---|
126 | /** Returns supported update chennels. */
|
---|
127 | QVector<KUpdateChannel> supportedUpdateChannels() const;
|
---|
128 |
|
---|
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 |
|
---|
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 |
|
---|
145 | private:
|
---|
146 |
|
---|
147 | /** Gathers period suitable to passed @a uFrequency rounding up. */
|
---|
148 | static UpdatePeriodType gatherSuitablePeriod(ULONG uFrequency);
|
---|
149 |
|
---|
150 | /** Holds the populated list of update period options. */
|
---|
151 | static VBoxUpdateDayList s_days;
|
---|
152 |
|
---|
153 | /** Holds the update data. */
|
---|
154 | QString m_strData;
|
---|
155 |
|
---|
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 |
|
---|
161 | /** Holds the update period. */
|
---|
162 | UpdatePeriodType m_enmUpdatePeriod;
|
---|
163 | /** Holds the update date. */
|
---|
164 | QDate m_date;
|
---|
165 | /** Holds the update channel. */
|
---|
166 | KUpdateChannel m_enmUpdateChannel;
|
---|
167 | /** Holds the update version. */
|
---|
168 | UIVersion m_version;
|
---|
169 |
|
---|
170 | /** Holds the supported update chennels. */
|
---|
171 | QVector<KUpdateChannel> m_supportedUpdateChannels;
|
---|
172 | };
|
---|
173 |
|
---|
174 |
|
---|
175 | #endif /* !FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h */
|
---|