VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.h@ 101452

Last change on this file since 101452 was 101452, checked in by vboxsync, 8 months ago

FE/Qt: bugref:10205: A fix for UIUpdateDefs; VBoxUpdateData created by default should have data initiated properly; Otherwise update period goes south.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: UIUpdateDefs.h 101452 2023-10-16 12:55:04Z 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 "COMEnums.h"
43#include "CHost.h"
44
45
46/** Update period types. */
47enum UpdatePeriodType
48{
49 UpdatePeriodType_Never = -1,
50 UpdatePeriodType_1Day = 0,
51 UpdatePeriodType_2Days = 1,
52 UpdatePeriodType_3Days = 2,
53 UpdatePeriodType_4Days = 3,
54 UpdatePeriodType_5Days = 4,
55 UpdatePeriodType_6Days = 5,
56 UpdatePeriodType_1Week = 6,
57 UpdatePeriodType_2Weeks = 7,
58 UpdatePeriodType_3Weeks = 8,
59 UpdatePeriodType_1Month = 9
60};
61
62
63/** Structure to store retranslated period type values. */
64struct VBoxUpdateDay
65{
66 VBoxUpdateDay(const QString &strVal, const QString &strKey, ULONG uLength)
67 : val(strVal)
68 , key(strKey)
69 , length(uLength)
70 {}
71
72 bool operator==(const VBoxUpdateDay &other) const
73 {
74 return val == other.val
75 || key == other.key
76 || length == other.length;
77 }
78
79 QString val;
80 QString key;
81 ULONG length;
82};
83typedef QList<VBoxUpdateDay> VBoxUpdateDayList;
84
85
86/** Class used to encode/decode update data. */
87class SHARED_LIBRARY_STUFF VBoxUpdateData
88{
89public:
90
91 /** Populates a set of update options. */
92 static void populate();
93 /** Returns a list of update options. */
94 static QStringList list();
95
96 /** Constructs update description on the basis of passed @a strData. */
97 VBoxUpdateData(const QString &strData = QString("never"));
98 /** Constructs update description on the basis of passed @a fCheckEnabled, @a enmUpdatePeriod and @a enmUpdateChannel. */
99 VBoxUpdateData(bool fCheckEnabled, UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel);
100
101 /** Loads data from IHost. */
102 bool load(const CHost &comHost);
103 /** Saves data to IHost. */
104 bool save(const CHost &comHost) const;
105
106 /** Returns whether check is enabled. */
107 bool isCheckEnabled() const;
108 /** Returns whether check is required. */
109 bool isCheckRequired() const;
110
111 /** Returns update data. */
112 QString data() const;
113
114 /** Returns update period. */
115 UpdatePeriodType updatePeriod() const;
116 /** Returns update date. */
117 QDate date() const;
118 /** Returns update date as string. */
119 QString dateToString() const;
120 /** Returns update channel. */
121 KUpdateChannel updateChannel() const;
122 /** Returns update channel name. */
123 QString updateChannelName() const;
124 /** Returns version. */
125 UIVersion version() const;
126
127 /** Returns supported update chennels. */
128 QVector<KUpdateChannel> supportedUpdateChannels() const;
129
130 /** Returns whether this item equals to @a another one. */
131 bool isEqual(const VBoxUpdateData &another) const;
132 /** Returns whether this item equals to @a another one. */
133 bool operator==(const VBoxUpdateData &another) const;
134 /** Returns whether this item isn't equal to @a another one. */
135 bool operator!=(const VBoxUpdateData &another) const;
136
137 /** Converts passed @a enmUpdateChannel to internal QString value.
138 * @note This isn't a member of UIConverter since it's used for
139 * legacy extra-data settings saving routine only. */
140 static QString updateChannelToInternalString(KUpdateChannel enmUpdateChannel);
141 /** Converts passed @a strUpdateChannel to KUpdateChannel value.
142 * @note This isn't a member of UIConverter since it's used for
143 * legacy extra-data settings saving routine only. */
144 static KUpdateChannel updateChannelFromInternalString(const QString &strUpdateChannel);
145
146private:
147
148 /** Gathers period suitable to passed @a uFrequency rounding up. */
149 static UpdatePeriodType gatherSuitablePeriod(ULONG uFrequency);
150
151 /** Holds the populated list of update period options. */
152 static VBoxUpdateDayList s_days;
153
154 /** Holds the update data. */
155 QString m_strData;
156
157 /** Holds whether check is enabled. */
158 bool m_fCheckEnabled;
159 /** Holds whether it's need to check for update. */
160 bool m_fCheckRequired;
161
162 /** Holds the update period. */
163 UpdatePeriodType m_enmUpdatePeriod;
164 /** Holds the update date. */
165 QDate m_date;
166 /** Holds the update channel. */
167 KUpdateChannel m_enmUpdateChannel;
168 /** Holds the update version. */
169 UIVersion m_version;
170
171 /** Holds the supported update chennels. */
172 QVector<KUpdateChannel> m_supportedUpdateChannels;
173};
174
175
176#endif /* !FEQT_INCLUDED_SRC_networking_UIUpdateDefs_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use