VirtualBox

source: vbox/trunk/src/VBox/Main/include/UpdateAgentImpl.h@ 94660

Last change on this file since 94660 was 94654, checked in by vboxsync, 3 years ago

Main/Update check: Big overhaul of the API and functionality [build fix]. bugref:7983

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/* $Id: UpdateAgentImpl.h 94654 2022-04-20 16:50:13Z vboxsync $ */
2/** @file
3 * Update agent COM class implementation - Header
4 */
5
6/*
7 * Copyright (C) 2020-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef MAIN_INCLUDED_UpdateAgentImpl_h
19#define MAIN_INCLUDED_UpdateAgentImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/http.h>
25
26#include <VBox/settings.h>
27
28#include "UpdateAgentWrap.h"
29#include "HostUpdateAgentWrap.h"
30
31class UpdateAgentTask;
32struct UpdateAgentTaskParms;
33
34struct UpdateAgentTaskResult
35{
36 Utf8Str strVer;
37 Utf8Str strWebUrl;
38 Utf8Str strDownloadUrl;
39 UpdateSeverity_T enmSeverity;
40 Utf8Str strReleaseNotes;
41};
42
43class UpdateAgentBase
44{
45protected: /* Not directly instancable. */
46
47 UpdateAgentBase()
48 : m_VirtualBox(NULL)
49 , m(new settings::UpdateAgent) { }
50
51 virtual ~UpdateAgentBase() { }
52
53public:
54
55 /** @name Pure virtual public methods for internal purposes only
56 * (ensure there is a caller and a read lock before calling them!)
57 * @{ */
58 virtual HRESULT i_loadSettings(const settings::UpdateAgent &data) = 0;
59 virtual HRESULT i_saveSettings(settings::UpdateAgent &data) = 0;
60
61 virtual HRESULT i_setCheckCount(ULONG aCount) = 0;
62 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate) = 0;
63 /** @} */
64
65protected:
66
67 /** @name Pure virtual internal task callbacks.
68 * @{ */
69 friend UpdateAgentTask;
70 virtual DECLCALLBACK(HRESULT) i_updateTask(UpdateAgentTask *pTask) = 0;
71 /** @} */
72
73 /** @name Static helper methods.
74 * @{ */
75 static Utf8Str i_getPlatformInfo(void);
76 /** @} */
77
78protected:
79 VirtualBox * const m_VirtualBox;
80
81 /** @name Data members.
82 * @{ */
83 settings::UpdateAgent *m;
84
85 struct Data
86 {
87 UpdateAgentTaskResult m_lastResult;
88
89 Utf8Str m_strName;
90 bool m_fHidden;
91 UpdateState_T m_enmState;
92 uint32_t m_uOrder;
93
94 Data(void)
95 {
96 m_fHidden = true;
97 m_enmState = UpdateState_Invalid;
98 m_uOrder = UINT32_MAX;
99 }
100 } mData;
101 /** @} */
102};
103
104class ATL_NO_VTABLE UpdateAgent :
105 public UpdateAgentWrap,
106 public UpdateAgentBase
107{
108public:
109 DECLARE_COMMON_CLASS_METHODS(UpdateAgent)
110
111 /** @name COM and internal init/term/mapping cruft.
112 * @{ */
113 HRESULT FinalConstruct();
114 void FinalRelease();
115
116 HRESULT init(VirtualBox *aVirtualBox);
117 void uninit(void);
118 /** @} */
119
120 /** @name Public methods for internal purposes only
121 * (ensure there is a caller and a read lock before calling them!) */
122 HRESULT i_loadSettings(const settings::UpdateAgent &data);
123 HRESULT i_saveSettings(settings::UpdateAgent &data);
124
125 virtual HRESULT i_setCheckCount(ULONG aCount);
126 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate);
127 /** @} */
128
129protected:
130 /** @name Wrapped IUpdateAgent attributes and methods
131 * @{ */
132 HRESULT check(ComPtr<IProgress> &aProgress);
133 HRESULT download(ComPtr<IProgress> &aProgress);
134 HRESULT install(ComPtr<IProgress> &aProgress);
135 HRESULT rollback(void);
136
137 HRESULT getName(com::Utf8Str &aName);
138 HRESULT getOrder(ULONG *aOrder);
139 HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps);
140 HRESULT getVersion(com::Utf8Str &aVer);
141 HRESULT getDownloadUrl(com::Utf8Str &aUrl);
142 HRESULT getWebUrl(com::Utf8Str &aUrl);
143 HRESULT getReleaseNotes(com::Utf8Str &aRelNotes);
144 HRESULT getEnabled(BOOL *aEnabled);
145 HRESULT setEnabled(BOOL aEnabled);
146 HRESULT getHidden(BOOL *aHidden);
147 HRESULT getState(UpdateState_T *aState);
148 HRESULT getCheckCount(ULONG *aCount);
149 HRESULT getCheckFrequency(ULONG *aFreqSeconds);
150 HRESULT setCheckFrequency(ULONG aFreqSeconds);
151 HRESULT getChannel(UpdateChannel_T *aChannel);
152 HRESULT setChannel(UpdateChannel_T aChannel);
153 HRESULT getRepositoryURL(com::Utf8Str &aRepo);
154 HRESULT setRepositoryURL(const com::Utf8Str &aRepo);
155 HRESULT getProxyMode(ProxyMode_T *aMode);
156 HRESULT setProxyMode(ProxyMode_T aMode);
157 HRESULT getProxyURL(com::Utf8Str &aAddress);
158 HRESULT setProxyURL(const com::Utf8Str &aAddress);
159 HRESULT getLastCheckDate(com::Utf8Str &aData);
160 /** @} */
161};
162
163/** @todo Put this into an own module, e.g. HostUpdateAgentImpl.[cpp|h]. */
164
165class ATL_NO_VTABLE HostUpdateAgent :
166 public UpdateAgent
167{
168public:
169 /** @name COM and internal init/term/mapping cruft.
170 * @{ */
171 DECLARE_COMMON_CLASS_METHODS(HostUpdateAgent)
172
173 HRESULT init(VirtualBox *aVirtualBox);
174 void uninit(void);
175
176 HRESULT FinalConstruct(void);
177 void FinalRelease(void);
178 /** @} */
179
180private:
181 /** @name Implemented (pure) virtual methods from UpdateAgent.
182 * @{ */
183 HRESULT check(ComPtr<IProgress> &aProgress);
184
185 DECLCALLBACK(HRESULT) i_updateTask(UpdateAgentTask *pTask);
186 /** @} */
187
188 HRESULT i_checkForUpdate(void);
189 HRESULT i_checkForUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent);
190};
191
192#endif /* !MAIN_INCLUDED_UpdateAgentImpl_h */
193
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette