VirtualBox

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

Last change on this file since 94714 was 94704, checked in by vboxsync, 3 years ago

Main/Update check: Implemented and expose update agent events. ​​bugref:7983

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/* $Id: UpdateAgentImpl.h 94704 2022-04-25 10:28:46Z 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 /** @} */
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
92 Utf8Str m_strName;
93 bool m_fHidden;
94 UpdateState_T m_enmState;
95 uint32_t m_uOrder;
96
97 Data(void)
98 {
99 m_fHidden = true;
100 m_enmState = UpdateState_Invalid;
101 m_uOrder = UINT32_MAX;
102 }
103 } mData;
104 /** @} */
105};
106
107class ATL_NO_VTABLE UpdateAgent :
108 public UpdateAgentWrap,
109 public UpdateAgentBase
110{
111public:
112 DECLARE_COMMON_CLASS_METHODS(UpdateAgent)
113
114 /** @name COM and internal init/term/mapping cruft.
115 * @{ */
116 HRESULT FinalConstruct();
117 void FinalRelease();
118
119 HRESULT init(VirtualBox *aVirtualBox);
120 void uninit(void);
121 /** @} */
122
123 /** @name Public methods for internal purposes only
124 * (ensure there is a caller and a read lock before calling them!) */
125 HRESULT i_loadSettings(const settings::UpdateAgent &data);
126 HRESULT i_saveSettings(settings::UpdateAgent &data);
127
128 virtual HRESULT i_setCheckCount(ULONG aCount);
129 virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate);
130 /** @} */
131
132protected:
133
134 /** @name Internal helper methods.
135 * @{ */
136 HRESULT i_commitSettings(AutoWriteLock &aLock);
137 HRESULT i_reportError(int vrc, const char *pcszMsgFmt, ...);
138 /** @} */
139
140protected:
141 /** @name Wrapped IUpdateAgent attributes and methods.
142 * @{ */
143 HRESULT checkFor(ComPtr<IProgress> &aProgress);
144 HRESULT download(ComPtr<IProgress> &aProgress);
145 HRESULT install(ComPtr<IProgress> &aProgress);
146 HRESULT rollback(void);
147
148 HRESULT getName(com::Utf8Str &aName);
149 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
150 HRESULT getOrder(ULONG *aOrder);
151 HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps);
152 HRESULT getVersion(com::Utf8Str &aVer);
153 HRESULT getDownloadUrl(com::Utf8Str &aUrl);
154 HRESULT getWebUrl(com::Utf8Str &aUrl);
155 HRESULT getReleaseNotes(com::Utf8Str &aRelNotes);
156 HRESULT getEnabled(BOOL *aEnabled);
157 HRESULT setEnabled(BOOL aEnabled);
158 HRESULT getHidden(BOOL *aHidden);
159 HRESULT getState(UpdateState_T *aState);
160 HRESULT getCheckCount(ULONG *aCount);
161 HRESULT getCheckFrequency(ULONG *aFreqSeconds);
162 HRESULT setCheckFrequency(ULONG aFreqSeconds);
163 HRESULT getChannel(UpdateChannel_T *aChannel);
164 HRESULT setChannel(UpdateChannel_T aChannel);
165 HRESULT getRepositoryURL(com::Utf8Str &aRepo);
166 HRESULT setRepositoryURL(const com::Utf8Str &aRepo);
167 HRESULT getProxyMode(ProxyMode_T *aMode);
168 HRESULT setProxyMode(ProxyMode_T aMode);
169 HRESULT getProxyURL(com::Utf8Str &aAddress);
170 HRESULT setProxyURL(const com::Utf8Str &aAddress);
171 HRESULT getLastCheckDate(com::Utf8Str &aData);
172 HRESULT getIsCheckNeeded(BOOL *aCheckNeeded);
173 /** @} */
174};
175
176/** @todo Put this into an own module, e.g. HostUpdateAgentImpl.[cpp|h]. */
177
178class ATL_NO_VTABLE HostUpdateAgent :
179 public UpdateAgent
180{
181public:
182 /** @name COM and internal init/term/mapping cruft.
183 * @{ */
184 DECLARE_COMMON_CLASS_METHODS(HostUpdateAgent)
185
186 HRESULT init(VirtualBox *aVirtualBox);
187 void uninit(void);
188
189 HRESULT FinalConstruct(void);
190 void FinalRelease(void);
191 /** @} */
192
193private:
194 /** @name Implemented (pure) virtual methods from UpdateAgent.
195 * @{ */
196 HRESULT checkFor(ComPtr<IProgress> &aProgress);
197
198 DECLCALLBACK(HRESULT) i_checkForUpdateTask(UpdateAgentTask *pTask);
199 /** @} */
200
201 HRESULT i_checkForUpdate(void);
202 HRESULT i_checkForUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent);
203};
204
205#endif /* !MAIN_INCLUDED_UpdateAgentImpl_h */
206
Note: See TracBrowser for help on using the repository browser.

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