VirtualBox

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

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

Main/Update check: Added UpdateAgent::supportedChannels getter. bugref:7983

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

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