VirtualBox

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

Last change on this file since 94981 was 94981, checked in by vboxsync, 2 years ago

Main/Update check Removed update agent-specific proxy settings. ​bugref:7983

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/* $Id: UpdateAgentImpl.h 94981 2022-05-10 14:48:36Z 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 "EventImpl.h"
29#include "UpdateAgentWrap.h"
30#include "HostUpdateAgentWrap.h"
31
32class UpdateAgentTask;
33struct UpdateAgentTaskParms;
34
35struct UpdateAgentTaskResult
36{
37 Utf8Str strVer;
38 Utf8Str strWebUrl;
39 Utf8Str strDownloadUrl;
40 UpdateSeverity_T enmSeverity;
41 Utf8Str strReleaseNotes;
42};
43
44class UpdateAgentBase
45{
46protected: /* Not directly instancable. */
47
48 UpdateAgentBase()
49 : m_VirtualBox(NULL)
50 , m(new settings::UpdateAgent) { }
51
52 virtual ~UpdateAgentBase() { delete m; }
53
54public:
55
56 /** @name Pure virtual public methods for internal purposes only
57 * (ensure there is a caller and a read lock before calling them!)
58 * @{ */
59 virtual HRESULT i_loadSettings(const settings::UpdateAgent &data) = 0;
60 virtual HRESULT i_saveSettings(settings::UpdateAgent &data) = 0;
61
62 virtual HRESULT i_setCheckCount(ULONG aCount) = 0;
63 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate) = 0;
64 /** @} */
65
66protected:
67
68 /** @name Pure virtual internal task callbacks.
69 * @{ */
70 friend UpdateAgentTask;
71 virtual DECLCALLBACK(HRESULT) i_checkForUpdateTask(UpdateAgentTask *pTask) = 0;
72 /** @} */
73
74 /** @name Static helper methods.
75 * @{ */
76 static Utf8Str i_getPlatformInfo(void);
77 const char *i_proxyModeToStr(ProxyMode_T enmMode);
78 bool i_urlSchemeIsSupported(const Utf8Str &strUrl) const;
79 /** @} */
80
81protected:
82 /** The update agent's event source. */
83 const ComObjPtr<EventSource> m_EventSource;
84 VirtualBox * const m_VirtualBox;
85
86 /** @name Data members.
87 * @{ */
88 settings::UpdateAgent *m;
89
90 struct Data
91 {
92 UpdateAgentTaskResult m_lastResult;
93 Utf8Str m_strName;
94 /** Vector of update channels this agent supports. */
95 const std::vector<UpdateChannel_T> m_enmChannels;
96 bool m_fHidden;
97 UpdateState_T m_enmState;
98 uint32_t m_uOrder;
99
100 Data(void)
101 {
102 m_fHidden = true;
103 m_enmState = UpdateState_Invalid;
104 m_uOrder = UINT32_MAX;
105 }
106 } mData;
107 /** @} */
108};
109
110class ATL_NO_VTABLE UpdateAgent :
111 public UpdateAgentWrap,
112 public UpdateAgentBase
113{
114public:
115 DECLARE_COMMON_CLASS_METHODS(UpdateAgent)
116
117 /** @name COM and internal init/term/mapping cruft.
118 * @{ */
119 HRESULT FinalConstruct();
120 void FinalRelease();
121
122 HRESULT init(VirtualBox *aVirtualBox);
123 void uninit(void);
124 /** @} */
125
126 /** @name Public methods for internal purposes only
127 * (ensure there is a caller and a read lock before calling them!) */
128 HRESULT i_loadSettings(const settings::UpdateAgent &data);
129 HRESULT i_saveSettings(settings::UpdateAgent &data);
130
131 virtual HRESULT i_setCheckCount(ULONG aCount);
132 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate);
133 /** @} */
134
135protected:
136
137 /** @name Internal helper methods.
138 * @{ */
139 HRESULT i_getProxyMode(ProxyMode_T *aMode);
140 HRESULT i_getProxyURL(com::Utf8Str &aAddress);
141 HRESULT i_configureProxy(RTHTTP hHttp);
142 HRESULT i_commitSettings(AutoWriteLock &aLock);
143 HRESULT i_reportError(int vrc, const char *pcszMsgFmt, ...);
144 /** @} */
145
146protected:
147 /** @name Wrapped IUpdateAgent attributes and methods.
148 * @{ */
149 HRESULT checkFor(ComPtr<IProgress> &aProgress);
150 HRESULT download(ComPtr<IProgress> &aProgress);
151 HRESULT install(ComPtr<IProgress> &aProgress);
152 HRESULT rollback(void);
153
154 HRESULT getName(com::Utf8Str &aName);
155 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
156 HRESULT getOrder(ULONG *aOrder);
157 HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps);
158 HRESULT getVersion(com::Utf8Str &aVer);
159 HRESULT getDownloadUrl(com::Utf8Str &aUrl);
160 HRESULT getWebUrl(com::Utf8Str &aUrl);
161 HRESULT getReleaseNotes(com::Utf8Str &aRelNotes);
162 HRESULT getEnabled(BOOL *aEnabled);
163 HRESULT setEnabled(BOOL aEnabled);
164 HRESULT getHidden(BOOL *aHidden);
165 HRESULT getState(UpdateState_T *aState);
166 HRESULT getCheckCount(ULONG *aCount);
167 HRESULT getCheckFrequency(ULONG *aFreqSeconds);
168 HRESULT setCheckFrequency(ULONG aFreqSeconds);
169 HRESULT getChannel(UpdateChannel_T *aChannel);
170 HRESULT setChannel(UpdateChannel_T aChannel);
171 HRESULT getRepositoryURL(com::Utf8Str &aRepo);
172 HRESULT setRepositoryURL(const com::Utf8Str &aRepo);
173 HRESULT getLastCheckDate(com::Utf8Str &aData);
174 HRESULT getIsCheckNeeded(BOOL *aCheckNeeded);
175 HRESULT getSupportedChannels(std::vector<UpdateChannel_T> &aSupportedChannels);
176 /** @} */
177};
178
179/** @todo Put this into an own module, e.g. HostUpdateAgentImpl.[cpp|h]. */
180
181class ATL_NO_VTABLE HostUpdateAgent :
182 public UpdateAgent
183{
184public:
185 /** @name COM and internal init/term/mapping cruft.
186 * @{ */
187 DECLARE_COMMON_CLASS_METHODS(HostUpdateAgent)
188
189 HRESULT init(VirtualBox *aVirtualBox);
190 void uninit(void);
191
192 HRESULT FinalConstruct(void);
193 void FinalRelease(void);
194 /** @} */
195
196private:
197 /** @name Implemented (pure) virtual methods from UpdateAgent.
198 * @{ */
199 HRESULT checkFor(ComPtr<IProgress> &aProgress);
200
201 DECLCALLBACK(HRESULT) i_checkForUpdateTask(UpdateAgentTask *pTask);
202 /** @} */
203
204 HRESULT i_checkForUpdate(void);
205 HRESULT i_checkForUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent);
206};
207
208#endif /* !MAIN_INCLUDED_UpdateAgentImpl_h */
209
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use