VirtualBox

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

最後變更 在這個檔案從94778是 94756,由 vboxsync 提交於 3 年 前

Main/VBoxManage/Update check: More code + docs for proxy settings handling. bugref:7983

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.5 KB
 
1/* $Id: UpdateAgentImpl.h 94756 2022-04-29 08:55:44Z 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.alldomusa.eu.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 /** @} */
79
80protected:
81 /** The update agent's event source. */
82 const ComObjPtr<EventSource> m_EventSource;
83 VirtualBox * const m_VirtualBox;
84
85 /** @name Data members.
86 * @{ */
87 settings::UpdateAgent *m;
88
89 struct Data
90 {
91 UpdateAgentTaskResult m_lastResult;
92 Utf8Str m_strName;
93 /** Vector of update channels this agent supports. */
94 const std::vector<UpdateChannel_T> m_enmChannels;
95 bool m_fHidden;
96 UpdateState_T m_enmState;
97 uint32_t m_uOrder;
98 /** Whether to use the own (dedicated) proxy settings or
99 * use the ones of ISystemProperties. */
100 bool m_fUseOwnProxy;
101
102 Data(void)
103 {
104 m_fHidden = true;
105 m_enmState = UpdateState_Invalid;
106 m_uOrder = UINT32_MAX;
107 }
108 } mData;
109 /** @} */
110};
111
112class ATL_NO_VTABLE UpdateAgent :
113 public UpdateAgentWrap,
114 public UpdateAgentBase
115{
116public:
117 DECLARE_COMMON_CLASS_METHODS(UpdateAgent)
118
119 /** @name COM and internal init/term/mapping cruft.
120 * @{ */
121 HRESULT FinalConstruct();
122 void FinalRelease();
123
124 HRESULT init(VirtualBox *aVirtualBox);
125 void uninit(void);
126 /** @} */
127
128 /** @name Public methods for internal purposes only
129 * (ensure there is a caller and a read lock before calling them!) */
130 HRESULT i_loadSettings(const settings::UpdateAgent &data);
131 HRESULT i_saveSettings(settings::UpdateAgent &data);
132
133 virtual HRESULT i_setCheckCount(ULONG aCount);
134 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate);
135 /** @} */
136
137protected:
138
139 /** @name Internal helper methods.
140 * @{ */
141 HRESULT i_getProxyMode(ProxyMode_T *aMode);
142 HRESULT i_getProxyURL(com::Utf8Str &aAddress);
143 HRESULT i_configureProxy(RTHTTP hHttp);
144 HRESULT i_commitSettings(AutoWriteLock &aLock);
145 HRESULT i_reportError(int vrc, const char *pcszMsgFmt, ...);
146 /** @} */
147
148protected:
149 /** @name Wrapped IUpdateAgent attributes and methods.
150 * @{ */
151 HRESULT checkFor(ComPtr<IProgress> &aProgress);
152 HRESULT download(ComPtr<IProgress> &aProgress);
153 HRESULT install(ComPtr<IProgress> &aProgress);
154 HRESULT rollback(void);
155
156 HRESULT getName(com::Utf8Str &aName);
157 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
158 HRESULT getOrder(ULONG *aOrder);
159 HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps);
160 HRESULT getVersion(com::Utf8Str &aVer);
161 HRESULT getDownloadUrl(com::Utf8Str &aUrl);
162 HRESULT getWebUrl(com::Utf8Str &aUrl);
163 HRESULT getReleaseNotes(com::Utf8Str &aRelNotes);
164 HRESULT getEnabled(BOOL *aEnabled);
165 HRESULT setEnabled(BOOL aEnabled);
166 HRESULT getHidden(BOOL *aHidden);
167 HRESULT getState(UpdateState_T *aState);
168 HRESULT getCheckCount(ULONG *aCount);
169 HRESULT getCheckFrequency(ULONG *aFreqSeconds);
170 HRESULT setCheckFrequency(ULONG aFreqSeconds);
171 HRESULT getChannel(UpdateChannel_T *aChannel);
172 HRESULT setChannel(UpdateChannel_T aChannel);
173 HRESULT getRepositoryURL(com::Utf8Str &aRepo);
174 HRESULT setRepositoryURL(const com::Utf8Str &aRepo);
175 HRESULT getProxyMode(ProxyMode_T *aMode);
176 HRESULT setProxyMode(ProxyMode_T aMode);
177 HRESULT getProxyURL(com::Utf8Str &aAddress);
178 HRESULT setProxyURL(const com::Utf8Str &aAddress);
179 HRESULT getLastCheckDate(com::Utf8Str &aData);
180 HRESULT getIsCheckNeeded(BOOL *aCheckNeeded);
181 HRESULT getSupportedChannels(std::vector<UpdateChannel_T> &aSupportedChannels);
182 /** @} */
183};
184
185/** @todo Put this into an own module, e.g. HostUpdateAgentImpl.[cpp|h]. */
186
187class ATL_NO_VTABLE HostUpdateAgent :
188 public UpdateAgent
189{
190public:
191 /** @name COM and internal init/term/mapping cruft.
192 * @{ */
193 DECLARE_COMMON_CLASS_METHODS(HostUpdateAgent)
194
195 HRESULT init(VirtualBox *aVirtualBox);
196 void uninit(void);
197
198 HRESULT FinalConstruct(void);
199 void FinalRelease(void);
200 /** @} */
201
202private:
203 /** @name Implemented (pure) virtual methods from UpdateAgent.
204 * @{ */
205 HRESULT checkFor(ComPtr<IProgress> &aProgress);
206
207 DECLCALLBACK(HRESULT) i_checkForUpdateTask(UpdateAgentTask *pTask);
208 /** @} */
209
210 HRESULT i_checkForUpdate(void);
211 HRESULT i_checkForUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent);
212};
213
214#endif /* !MAIN_INCLUDED_UpdateAgentImpl_h */
215
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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