VirtualBox

Changeset 94643 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 20, 2022 9:08:37 AM (3 years ago)
Author:
vboxsync
Message:

Main/Update check: Big overhaul of the API and functionality.

  • Now uses VBOX_WITH_UPDATE_AGENT to entirely disable the feature (enabled by default).
  • Main: Uses new (more abstract) API as proposed in the latest UML docs.
  • Main: Added support for several events.
  • Main: Added support for update severities, order and dependencies (all optional).
  • Settings/XML: Now has own "Updates" branch to also cover other updatable components (later); not part of the system properties anymore.
  • Prepared for GuestAdditions and ExtPack updates.
  • FE/Qt: Adapted to new API.
  • FE/VBoxManage: Adapted to new API; uses more uniform (common) synopsis "modify" and "list" for modifying and listing (showing) update settings.
  • Docs: Fixed various typos, extended documentation.

Work in progress. bugref:7983

Location:
trunk/src/VBox/Main
Files:
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r94521 r94643  
    146146  VBOX_MAIN_DEFS += VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    147147 endif
     148endif
     149ifdef VBOX_WITH_UPDATE_AGENT
     150VBOX_MAIN_DEFS += VBOX_WITH_UPDATE_AGENT
    148151endif
    149152ifdef VBOX_WITH_USB_CARDREADER
     
    522525        $(if $(VBOX_USB_WITH_INOTIFY),VBOX_USB_WITH_INOTIFY,) \
    523526        $(if $(VBOX_WITH_NAT_SERVICE),VBOX_WITH_NAT_SERVICE,) \
    524         $(if $(VBOX_WITH_LIBCURL),VBOX_WITH_HOST_UPDATE_CHECK,) \
     527        $(if $(VBOX_WITH_UPDATE_AGENT),VBOX_WITH_UPDATE_AGENT,) \
    525528        $(if $(VBOX_WITH_IOMMU_AMD),VBOX_WITH_IOMMU_AMD,) \
    526529        $(if $(VBOX_WITH_IOMMU_INTEL),VBOX_WITH_IOMMU_INTEL,) \
     
    629632        src-server/HostNetworkInterfaceImpl.cpp \
    630633        src-server/HostPower.cpp \
    631         src-server/HostUpdateImpl.cpp \
     634        $(if $(VBOX_WITH_UPDATE_AGENT),src-server/UpdateAgentImpl.cpp,) \
    632635        src-server/HostVideoInputDeviceImpl.cpp \
    633636        src-server/HostDrivePartitionImpl.cpp \
     
    18621865        $(VBoxAPIWrap_0_OUTDIR)/apiwrappers-sources-odd \
    18631866        $(VBoxAPIWrap_0_OUTDIR)/apiwrappers-sources-even
    1864 
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r94601 r94643  
    1103411034
    1103511035  <enum
    11036     name="UpdateCheckType"
    11037     uuid="ac34bb91-6739-4791-b30f-ce84e57928bb"
    11038     >
    11039     <desc>
    11040       Which type of software to check whether a new version exists.
    11041     </desc>
    11042     <const name="None"              value="0">
    11043       <desc>No flags specified. Do not use this.</desc>
    11044     </const>
    11045     <const name="VirtualBox"        value="1"/>
    11046     <const name="ExtensionPack"     value="2"/>
    11047     <const name="GuestAdditions"    value="3"/>
     11036    name="UpdateChannel"
     11037    uuid="9f1562a5-e47a-496b-a818-66776f06ce40"
     11038    >
     11039    <const name="Invalid"     value="0">
     11040      <desc>No channel specified. Do not use this.</desc>
     11041    </const>
     11042    <const name="Stable"      value="1">
     11043      <desc>All stable releases (maintenance and minor releases within the same major release)</desc>
     11044    </const>
     11045    <const name="All"         value="2">
     11046      <desc>All stable releases, including major versions.</desc>
     11047    </const>
     11048    <const name="WithBetas"   value="3">
     11049      <desc>All stable and major releases, including beta versions.</desc>
     11050    </const>
     11051    <const name="WithTesting" value="4">
     11052      <desc>All stable, major and beta releases, including testing versions.</desc>
     11053    </const>
    1104811054  </enum>
    1104911055
     11056  <enum
     11057    name="UpdateSeverity"
     11058    uuid="359a5fee-8a06-4306-8068-2f2dd5cde06f"
     11059    >
     11060    <const name="Invalid"  value="0">
     11061      <desc>No severity specified. Do not use this.</desc>
     11062    </const>
     11063    <const name="Critical" value="1">
     11064      <desc>Update contains critical patches.</desc>
     11065    </const>
     11066    <const name="Major"    value="2">
     11067      <desc>Update contains a major version.</desc>
     11068    </const>
     11069    <const name="Minor"    value="3">
     11070      <desc>Update contains a minor version.</desc>
     11071    </const>
     11072    <const name="Testing"  value="4">
     11073      <desc>Update contains a testing version. Use with caution!</desc>
     11074    </const>
     11075  </enum>
     11076
     11077  <enum
     11078    name="UpdateState"
     11079    uuid="6623e363-c892-45f8-80cb-4e8ffd9b4e60"
     11080    >
     11081    <const name="Invalid"         value="0">
     11082        <desc>Invalid / not set update state.</desc>
     11083    </const>
     11084    <const name="Available"       value="1">
     11085        <desc>An uppdate is available.</desc>
     11086    </const>
     11087    <const name="NotAvailable"    value="2">
     11088        <desc>No update available.</desc>
     11089    </const>
     11090    <const name="Downloading"     value="3">
     11091        <desc>Update is being downloaded currently.</desc>
     11092    </const>
     11093    <const name="Downloaded"      value="4">
     11094        <desc>Update has been successfully downloaded.</desc>
     11095    </const>
     11096    <const name="Installing"      value="5">
     11097        <desc>Update is being installed currently.</desc>
     11098    </const>
     11099    <const name="Installed"       value="6">
     11100        <desc>Update has been successfully installed.</desc>
     11101    </const>
     11102    <const name="UserInteraction" value="7">
     11103        <desc>Update requires user interaction to continue.</desc>
     11104    </const>
     11105    <const name="Canceled"        value="8">
     11106        <desc>Update has been canceled.</desc>
     11107    </const>
     11108    <const name="Maintenance"     value="9">
     11109        <desc>Update service currently is in maintenance mode.</desc>
     11110    </const>
     11111    <const name="Error"           value="10">
     11112        <desc>An error occurred while updating.</desc>
     11113    </const>
     11114  </enum>
     11115
    1105011116  <interface
    11051     name="IHostUpdate" extends="$unknown"
    11052     uuid="6fa2671b-0547-448e-bc7c-94e9e173bf57"
     11117    name="IUpdateAgent" extends="$unknown"
     11118    uuid="de87048a-036c-4a27-a0f8-73b51e66c2ca"
    1105311119    wsmap="managed"
    1105411120    rest="managed"
     
    1105711123
    1105811124    <desc>
    11059       Represents the state of the update checking logic (a singleton returned
    11060       by <link to="IHost::update" /> attribute).
     11125      Abstract parent interface for handling updateable software components.
    1106111126    </desc>
    1106211127
    11063     <method name="updateCheck">
    11064       <desc>
    11065         Check for a newer version of software based on the 'checkType' value.
    11066       </desc>
    11067       <param name="checkType" type="UpdateCheckType" dir="in">
    11068         <desc>The type of software to check.</desc>
    11069       </param>
     11128    <method name="check">
     11129      <desc>
     11130        Checks for an update.
     11131      </desc>
    1107011132      <param name="progress" type="IProgress" dir="return">
    1107111133        <desc>Progress object to track operation completion.</desc>
     
    1107311135    </method>
    1107411136
    11075     <attribute name="updateResponse" type="boolean" readonly="yes">
    11076       <desc>
    11077         The response from the <link to="IHostUpdate::updateCheck"/> method.
    11078       </desc>
    11079     </attribute>
    11080 
    11081     <attribute name="updateVersion" type="wstring" readonly="yes">
    11082       <desc>
    11083        The newer version of the software returned by calling the update check
    11084        <link to="IHostUpdate::updateCheck"/> method.
    11085       </desc>
    11086     </attribute>
    11087 
    11088     <attribute name="updateURL" type="wstring" readonly="yes">
    11089       <desc>
    11090        The download URL of the newer software version returned by calling the
    11091        update check <link to="IHostUpdate::updateCheck"/> method.
    11092       </desc>
    11093     </attribute>
    11094 
    11095     <attribute name="updateCheckNeeded" type="boolean" readonly="yes">
    11096       <desc>
    11097         Is it time to check for a newer version of software?
     11137    <method name="download">
     11138      <desc>
     11139        Downloads the update.
     11140      </desc>
     11141      <result name="VBOX_E_NOT_SUPPORTED">
     11142        Downloading update not supported.
     11143      </result>
     11144      <param name="progress" type="IProgress" dir="return">
     11145        <desc>Progress object to track operation completion.</desc>
     11146      </param>
     11147    </method>
     11148
     11149    <method name="install">
     11150      <desc>
     11151        Installs the update.
     11152      </desc>
     11153      <result name="VBOX_E_NOT_SUPPORTED">
     11154        Installing update not supported.
     11155      </result>
     11156      <param name="progress" type="IProgress" dir="return">
     11157        <desc>Progress object to track operation completion.</desc>
     11158      </param>
     11159    </method>
     11160
     11161    <method name="rollback">
     11162      <desc>
     11163        Rolls back installing the update.
     11164      </desc>
     11165      <result name="VBOX_E_NOT_SUPPORTED">
     11166        Rolling back update not supported.
     11167      </result>
     11168    </method>
     11169
     11170    <attribute name="name" type="wstring" readonly="yes">
     11171      <desc>
     11172        Name of the update component.
     11173      </desc>
     11174    </attribute>
     11175
     11176    <attribute name="order" type="unsigned long" readonly="yes">
     11177      <desc>
     11178        Order hint the update component needs to run at, in conjunction with other update components.
     11179      </desc>
     11180      <result name="0">
     11181        No order preferred / disabled.
     11182      </result>
     11183      <note>
     11184        Lower numbers mean higher priority. 0 means no order or disabled.
     11185      </note>
     11186    </attribute>
     11187
     11188    <attribute name="dependsOn" type="wstring" readonly="yes" safearray="yes">
     11189      <desc>
     11190        Array of other update component names this component depends on before being able to get installed.
     11191      </desc>
     11192      <note>
     11193        Ordered entries, highest priority first. No dependencies when array is empty.
     11194        Dependency entries also can contain a minimum version number after the update component name, separated by an "@",
     11195        e.g. "Guest [email protected]_BETA2".
     11196      </note>
     11197    </attribute>
     11198
     11199    <attribute name="version" type="wstring" readonly="yes">
     11200      <result name="VBOX_E_INVALID_OBJECT_STATE">
     11201        Result not available yet.
     11202      </result>
     11203      <desc>
     11204        Version the update contains.
     11205      </desc>
     11206    </attribute>
     11207
     11208    <attribute name="downloadUrl" type="wstring" readonly="yes">
     11209      <result name="VBOX_E_INVALID_OBJECT_STATE">
     11210        Result not available yet.
     11211      </result>
     11212      <desc>
     11213        Download URL of the update.
     11214      </desc>
     11215    </attribute>
     11216
     11217    <attribute name="webUrl" type="wstring" readonly="yes">
     11218      <result name="VBOX_E_INVALID_OBJECT_STATE">
     11219        Result not available yet.
     11220      </result>
     11221      <desc>
     11222        Web URL of the update.
     11223      </desc>
     11224    </attribute>
     11225
     11226    <attribute name="releaseNotes" type="wstring" readonly="yes">
     11227      <result name="VBOX_E_INVALID_OBJECT_STATE">
     11228        Result not available yet.
     11229      </result>
     11230      <desc>
     11231        Release notes of the update.
     11232      </desc>
     11233    </attribute>
     11234
     11235    <attribute name="enabled" type="boolean" readonly="no">
     11236      <desc>
     11237        Enables or disables the update component.
     11238      </desc>
     11239    </attribute>
     11240
     11241    <attribute name="hidden" type="boolean" readonly="yes">
     11242      <desc>
     11243        Whether the update component shall be hidden from the user or not.
     11244      </desc>
     11245    </attribute>
     11246
     11247    <attribute name="state" type="UpdateState" readonly="yes">
     11248      <desc>
     11249        Returns the current update state.
     11250      </desc>
     11251    </attribute>
     11252
     11253    <attribute name="checkFrequency" type="unsigned long" readonly="no">
     11254      <desc>
     11255        The update check frequency (in seconds).
     11256      </desc>
     11257    </attribute>
     11258
     11259    <attribute name="channel" type="UpdateChannel" readonly="no">
     11260      <desc>
     11261        Update channel to use for checking for updates.
     11262      </desc>
     11263    </attribute>
     11264
     11265    <attribute name="repositoryURL" type="wstring" readonly="no">
     11266      <desc>
     11267        Update repository URL to use for retrieving the update.
     11268      </desc>
     11269      <note>
     11270        Only repositories with the https:// URL scheme are allowed.
     11271      </note>
     11272    </attribute>
     11273
     11274    <attribute name="proxyMode" type="ProxyMode" readonly="no">
     11275      <desc>
     11276        Proxy mode to use.
     11277      </desc>
     11278    </attribute>
     11279
     11280    <attribute name="proxyURL" type="wstring" readonly="no">
     11281      <desc>
     11282        Proxy URL to use.
     11283      </desc>
     11284    </attribute>
     11285
     11286    <attribute name="lastCheckDate" type="wstring" readonly="yes">
     11287      <desc>
     11288        Date of last update check.
     11289      </desc>
     11290      <note>
     11291        Uses ISO date.
     11292      </note>
     11293    </attribute>
     11294
     11295    <attribute name="checkCount" type="unsigned long" readonly="yes">
     11296      <desc>
     11297        How many times the update check has happened already.
     11298      </desc>
     11299    </attribute>
     11300  </interface>
     11301
     11302  <interface
     11303    name="IHostUpdateAgent" extends="IUpdateAgent"
     11304    uuid="26934cbf-5bb6-4a27-9599-83ca057905d4"
     11305    wsmap="managed"
     11306    reservedMethods="12" reservedAttributes="24"
     11307    >
     11308    <desc>
     11309      Implementation of the <link to="IUpdateAgent" /> object
     11310      for VirtualBox host updates.
     11311    </desc>
     11312    <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/>
     11313  </interface>
     11314
     11315  <interface
     11316    name="IUpdateAgentEvent" extends="$unknown"
     11317    uuid="aa1987dc-6402-4e3c-a0e9-68e87d301a83"
     11318    wsmap="managed"
     11319    reservedAttributes="4"
     11320    >
     11321    <desc>
     11322      Abstract base interface for update agent events.
     11323    </desc>
     11324
     11325    <attribute name="eventSource" type="IEventSource" readonly="yes">
     11326      <desc>
     11327        Event source for update agent events.
     11328      </desc>
     11329    </attribute>
     11330
     11331  </interface>
     11332
     11333  <interface
     11334    name="IUpdateAgentSettingsChangedEvent" extends="IUpdateAgentEvent"
     11335    uuid="7bfd3718-b2ad-4112-8a86-328ebeb7b091"
     11336    wsmap="managed"
     11337    reservedMethods="4" reservedAttributes="8"
     11338    >
     11339    <desc>
     11340      Notification when update agent settings have been changed.
     11341    </desc>
     11342  </interface>
     11343
     11344  <interface
     11345    name="IUpdateAgentErrorEvent" extends="IUpdateAgentEvent"
     11346    uuid="2dad1ad8-78be-441d-b4fa-9cff25ee16b2"
     11347    wsmap="managed"
     11348    reservedAttributes="4"
     11349    >
     11350    <desc>
     11351    </desc>
     11352
     11353    <attribute name="msg" type="wstring" readonly="yes">
     11354      <desc>
     11355        Error message in human readable format.
     11356      </desc>
     11357    </attribute>
     11358
     11359    <attribute name="rcError" type="long" readonly="yes">
     11360      <desc>
     11361        IPRT-style error code.
     11362      </desc>
     11363    </attribute>
     11364
     11365  </interface>
     11366
     11367  <interface
     11368    name="IUpdateAgentAvailableEvent" extends="IUpdateAgentEvent"
     11369    uuid="7b931bfa-3b2b-4220-87ce-86cb0dee7ed1"
     11370    wsmap="managed"
     11371    reservedAttributes="4"
     11372    >
     11373    <desc>
     11374      Notification when an update is available.
     11375    </desc>
     11376
     11377    <attribute name="version" type="wstring" readonly="yes">
     11378      <desc>
     11379        Version of the update.
     11380      </desc>
     11381    </attribute>
     11382
     11383    <attribute name="channel" type="UpdateChannel" readonly="yes">
     11384      <desc>
     11385        Channel containing the update.
     11386      </desc>
     11387    </attribute>
     11388
     11389    <attribute name="severity" type="UpdateSeverity" readonly="yes">
     11390      <desc>
     11391        Severity of the update.
     11392      </desc>
     11393    </attribute>
     11394
     11395    <attribute name="downloadURL" type="wstring" readonly="yes">
     11396      <desc>
     11397        Download URL of the update.
     11398      </desc>
     11399    </attribute>
     11400
     11401    <attribute name="webURL" type="wstring" readonly="yes">
     11402      <desc>
     11403        Web URL of the update.
     11404      </desc>
     11405    </attribute>
     11406
     11407    <attribute name="releaseNotes" type="wstring" readonly="yes">
     11408      <desc>
     11409        Release notes of the update.
     11410      </desc>
     11411    </attribute>
     11412
     11413  </interface>
     11414
     11415  <interface
     11416    name="IUpdateAgentStateChangedEvent" extends="IUpdateAgentEvent"
     11417    uuid="7da1b997-10ea-4690-99ff-df78bf309164"
     11418    wsmap="managed"
     11419    reservedAttributes="4"
     11420    >
     11421    <desc>
     11422    </desc>
     11423
     11424    <attribute name="state" type="UpdateState" readonly="yes">
     11425      <desc>
    1109811426      </desc>
    1109911427    </attribute>
     
    1178012108    </method>
    1178112109
    11782     <attribute name="update" type="IHostUpdate" readonly="yes">
    11783       <desc>The check for newer software object (singleton).</desc>
     12110    <attribute name="updateHost" type="IUpdateAgent" readonly="yes">
     12111      <desc>Checks for new VirtualBox host versions.</desc>
     12112    </attribute>
     12113
     12114    <attribute name="updateExtPack" type="IUpdateAgent" readonly="yes">
     12115      <desc>Checks for new VirtualBox Extension Pack versions.</desc>
     12116    </attribute>
     12117
     12118    <attribute name="updateGuestAdditions" type="IUpdateAgent" readonly="yes">
     12119        <desc>Checks for new Guest Additions versions.</desc>
    1178412120    </attribute>
    1178512121
     
    1182812164  </enum>
    1182912165
    11830   <enum name="VBoxUpdateTarget" uuid="900d4a76-7b08-4af8-a453-f331e783eaee">
    11831     <desc> The preferred release type used for determining whether a newer version of VirtualBox is available. <link to="ISystemProperties::VBoxUpdateTarget"/></desc>
    11832     <const name="Stable" value="0">
    11833       <desc>Stable releases: new maintenance and minor releases within the same major release version.  This is the default.</desc>
    11834     </const>
    11835     <const name="AllReleases" value="1">
    11836       <desc>All releases: new maintenance, minor, and major releases.</desc>
    11837     </const>
    11838     <const name="WithBetas" value="2">
    11839       <desc>With betas: new maintenance, minor, and major releases as well as beta releases.</desc>
    11840     </const>
    11841   </enum>
    11842 
    1184312166  <interface
    1184412167    name="ISystemProperties"
    1184512168    extends="$unknown"
    11846     uuid="31cdb11d-9bb0-455a-b2ca-a1a5b1177912"
     12169    uuid="e6bf9165-6685-4ebe-96cd-9c1b7ab7f776"
    1184712170    wsmap="managed"
    1184812171    rest="managed"
     
    1237112694        Returns an array of officially supported values for enum <link to="ChipsetType"/>,
    1237212695        in the sense of what is e.g. worth offering in the VirtualBox GUI.
    12373       </desc>
    12374     </attribute>
    12375 
    12376     <attribute name="VBoxUpdateEnabled" type="boolean">
    12377       <desc> Is the VirtualBox update check enabled?</desc>
    12378     </attribute>
    12379 
    12380     <attribute name="VBoxUpdateFrequency" type="unsigned long">
    12381       <desc> How often should a check for a newer version of VirtualBox be made? (in days)</desc>
    12382     </attribute>
    12383 
    12384     <attribute name="VBoxUpdateLastCheckDate" type="wstring">
    12385       <desc>
    12386         When was the update check last performed? If updating this attribute the
    12387         string must be in ISO 8601 format (e.g. 2020-05-11T21:13:39.348416000Z).
    12388       </desc>
    12389     </attribute>
    12390 
    12391     <attribute name="VBoxUpdateTarget" type="VBoxUpdateTarget">
    12392       <desc> The preferred release type used for determining whether a newer version of VirtualBox is available.</desc>
    12393     </attribute>
    12394 
    12395     <attribute name="VBoxUpdateCount" type="unsigned long">
    12396       <desc> The count of update check attempts.</desc>
    12397     </attribute>
    12398 
    12399     <attribute name="supportedVBoxUpdateTargetTypes" type="VBoxUpdateTarget" safearray="yes" readonly="yes">
    12400       <desc>
    12401         Returns an array of officially supported values for enum <link to="VBoxUpdateTarget"/>.
    1240212696      </desc>
    1240312697    </attribute>
  • trunk/src/VBox/Main/include/HostImpl.h

    r93115 r94643  
    119119    HRESULT getAcceleration3DAvailable(BOOL *aAcceleration3DAvailable);
    120120    HRESULT getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices);
    121     HRESULT getUpdate(ComPtr<IHostUpdate> &aUpdate);
     121    HRESULT getUpdateHost(ComPtr<IUpdateAgent> &aUpdate);
     122    HRESULT getUpdateExtPack(ComPtr<IUpdateAgent> &aUpdate);
     123    HRESULT getUpdateGuestAdditions(ComPtr<IUpdateAgent> &aUpdate);
    122124    HRESULT getUpdateResponse(BOOL *aUpdateNeeded);
    123125    HRESULT getUpdateVersion(com::Utf8Str &aUpdateVersion);
     
    168170
    169171    HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
    170     HRESULT UpdateCheck(UpdateCheckType_T aCheckType,
    171                         ComPtr<IProgress> &aProgress);
    172172
    173173    // Internal Methods.
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r93115 r94643  
    143143    HRESULT getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes) RT_OVERRIDE;
    144144    HRESULT getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes) RT_OVERRIDE;
    145     HRESULT getSupportedVBoxUpdateTargetTypes(std::vector<VBoxUpdateTarget_T> &aSupportedVBoxUpdateTargetTypes) RT_OVERRIDE;
    146     HRESULT getVBoxUpdateEnabled(BOOL *aVBoxUpdateEnabled) RT_OVERRIDE;
    147     HRESULT setVBoxUpdateEnabled(BOOL aVBoxUpdateEnabled) RT_OVERRIDE;
    148     HRESULT getVBoxUpdateFrequency(ULONG *aVBoxUpdateFrequency) RT_OVERRIDE;
    149     HRESULT setVBoxUpdateFrequency(ULONG aVBoxUpdateFrequency) RT_OVERRIDE;
    150     HRESULT getVBoxUpdateLastCheckDate(com::Utf8Str &aVBoxUpdateLastCheckDate) RT_OVERRIDE;
    151     HRESULT setVBoxUpdateLastCheckDate(const com::Utf8Str &aVBoxUpdateLastCheckDate) RT_OVERRIDE;
    152     HRESULT getVBoxUpdateTarget(VBoxUpdateTarget_T *aVBoxUpdateTarget) RT_OVERRIDE;
    153     HRESULT setVBoxUpdateTarget(VBoxUpdateTarget_T aVBoxUpdateTarget) RT_OVERRIDE;
    154     HRESULT getVBoxUpdateCount(ULONG *aVBoxUpdateCount) RT_OVERRIDE;
    155     HRESULT setVBoxUpdateCount(ULONG aVBoxUpdateCount) RT_OVERRIDE;
    156145    HRESULT getLanguageId(com::Utf8Str &aLanguageId) RT_OVERRIDE;
    157146    HRESULT setLanguageId(const com::Utf8Str &aLanguageId) RT_OVERRIDE;
     
    199188    HRESULT i_setDefaultAdditionsISO(const com::Utf8Str &aPath);
    200189    HRESULT i_setDefaultFrontend(const com::Utf8Str &aDefaultFrontend);
    201     HRESULT i_setVBoxUpdateLastCheckDate(const com::Utf8Str &aVBoxUpdateLastCheckDate);
    202190
    203191    VirtualBox * const  mParent;
  • trunk/src/VBox/Main/include/UpdateAgentImpl.h

    r94642 r94643  
    11/* $Id$ */
    22/** @file
    3  * VirtualBox COM class implementation
     3 * Update agent COM class implementation - Header
    44 */
    55
     
    1616 */
    1717
    18 #ifndef MAIN_INCLUDED_HostUpdateImpl_h
    19 #define MAIN_INCLUDED_HostUpdateImpl_h
     18#ifndef MAIN_INCLUDED_UpdateAgentImpl_h
     19#define MAIN_INCLUDED_UpdateAgentImpl_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
    24 #include "HostUpdateWrap.h"
    25 #include <iprt/http.h> /* RTHTTP */
     24#include <iprt/http.h>
    2625
     26#include <VBox/settings.h>
    2727
    28 class ATL_NO_VTABLE HostUpdate
    29     : public HostUpdateWrap
     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 ATL_NO_VTABLE UpdateAgent
     44    : public UpdateAgentWrap
    3045{
    3146public:
    32     DECLARE_COMMON_CLASS_METHODS(HostUpdate)
     47    DECLARE_COMMON_CLASS_METHODS(UpdateAgent)
    3348
     49    /** @name COM and internal init/term/mapping cruft.
     50     * @{ */
    3451    HRESULT FinalConstruct();
    3552    void FinalRelease();
    3653
    37     // public initializer/uninitializer for internal purposes only
    3854    HRESULT init(VirtualBox *aVirtualBox);
    39     void uninit();
     55    void uninit(void);
     56    /** @}  */
    4057
    41 private:
    42     /** @name wrapped IHostUpdate attributes and methods
     58    /** @name Public methods for internal purposes only
     59     *        (ensure there is a caller and a read lock before calling them!) */
     60    HRESULT i_loadSettings(const settings::UpdateAgent &data);
     61    HRESULT i_saveSettings(settings::UpdateAgent &data);
     62
     63    virtual HRESULT i_setCheckCount(ULONG aCount);
     64    virtual HRESULT i_setLastCheckDate(const com::Utf8Str &aDate);
     65    /** @}  */
     66
     67protected:
     68    /** @name Wrapped IUpdateAgent attributes and methods
    4369     * @{ */
    44     HRESULT updateCheck(UpdateCheckType_T aCheckType, ComPtr<IProgress> &aProgress) RT_OVERRIDE;
    45     HRESULT getUpdateResponse(BOOL *aUpdateNeeded) RT_OVERRIDE;
    46     HRESULT getUpdateVersion(com::Utf8Str &aUpdateVersion) RT_OVERRIDE;
    47     HRESULT getUpdateURL(com::Utf8Str &aUpdateURL) RT_OVERRIDE;
    48     HRESULT getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded) RT_OVERRIDE;
     70    virtual HRESULT check(ComPtr<IProgress> &aProgress) RT_OVERRIDE = 0;
     71    virtual HRESULT download(ComPtr<IProgress> &aProgress) RT_OVERRIDE;
     72    virtual HRESULT install(ComPtr<IProgress> &aProgress) RT_OVERRIDE;
     73    virtual HRESULT rollback(void) RT_OVERRIDE;
     74
     75    virtual HRESULT getName(com::Utf8Str &aName);
     76    virtual HRESULT getOrder(ULONG *aOrder);
     77    virtual HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps);
     78    virtual HRESULT getVersion(com::Utf8Str &aVer);
     79    virtual HRESULT getDownloadUrl(com::Utf8Str &aUrl);
     80    virtual HRESULT getWebUrl(com::Utf8Str &aUrl);
     81    virtual HRESULT getReleaseNotes(com::Utf8Str &aRelNotes);
     82    virtual HRESULT getEnabled(BOOL *aEnabled);
     83    virtual HRESULT setEnabled(BOOL aEnabled);
     84    virtual HRESULT getHidden(BOOL *aHidden);
     85    virtual HRESULT getState(UpdateState_T *aState);
     86    virtual HRESULT getCheckCount(ULONG *aCount);
     87    virtual HRESULT getCheckFrequency(ULONG  *aFreqSeconds);
     88    virtual HRESULT setCheckFrequency(ULONG aFreqSeconds);
     89    virtual HRESULT getChannel(UpdateChannel_T *aChannel);
     90    virtual HRESULT setChannel(UpdateChannel_T aChannel);
     91    virtual HRESULT getRepositoryURL(com::Utf8Str &aRepo);
     92    virtual HRESULT setRepositoryURL(const com::Utf8Str &aRepo);
     93    virtual HRESULT getProxyMode(ProxyMode_T *aMode);
     94    virtual HRESULT setProxyMode(ProxyMode_T aMode);
     95    virtual HRESULT getProxyURL(com::Utf8Str &aAddress);
     96    virtual HRESULT setProxyURL(const com::Utf8Str &aAddress);
     97    virtual HRESULT getLastCheckDate(com::Utf8Str &aData);
    4998    /** @} */
    5099
    51 #ifdef VBOX_WITH_HOST_UPDATE_CHECK
    52     Utf8Str i_platformInfo();
    53     class UpdateCheckTask;
    54     HRESULT i_updateCheckTask(UpdateCheckTask *pTask);
    55     HRESULT i_checkForVBoxUpdate();
    56     HRESULT i_checkForVBoxUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent,
    57                                       ComPtr<ISystemProperties> const &ptrSystemProperties);
    58 #endif
     100    /** @name Internal task callbacks.
     101     * @{ */
     102    friend UpdateAgentTask;
     103    virtual DECLCALLBACK(HRESULT) i_updateTask(UpdateAgentTask *pTask) = 0;
     104    /** @} */
     105
     106    /** @name Static helper methods.
     107     * @{ */
     108    static Utf8Str i_getPlatformInfo(void);
     109    /** @} */
     110
     111protected:
     112    VirtualBox * const m_VirtualBox;
    59113
    60114    /** @name Data members.
    61115     * @{ */
    62     VirtualBox * const mVirtualBox;
    63     BOOL     m_updateNeeded;
    64     Utf8Str  m_updateVersion;
    65     Utf8Str  m_updateURL;
     116    settings::UpdateAgent *m;
     117
     118    struct Data
     119    {
     120        UpdateAgentTaskResult m_lastResult;
     121
     122        Utf8Str               m_strName;
     123        bool                  m_fHidden;
     124        UpdateState_T         m_enmState;
     125        uint32_t              m_uOrder;
     126
     127        Data(void)
     128        {
     129            m_fHidden  = true;
     130            m_enmState = UpdateState_Invalid;
     131            m_uOrder   = UINT32_MAX;
     132        }
     133    } mData;
    66134    /** @} */
    67135};
    68136
    69 #endif /* !MAIN_INCLUDED_HostUpdateImpl_h */
     137/** @todo Put this into an own module, e.g. HostUpdateAgentImpl.[cpp|h]. */
    70138
    71 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
     139class ATL_NO_VTABLE HostUpdateAgent :
     140    public UpdateAgent
     141{
     142public:
     143    /** @name COM and internal init/term/mapping cruft.
     144     * @{ */
     145    DECLARE_COMMON_CLASS_METHODS(HostUpdateAgent)
     146
     147    HRESULT init(VirtualBox *aVirtualBox);
     148    void    uninit(void);
     149
     150    HRESULT FinalConstruct(void);
     151    void    FinalRelease(void);
     152    /** @}  */
     153
     154    virtual DECLCALLBACK(HRESULT) i_updateTask(UpdateAgentTask *pTask);
     155
     156private:
     157    /** @name Implemented (pure) virtual methods from UpdateAgent.
     158     * @{ */
     159    HRESULT check(ComPtr<IProgress> &aProgress);
     160    /** @}  */
     161
     162#ifdef VBOX_WITH_UPDATE_AGENT
     163    HRESULT i_updateAgentTask(UpdateAgentTask *pTask);
     164    HRESULT i_checkForUpdate(void);
     165    HRESULT i_checkForUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent);
     166#endif
     167};
     168
     169#endif /* !MAIN_INCLUDED_UpdateAgentImpl_h */
     170
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r94597 r94643  
    4545#include "LoggingNew.h"
    4646#include "Performance.h"
    47 #include "HostUpdateImpl.h"
     47#ifdef VBOX_WITH_UPDATE_AGENT
     48# include "UpdateAgentImpl.h"
     49#endif
    4850
    4951#include "MediumImpl.h"
     
    250252    bool                    fPersistentConfigUpToDate;
    251253
    252     /** The reference to the update check handler singleton. */
    253     const ComObjPtr<HostUpdate> pHostUpdate;
     254#ifdef VBOX_WITH_UPDATE_AGENT
     255    /** Reference to the host update agent. */
     256    const ComObjPtr<HostUpdateAgent> pUpdateHost;
     257#endif
    254258};
    255259
     
    308312    m->hostDnsMonitorProxy.init(m->pParent);
    309313
    310     hrc = unconst(m->pHostUpdate).createObject();
     314#ifdef VBOX_WITH_UPDATE_AGENT
     315    hrc = unconst(m->pUpdateHost).createObject();
    311316    if (SUCCEEDED(hrc))
    312         hrc = m->pHostUpdate->init(m->pParent);
     317        hrc = m->pUpdateHost->init(m->pParent);
    313318    AssertComRCReturn(hrc, hrc);
     319#endif
    314320
    315321#if defined(RT_OS_WINDOWS)
     
    502508    m->hostDnsMonitorProxy.uninit();
    503509
    504     if (m->pHostUpdate)
    505     {
    506         m->pHostUpdate->uninit();
    507         unconst(m->pHostUpdate).setNull();
    508     }
     510#ifdef VBOX_WITH_UPDATE_AGENT
     511    if (m->pUpdateHost)
     512    {
     513        m->pUpdateHost->uninit();
     514        unconst(m->pUpdateHost).setNull();
     515    }
     516#endif
    509517
    510518#ifdef VBOX_WITH_USB
     
    19922000}
    19932001
    1994 
    1995 HRESULT Host::getUpdate(ComPtr<IHostUpdate> &aUpdate)
    1996 {
    1997     HRESULT hrc = m->pHostUpdate.queryInterfaceTo(aUpdate.asOutParam());
     2002HRESULT Host::getUpdateHost(ComPtr<IUpdateAgent> &aUpdate)
     2003{
     2004#ifdef VBOX_WITH_UPDATE_AGENT
     2005    HRESULT hrc = m->pUpdateHost.queryInterfaceTo(aUpdate.asOutParam());
    19982006    return hrc;
    1999 }
    2000 
     2007#else
     2008    RT_NOREF(aUpdate);
     2009    ReturnComNotImplemented();
     2010#endif
     2011}
     2012
     2013HRESULT Host::getUpdateExtPack(ComPtr<IUpdateAgent> &aUpdate)
     2014{
     2015    RT_NOREF(aUpdate);
     2016    ReturnComNotImplemented();
     2017}
     2018
     2019HRESULT Host::getUpdateGuestAdditions(ComPtr<IUpdateAgent> &aUpdate)
     2020{
     2021    RT_NOREF(aUpdate);
     2022    ReturnComNotImplemented();
     2023}
    20012024
    20022025HRESULT  Host::getHostDrives(std::vector<ComPtr<IHostDrive> > &aHostDrives)
     
    20672090HRESULT Host::i_saveSettings(settings::Host &data)
    20682091{
    2069 #ifdef VBOX_WITH_USB
    20702092    AutoCaller autoCaller(this);
    20712093    if (FAILED(autoCaller.rc()))
     
    20742096    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    20752097
     2098    HRESULT rc;
     2099
     2100#ifdef VBOX_WITH_USB
    20762101    data.llUSBDeviceFilters.clear();
    20772102    data.llUSBDeviceSources.clear();
     
    20872112    }
    20882113
    2089     return m->pUSBProxyService->i_saveSettings(data.llUSBDeviceSources);
     2114    rc = m->pUSBProxyService->i_saveSettings(data.llUSBDeviceSources);
     2115    ComAssertComRCRet(rc, rc);
    20902116#else
    20912117    RT_NOREF(data);
     2118#endif /* VBOX_WITH_USB */
     2119
     2120#ifdef VBOX_WITH_UPDATE_AGENT
     2121    rc = m->pUpdateHost->i_saveSettings(data.updateHost);
     2122    ComAssertComRCRet(rc, rc);
     2123    /** @todo Add handling for ExtPack and Guest Additions updates here later. See @bugref{7983}. */
     2124#endif
     2125
    20922126    return S_OK;
    2093 #endif /* VBOX_WITH_USB */
    2094 
    20952127}
    20962128
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r94578 r94643  
    117117    m->fExclusiveHwVirt = true;
    118118#endif
    119 
    120     m->fVBoxUpdateEnabled = true;
    121     m->uVBoxUpdateCount = 0;
    122     m->uVBoxUpdateFrequency = 1; // daily is the default
    123     m->uVBoxUpdateTarget = VBoxUpdateTarget_Stable;
    124119
    125120    HRESULT rc = S_OK;
     
    18291824}
    18301825
    1831 HRESULT SystemProperties::getSupportedVBoxUpdateTargetTypes(std::vector<VBoxUpdateTarget_T> &aSupportedVBoxUpdateTargetTypes)
    1832 {
    1833     static const VBoxUpdateTarget_T aVBoxUpdateTargetTypes[] =
    1834     {
    1835         VBoxUpdateTarget_Stable,
    1836         VBoxUpdateTarget_AllReleases,
    1837         VBoxUpdateTarget_WithBetas
    1838     };
    1839     aSupportedVBoxUpdateTargetTypes.assign(aVBoxUpdateTargetTypes,
    1840                                            aVBoxUpdateTargetTypes + RT_ELEMENTS(aVBoxUpdateTargetTypes));
    1841     return S_OK;
    1842 }
    1843 
    18441826
    18451827// public methods only for internal purposes
     
    18771859
    18781860    m->strLanguageId     = data.strLanguageId;
    1879 
    1880     m->fVBoxUpdateEnabled               = data.fVBoxUpdateEnabled;
    1881     m->uVBoxUpdateFrequency             = data.uVBoxUpdateFrequency;
    1882     m->strVBoxUpdateLastCheckDate       = data.strVBoxUpdateLastCheckDate;
    1883     m->uVBoxUpdateTarget                = data.uVBoxUpdateTarget;
    1884     m->uVBoxUpdateCount                 = data.uVBoxUpdateCount;
    18851861
    18861862    rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath);
     
    22282204}
    22292205
    2230 HRESULT SystemProperties::i_setVBoxUpdateLastCheckDate(const com::Utf8Str &aVBoxUpdateLastCheckDate)
    2231 {
    2232     m->strVBoxUpdateLastCheckDate = aVBoxUpdateLastCheckDate;
    2233 
    2234     return S_OK;
    2235 }
    2236 
    2237 HRESULT SystemProperties::getVBoxUpdateEnabled(BOOL *aVBoxUpdateEnabled)
    2238 {
    2239     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2240 
    2241     *aVBoxUpdateEnabled = m->fVBoxUpdateEnabled;
    2242 
    2243     return S_OK;
    2244 }
    2245 
    2246 HRESULT SystemProperties::setVBoxUpdateEnabled(BOOL aVBoxUpdateEnabled)
    2247 {
    2248     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2249     m->fVBoxUpdateEnabled = !!aVBoxUpdateEnabled;
    2250     alock.release();
    2251 
    2252     // VirtualBox::i_saveSettings() needs vbox write lock
    2253     AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    2254     HRESULT rc = mParent->i_saveSettings();
    2255 
    2256     return rc;
    2257 }
    2258 
    2259 HRESULT SystemProperties::getVBoxUpdateCount(ULONG *aVBoxUpdateCount)
    2260 {
    2261     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2262 
    2263     *aVBoxUpdateCount = m->uVBoxUpdateCount;
    2264 
    2265     return S_OK;
    2266 }
    2267 
    2268 HRESULT SystemProperties::setVBoxUpdateCount(ULONG aVBoxUpdateCount)
    2269 {
    2270     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2271     m->uVBoxUpdateCount = aVBoxUpdateCount;
    2272     alock.release();
    2273 
    2274     // VirtualBox::i_saveSettings() needs vbox write lock
    2275     AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    2276     HRESULT rc = mParent->i_saveSettings();
    2277 
    2278     return rc;
    2279 }
    2280 
    22812206HRESULT SystemProperties::getLanguageId(com::Utf8Str &aLanguageId)
    22822207{
     
    23382263}
    23392264
    2340 HRESULT SystemProperties::getVBoxUpdateFrequency(ULONG *aVBoxUpdateFrequency)
    2341 {
    2342     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2343 
    2344     *aVBoxUpdateFrequency = m->uVBoxUpdateFrequency;
    2345 
    2346     return S_OK;
    2347 }
    2348 
    2349 HRESULT SystemProperties::setVBoxUpdateFrequency(ULONG aVBoxUpdateFrequency)
    2350 {
    2351     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2352     m->uVBoxUpdateFrequency = aVBoxUpdateFrequency;
    2353     alock.release();
    2354 
    2355     // VirtualBox::i_saveSettings() needs vbox write lock
    2356     AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    2357     HRESULT rc = mParent->i_saveSettings();
    2358 
    2359     return rc;
    2360 }
    2361 
    2362 HRESULT SystemProperties::getVBoxUpdateTarget(VBoxUpdateTarget_T *aVBoxUpdateTarget)
    2363 {
    2364     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2365     VBoxUpdateTarget_T enmTarget = *aVBoxUpdateTarget = (VBoxUpdateTarget_T)m->uVBoxUpdateTarget;
    2366     AssertMsgReturn(enmTarget == VBoxUpdateTarget_Stable ||
    2367                     enmTarget == VBoxUpdateTarget_AllReleases ||
    2368                     enmTarget == VBoxUpdateTarget_WithBetas,
    2369                     ("enmTarget=%d\n", enmTarget), E_UNEXPECTED);
    2370     return S_OK;
    2371 }
    2372 
    2373 HRESULT SystemProperties::setVBoxUpdateTarget(VBoxUpdateTarget_T aVBoxUpdateTarget)
    2374 {
    2375     /* Validate input. */
    2376     switch (aVBoxUpdateTarget)
    2377     {
    2378         case VBoxUpdateTarget_Stable:
    2379         case VBoxUpdateTarget_AllReleases:
    2380         case VBoxUpdateTarget_WithBetas:
    2381             break;
    2382         default:
    2383             return setError(E_INVALIDARG, tr("Invalid Target value: %d"), (int)aVBoxUpdateTarget);
    2384     }
    2385 
    2386     /* Set and write out settings. */
    2387     {
    2388         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2389         m->uVBoxUpdateTarget = aVBoxUpdateTarget;
    2390     }
    2391     AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
    2392     return mParent->i_saveSettings();
    2393 }
    2394 
    2395 HRESULT SystemProperties::getVBoxUpdateLastCheckDate(com::Utf8Str &aVBoxUpdateLastCheckDate)
    2396 {
    2397     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2398     aVBoxUpdateLastCheckDate = m->strVBoxUpdateLastCheckDate;
    2399     return S_OK;
    2400 }
    2401 
    2402 HRESULT SystemProperties::setVBoxUpdateLastCheckDate(const com::Utf8Str &aVBoxUpdateLastCheckDate)
    2403 {
    2404     /*
    2405      * Validate input.
    2406      */
    2407     Utf8Str const *pLastCheckDate = &aVBoxUpdateLastCheckDate;
    2408     RTTIMESPEC TimeSpec;
    2409 
    2410     if (pLastCheckDate->isEmpty() || !RTTimeSpecFromString(&TimeSpec, pLastCheckDate->c_str()))
    2411         return setErrorBoth(E_INVALIDARG, VERR_INVALID_PARAMETER,
    2412                             tr("Invalid LastCheckDate value: '%s'. "
    2413                                "Must be in ISO 8601 format (e.g. 2020-05-11T21:13:39.348416000Z)"), pLastCheckDate->c_str());
    2414 
    2415     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2416     HRESULT rc = i_setVBoxUpdateLastCheckDate(aVBoxUpdateLastCheckDate);
    2417     alock.release();
    2418     if (SUCCEEDED(rc))
    2419     {
    2420         // VirtualBox::i_saveSettings() needs vbox write lock
    2421         AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    2422         rc = mParent->i_saveSettings();
    2423     }
    2424 
    2425     return rc;
    2426 }
  • trunk/src/VBox/Main/src-server/UpdateAgentImpl.cpp

    r94550 r94643  
    11/* $Id$ */
    22/** @file
    3  * IHostUpdate COM class implementations.
     3 * IUpdateAgent COM class implementations.
    44 */
    55
     
    1717
    1818
    19 #define LOG_GROUP LOG_GROUP_MAIN_HOSTUPDATE
     19#define LOG_GROUP LOG_GROUP_MAIN_UPDATEAGENT
    2020
    2121#include <iprt/cpp/utils.h>
     
    3636
    3737#include "HostImpl.h"
    38 #include "HostUpdateImpl.h"
     38#include "UpdateAgentImpl.h"
    3939#include "ProgressImpl.h"
    4040#include "AutoCaller.h"
     
    4848////////////////////////////////////////////////////////////////////////////////
    4949//
    50 // HostUpdate private data definition
     50// UpdateAgent private data definition
    5151//
    5252////////////////////////////////////////////////////////////////////////////////
    5353
    54 #ifdef VBOX_WITH_HOST_UPDATE_CHECK
    55 
    56 class HostUpdate::UpdateCheckTask : public ThreadTask
     54class UpdateAgentTask : public ThreadTask
    5755{
    5856public:
    59     UpdateCheckTask(UpdateCheckType_T aCheckType, HostUpdate *aThat, Progress *aProgress)
    60         : m_checkType(aCheckType)
    61         , m_pHostUpdate(aThat)
    62         , m_ptrProgress(aProgress)
    63     {
    64         m_strTaskName = "UpdateCheckTask";
    65     }
    66     ~UpdateCheckTask() { }
     57    UpdateAgentTask(UpdateAgent *aThat, Progress *aProgress)
     58        : m_pParent(aThat)
     59        , m_pProgress(aProgress)
     60    {
     61        m_strTaskName = "UpdateAgentTask";
     62    }
     63    virtual ~UpdateAgentTask(void) { }
    6764
    6865private:
    69     void handler();
    70 
    71     UpdateCheckType_T m_checkType;
    72     HostUpdate *m_pHostUpdate;
    73 
     66    void handler(void);
     67
     68    /** Weak pointer to parent (update agent). */
     69    UpdateAgent         *m_pParent;
    7470    /** Smart pointer to the progress object for this job. */
    75     ComObjPtr<Progress> m_ptrProgress;
    76 
    77     friend class HostUpdate;  // allow member functions access to private data
     71    ComObjPtr<Progress>  m_pProgress;
     72
     73    friend class UpdateAgent;  // allow member functions access to private data
    7874};
    7975
    80 void HostUpdate::UpdateCheckTask::handler()
    81 {
    82     HostUpdate *pHostUpdate = this->m_pHostUpdate;
    83 
    84     LogFlowFuncEnter();
    85     LogFlowFunc(("HostUpdate %p\n", pHostUpdate));
    86 
    87     HRESULT rc = pHostUpdate->i_updateCheckTask(this);
    88 
    89     LogFlowFunc(("rc=%Rhrc\n", rc)); NOREF(rc);
    90     LogFlowFuncLeave();
    91 }
    92 
    93 Utf8Str HostUpdate::i_platformInfo()
     76void UpdateAgentTask::handler(void)
     77{
     78    UpdateAgent *pUpdateAgent = this->m_pParent;
     79    AssertPtr(pUpdateAgent);
     80
     81    HRESULT rc = pUpdateAgent->i_updateTask(this);
     82
     83    if (!m_pProgress.isNull())
     84        m_pProgress->i_notifyComplete(rc);
     85
     86    LogFlowFunc(("rc=%Rhrc\n", rc)); RT_NOREF(rc);
     87}
     88
     89
     90/*********************************************************************************************************************************
     91*   Update agent base class implementation                                                                                       *
     92*********************************************************************************************************************************/
     93UpdateAgent::UpdateAgent()
     94    : m_VirtualBox(NULL)
     95    , m(new settings::UpdateAgent)
     96{
     97}
     98
     99UpdateAgent::~UpdateAgent()
     100{
     101    delete m;
     102}
     103
     104HRESULT UpdateAgent::FinalConstruct()
     105{
     106    return BaseFinalConstruct();
     107}
     108
     109void UpdateAgent::FinalRelease()
     110{
     111    uninit();
     112
     113    BaseFinalRelease();
     114}
     115
     116HRESULT UpdateAgent::init(VirtualBox *aVirtualBox)
     117{
     118    // Enclose the state transition NotReady->InInit->Ready.
     119    AutoInitSpan autoInitSpan(this);
     120    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     121
     122    /* Weak reference to a VirtualBox object */
     123    unconst(m_VirtualBox) = aVirtualBox;
     124
     125    autoInitSpan.setSucceeded();
     126    return S_OK;
     127}
     128
     129void UpdateAgent::uninit()
     130{
     131    // Enclose the state transition Ready->InUninit->NotReady.
     132    AutoUninitSpan autoUninitSpan(this);
     133    if (autoUninitSpan.uninitDone())
     134        return;
     135}
     136
     137HRESULT UpdateAgent::download(ComPtr<IProgress> &aProgress)
     138{
     139    RT_NOREF(aProgress);
     140
     141    return VBOX_E_NOT_SUPPORTED;
     142}
     143
     144HRESULT UpdateAgent::install(ComPtr<IProgress> &aProgress)
     145{
     146    RT_NOREF(aProgress);
     147
     148    return VBOX_E_NOT_SUPPORTED;
     149}
     150
     151HRESULT UpdateAgent::rollback(void)
     152{
     153    return S_OK; /* No-op by default. */
     154}
     155
     156HRESULT UpdateAgent::getName(com::Utf8Str &aName)
     157{
     158    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     159
     160    aName = mData.m_strName;
     161
     162    return S_OK;
     163}
     164
     165HRESULT UpdateAgent::getOrder(ULONG *aOrder)
     166{
     167    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     168
     169    *aOrder = 0; /* 0 means no order / disabled. */
     170
     171    return S_OK;
     172}
     173
     174HRESULT UpdateAgent::getDependsOn(std::vector<com::Utf8Str> &aDeps)
     175{
     176    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     177
     178    aDeps.resize(0); /* No dependencies by default. */
     179
     180    return S_OK;
     181}
     182
     183HRESULT UpdateAgent::getVersion(com::Utf8Str &aVer)
     184{
     185    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     186
     187    aVer = mData.m_lastResult.strVer;
     188
     189    return S_OK;
     190}
     191
     192HRESULT UpdateAgent::getDownloadUrl(com::Utf8Str &aUrl)
     193{
     194    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     195
     196    aUrl = mData.m_lastResult.strDownloadUrl;
     197
     198    return S_OK;
     199}
     200
     201
     202HRESULT UpdateAgent::getWebUrl(com::Utf8Str &aUrl)
     203{
     204    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     205
     206    aUrl = mData.m_lastResult.strWebUrl;
     207
     208    return S_OK;
     209}
     210
     211HRESULT UpdateAgent::getReleaseNotes(com::Utf8Str &aRelNotes)
     212{
     213    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     214
     215    aRelNotes = mData.m_lastResult.strReleaseNotes;
     216
     217    return S_OK;
     218}
     219
     220HRESULT UpdateAgent::getEnabled(BOOL *aEnabled)
     221{
     222    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     223
     224    *aEnabled = m->fEnabled;
     225
     226    return S_OK;
     227}
     228
     229HRESULT UpdateAgent::setEnabled(const BOOL aEnabled)
     230{
     231    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     232
     233    m->fEnabled = aEnabled;
     234
     235    return S_OK;
     236}
     237
     238
     239HRESULT UpdateAgent::getHidden(BOOL *aHidden)
     240{
     241    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     242
     243    *aHidden = mData.m_fHidden;
     244
     245    return S_OK;
     246}
     247
     248HRESULT UpdateAgent::getState(UpdateState_T *aState)
     249{
     250    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     251
     252    *aState = mData.m_enmState;
     253
     254    return S_OK;
     255}
     256
     257HRESULT UpdateAgent::getCheckFrequency(ULONG *aFreqSeconds)
     258{
     259    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     260
     261    *aFreqSeconds = m->uCheckFreqSeconds;
     262
     263    return S_OK;
     264}
     265
     266HRESULT UpdateAgent::setCheckFrequency(ULONG aFreqSeconds)
     267{
     268    if (aFreqSeconds < RT_SEC_1DAY) /* Don't allow more frequent checks for now. */
     269        return setError(E_INVALIDARG, tr("Frequency too small; one day is the minimum"));
     270
     271    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     272
     273    m->uCheckFreqSeconds = aFreqSeconds;
     274
     275    return S_OK;
     276}
     277
     278HRESULT UpdateAgent::getChannel(UpdateChannel_T *aChannel)
     279{
     280    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     281
     282    *aChannel = m->enmChannel;
     283
     284    return S_OK;
     285}
     286
     287HRESULT UpdateAgent::setChannel(UpdateChannel_T aChannel)
     288{
     289    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     290
     291    m->enmChannel = aChannel;
     292
     293    return S_OK;
     294}
     295
     296HRESULT UpdateAgent::getCheckCount(ULONG *aCount)
     297{
     298    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     299
     300    *aCount = m->uCheckCount;
     301
     302    return S_OK;
     303}
     304
     305HRESULT UpdateAgent::getRepositoryURL(com::Utf8Str &aRepo)
     306{
     307    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     308
     309    aRepo = m->strRepoUrl;
     310
     311    return S_OK;
     312}
     313
     314HRESULT UpdateAgent::setRepositoryURL(const com::Utf8Str &aRepo)
     315{
     316    if (!aRepo.startsWith("https://", com::Utf8Str::CaseInsensitive))
     317        return setError(E_INVALIDARG, tr("Invalid URL scheme specified; only https:// is supported."));
     318
     319    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     320
     321    m->strRepoUrl = aRepo;
     322
     323    return S_OK;
     324}
     325
     326HRESULT UpdateAgent::getProxyMode(ProxyMode_T *aMode)
     327{
     328    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     329
     330    *aMode = m->enmProxyMode;
     331
     332    return S_OK;
     333}
     334
     335HRESULT UpdateAgent::setProxyMode(ProxyMode_T aMode)
     336{
     337    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     338
     339    m->enmProxyMode = aMode;
     340
     341    return S_OK;
     342}
     343
     344HRESULT UpdateAgent::getProxyURL(com::Utf8Str &aAddress)
     345{
     346    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     347
     348    aAddress = m->strProxyUrl;
     349
     350    return S_OK;
     351}
     352
     353HRESULT UpdateAgent::setProxyURL(const com::Utf8Str &aAddress)
     354{
     355    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     356
     357    m->strProxyUrl = aAddress;
     358
     359    return S_OK;
     360}
     361
     362HRESULT UpdateAgent::getLastCheckDate(com::Utf8Str &aDate)
     363{
     364    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     365
     366    aDate = m->strLastCheckDate;
     367
     368    return S_OK;
     369}
     370
     371/* static */
     372Utf8Str UpdateAgent::i_getPlatformInfo(void)
    94373{
    95374    /* Prepare platform report: */
     
    255534}
    256535
    257 HRESULT HostUpdate::i_checkForVBoxUpdate()
    258 {
    259     // Default to no update required
    260     m_updateNeeded = FALSE;
     536HRESULT UpdateAgent::i_loadSettings(const settings::UpdateAgent &data)
     537{
     538    AutoCaller autoCaller(this);
     539    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     540
     541    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     542
     543    m->fEnabled          = data.fEnabled;
     544    m->enmChannel        = data.enmChannel;
     545    m->uCheckFreqSeconds = data.uCheckFreqSeconds;
     546    m->strRepoUrl        = data.strRepoUrl;
     547    m->enmProxyMode      = data.enmProxyMode;
     548    m->strProxyUrl       = data.strProxyUrl;
     549    m->strLastCheckDate  = data.strLastCheckDate;
     550    m->uCheckCount       = data.uCheckCount;
     551
     552    return S_OK;
     553}
     554
     555HRESULT UpdateAgent::i_saveSettings(settings::UpdateAgent &data)
     556{
     557    AutoCaller autoCaller(this);
     558    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     559
     560    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     561
     562    data = *m;
     563
     564    return S_OK;
     565}
     566
     567HRESULT UpdateAgent::i_setCheckCount(ULONG aCount)
     568{
     569    AutoCaller autoCaller(this);
     570    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     571
     572    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     573
     574    m->uCheckCount = aCount;
     575
     576    return S_OK;
     577}
     578
     579HRESULT UpdateAgent::i_setLastCheckDate(const com::Utf8Str &aDate)
     580{
     581    AutoCaller autoCaller(this);
     582    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     583
     584    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     585
     586    m->strLastCheckDate = aDate;
     587
     588    return S_OK;
     589}
     590
     591#if 0
     592HRESULT UpdateAgent::getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded)
     593{
     594    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     595
     596    HRESULT rc;
     597    ComPtr<ISystemProperties> pSystemProperties;
     598    rc = m_VirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
     599    if (FAILED(rc))
     600        return rc;
     601
     602    /*
     603     * Is update checking enabled?
     604     */
     605    BOOL fVBoxUpdateEnabled;
     606    rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled);
     607    if (FAILED(rc))
     608        return rc;
     609
     610    if (!fVBoxUpdateEnabled)
     611    {
     612        *aUpdateCheckNeeded = false;
     613        return S_OK;
     614    }
     615
     616    /*
     617     * When was the last update?
     618     */
     619    Bstr strVBoxUpdateLastCheckDate;
     620    rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam());
     621    if (FAILED(rc))
     622        return rc;
     623
     624    // No prior update check performed so do so now
     625    if (strVBoxUpdateLastCheckDate.isEmpty())
     626    {
     627        *aUpdateCheckNeeded = true;
     628        return S_OK;
     629    }
     630
     631    // convert stored timestamp to time spec
     632    RTTIMESPEC LastCheckTime;
     633    if (!RTTimeSpecFromString(&LastCheckTime, Utf8Str(strVBoxUpdateLastCheckDate).c_str()))
     634    {
     635        *aUpdateCheckNeeded = true;
     636        return S_OK;
     637    }
     638
     639    /*
     640     * Compare last update with how often we are supposed to check for updates.
     641     */
     642    ULONG uVBoxUpdateFrequency = 0;  // value in days
     643    rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency);
     644    if (FAILED(rc))
     645        return rc;
     646
     647    if (!uVBoxUpdateFrequency)
     648    {
     649        /* Consider config (enable, 0 day interval) as checking once but never again.
     650           We've already check since we've got a date. */
     651        *aUpdateCheckNeeded = false;
     652        return S_OK;
     653    }
     654    uint64_t const cSecsInXDays = uVBoxUpdateFrequency * RT_SEC_1DAY_64;
     655
     656    RTTIMESPEC TimeDiff;
     657    RTTimeSpecSub(RTTimeNow(&TimeDiff), &LastCheckTime);
     658
     659    LogRelFunc(("Checking if seconds since last check (%lld) >= Number of seconds in %lu day%s (%lld)\n",
     660                RTTimeSpecGetSeconds(&TimeDiff), uVBoxUpdateFrequency, uVBoxUpdateFrequency > 1 ? "s" : "", cSecsInXDays));
     661
     662    if (RTTimeSpecGetSeconds(&TimeDiff) >= (int64_t)cSecsInXDays)
     663        *aUpdateCheckNeeded = true;
     664
     665    return S_OK;
     666}
     667#endif
     668
     669
     670/*********************************************************************************************************************************
     671*   Host update implementation                                                                                                   *
     672*********************************************************************************************************************************/
     673
     674HostUpdateAgent::HostUpdateAgent(void)
     675{
     676}
     677
     678HostUpdateAgent::~HostUpdateAgent(void)
     679{
     680}
     681
     682
     683HRESULT HostUpdateAgent::FinalConstruct(void)
     684{
     685    return BaseFinalConstruct();
     686}
     687
     688void HostUpdateAgent::FinalRelease(void)
     689{
     690    uninit();
     691
     692    BaseFinalRelease();
     693}
     694
     695HRESULT HostUpdateAgent::init(VirtualBox *aVirtualBox)
     696{
     697    // Enclose the state transition NotReady->InInit->Ready.
     698    AutoInitSpan autoInitSpan(this);
     699    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     700
     701    /* Weak reference to a VirtualBox object */
     702    unconst(m_VirtualBox) = aVirtualBox;
     703
     704    /* Initialize the bare minimum to get things going.
     705     ** @todo Add more stuff later here. */
     706    mData.m_strName = "VirtualBox";
     707    mData.m_fHidden = false;
     708
     709    /* Set default repository. */
     710    m->strRepoUrl = "https://update.virtualbox.org";
     711
     712    autoInitSpan.setSucceeded();
     713    return S_OK;
     714}
     715
     716void HostUpdateAgent::uninit()
     717{
     718    // Enclose the state transition Ready->InUninit->NotReady.
     719    AutoUninitSpan autoUninitSpan(this);
     720    if (autoUninitSpan.uninitDone())
     721        return;
     722}
     723
     724HRESULT HostUpdateAgent::check(ComPtr<IProgress> &aProgress)
     725{
     726    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     727
     728    ComObjPtr<Progress> pProgress;
     729    HRESULT rc = pProgress.createObject();
     730    if (FAILED(rc))
     731        return rc;
     732
     733    rc = pProgress->init(m_VirtualBox,
     734                         static_cast<IUpdateAgent*>(this),
     735                         tr("Checking for update for %s ...", this->mData.m_strName.c_str()),
     736                         TRUE /* aCancelable */);
     737    if (FAILED(rc))
     738        return rc;
     739
     740    /* initialize the worker task */
     741    UpdateAgentTask *pTask = new UpdateAgentTask(this, pProgress);
     742    rc = pTask->createThread();
     743    pTask = NULL;
     744    if (FAILED(rc))
     745        return rc;
     746
     747    return pProgress.queryInterfaceTo(aProgress.asOutParam());
     748}
     749
     750
     751/*********************************************************************************************************************************
     752*   Host update internal functions                                                                                               *
     753*********************************************************************************************************************************/
     754
     755DECLCALLBACK(HRESULT) HostUpdateAgent::i_updateTask(UpdateAgentTask *pTask)
     756{
     757    RT_NOREF(pTask);
    261758
    262759    // Following the sequence of steps in UIUpdateStepVirtualBox::sltStartStep()
    263     // Build up our query URL starting with the URL basename
    264     Utf8Str strUrl("https://update.virtualbox.org/query.php/?");
     760    // Build up our query URL starting with the configured repository.
     761    Utf8Str strUrl;
     762    strUrl.appendPrintf("%s/query.php/?", m->strRepoUrl.c_str());
     763
     764    // Add platform ID.
    265765    Bstr platform;
    266     HRESULT rc = mVirtualBox->COMGETTER(PackageType)(platform.asOutParam());
     766    HRESULT rc = m_VirtualBox->COMGETTER(PackageType)(platform.asOutParam());
    267767    AssertComRCReturn(rc, rc);
    268768    strUrl.appendPrintf("platform=%ls", platform.raw()); // e.g. SOLARIS_64BITS_GENERIC
     
    270770    // Get the complete current version string for the query URL
    271771    Bstr versionNormalized;
    272     rc = mVirtualBox->COMGETTER(VersionNormalized)(versionNormalized.asOutParam());
     772    rc = m_VirtualBox->COMGETTER(VersionNormalized)(versionNormalized.asOutParam());
    273773    AssertComRCReturn(rc, rc);
    274774    strUrl.appendPrintf("&version=%ls", versionNormalized.raw()); // e.g. 6.1.1
    275     // strUrl.appendPrintf("&version=6.0.12"); // comment out previous line and uncomment this one for testing
     775#ifdef DEBUG // Comment out previous line and uncomment this one for testing.
     776//  strUrl.appendPrintf("&version=6.0.12");
     777#endif
    276778
    277779    ULONG revision = 0;
    278     rc = mVirtualBox->COMGETTER(Revision)(&revision);
     780    rc = m_VirtualBox->COMGETTER(Revision)(&revision);
    279781    AssertComRCReturn(rc, rc);
    280782    strUrl.appendPrintf("_%u", revision); // e.g. 135618
    281783
    282     // acquire the System Properties interface
    283     ComPtr<ISystemProperties> ptrSystemProperties;
    284     rc = mVirtualBox->COMGETTER(SystemProperties)(ptrSystemProperties.asOutParam());
    285     AssertComRCReturn(rc, rc);
    286 
    287     // Update the VBoxUpdate setting 'VBoxUpdateLastCheckDate'
     784    // Update the last update check timestamp.
    288785    RTTIME Time;
    289786    RTTIMESPEC TimeNow;
    290787    char szTimeStr[RTTIME_STR_LEN];
    291788    RTTimeToString(RTTimeExplode(&Time, RTTimeNow(&TimeNow)), szTimeStr, sizeof(szTimeStr));
    292     LogRelFunc(("VBox updating UpdateDate with TimeString = %s\n", szTimeStr));
    293     rc = ptrSystemProperties->COMSETTER(VBoxUpdateLastCheckDate)(Bstr(szTimeStr).raw());
    294     AssertComRCReturn(rc, rc);
    295 
    296     // Update the queryURL and the VBoxUpdate setting 'VBoxUpdateCount'
    297     ULONG cVBoxUpdateCount = 0;
    298     rc = ptrSystemProperties->COMGETTER(VBoxUpdateCount)(&cVBoxUpdateCount);
    299     AssertComRCReturn(rc, rc);
    300 
    301     cVBoxUpdateCount++;
    302 
    303     rc = ptrSystemProperties->COMSETTER(VBoxUpdateCount)(cVBoxUpdateCount);
    304     AssertComRCReturn(rc, rc);
    305     strUrl.appendPrintf("&count=%u", cVBoxUpdateCount);
    306 
    307     // Update the query URL and the VBoxUpdate settings (if necessary) with the 'Target' information.
    308     VBoxUpdateTarget_T enmTarget = VBoxUpdateTarget_Stable; // default branch is 'stable'
    309     rc = ptrSystemProperties->COMGETTER(VBoxUpdateTarget)(&enmTarget);
    310     AssertComRCReturn(rc, rc);
    311 
    312     switch (enmTarget)
    313     {
    314         case VBoxUpdateTarget_AllReleases:
     789    LogRel2(("Update agent (%s): Setting last update check timestamp to '%s'\n", mData.m_strName.c_str(), szTimeStr));
     790
     791    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     792
     793    m->strLastCheckDate = szTimeStr;
     794    m->uCheckCount++;
     795
     796    strUrl.appendPrintf("&count=%RU32", m->uCheckCount);
     797
     798    alock.release();
     799
     800    // Update the query URL (if necessary) with the 'channel' information.
     801    switch (m->enmChannel)
     802    {
     803        case UpdateChannel_All:
    315804            strUrl.appendPrintf("&branch=allrelease"); // query.php expects 'allrelease' and not 'allreleases'
    316805            break;
    317         case VBoxUpdateTarget_WithBetas:
     806        case UpdateChannel_WithBetas:
    318807            strUrl.appendPrintf("&branch=withbetas");
    319808            break;
    320         case VBoxUpdateTarget_Stable:
     809        /** @todo Handle UpdateChannel_WithTesting once implemented on the backend. */
     810        case UpdateChannel_Stable:
     811            RT_FALL_THROUGH();
    321812        default:
    322813            strUrl.appendPrintf("&branch=stable");
     
    324815    }
    325816
    326     rc = ptrSystemProperties->COMSETTER(VBoxUpdateTarget)(enmTarget);
    327     AssertComRCReturn(rc, rc);
    328 
    329     LogRelFunc(("VBox update URL = %s\n", strUrl.c_str()));
     817    LogRel2(("Update agent (%s): Using URL '%s'\n", mData.m_strName.c_str(), strUrl.c_str()));
    330818
    331819    /*
     
    333821     */
    334822    Bstr version;
    335     rc = mVirtualBox->COMGETTER(Version)(version.asOutParam()); // e.g. 6.1.0_RC1
     823    rc = m_VirtualBox->COMGETTER(Version)(version.asOutParam()); // e.g. 6.1.0_RC1
    336824    AssertComRCReturn(rc, rc);
    337825
    338     Utf8StrFmt const strUserAgent("VirtualBox %ls <%s>", version.raw(), HostUpdate::i_platformInfo().c_str());
    339     LogRelFunc(("userAgent = %s\n", strUserAgent.c_str()));
     826    Utf8StrFmt const strUserAgent("VirtualBox %ls <%s>", version.raw(), UpdateAgent::i_getPlatformInfo().c_str());
     827    LogRel2(("Update agent (%s): Using user agent '%s'\n",  mData.m_strName.c_str(), strUserAgent.c_str()));
    340828
    341829    /*
     
    349837        try
    350838        {
    351             rc = i_checkForVBoxUpdateInner(hHttp, strUrl, strUserAgent, ptrSystemProperties);
     839            rc = i_checkForUpdateInner(hHttp, strUrl, strUserAgent);
    352840        }
    353841        catch (...)
     
    359847    }
    360848    else
    361         rc = setErrorVrc(vrc, tr("%s: RTHttpCreate() failed: %Rrc"), __FUNCTION__, vrc);
    362     return S_OK;
    363 }
    364 
    365 HRESULT HostUpdate::i_checkForVBoxUpdateInner(RTHTTP hHttp, Utf8Str const &strUrl, Utf8Str const &strUserAgent,
    366                                               ComPtr<ISystemProperties> const &ptrSystemProperties)
    367 {
    368     /// @todo Are there any other headers needed to be added first via RTHttpSetHeaders()?
     849        rc = setErrorVrc(vrc, tr("Update agent (%s): RTHttpCreate() failed: %Rrc"), mData.m_strName.c_str(), vrc);
     850
     851    return rc;
     852}
     853
     854HRESULT HostUpdateAgent::i_checkForUpdateInner(RTHTTP hHttp, Utf8Str const &strUrl, Utf8Str const &strUserAgent)
     855{
     856    /** @todo Are there any other headers needed to be added first via RTHttpSetHeaders()? */
    369857    int vrc = RTHttpAddHeader(hHttp, "User-Agent", strUserAgent.c_str(), strUserAgent.length(), RTHTTPADDHDR_F_BACK);
    370858    if (RT_FAILURE(vrc))
    371         return setErrorVrc(vrc, tr("%s: RTHttpAddHeader() failed: %Rrc (on User-Agent)"), __FUNCTION__, vrc);
     859        return setErrorVrc(vrc, tr("Update agent (%s): RTHttpAddHeader() failed: %Rrc (on User-Agent)"),
     860                                   mData.m_strName.c_str(), vrc);
    372861
    373862    /*
    374863     * Configure proxying.
    375864     */
    376     ProxyMode_T enmProxyMode;
    377     HRESULT rc = ptrSystemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
    378     if (FAILED(rc))
    379         return setError(rc, tr("%s: ISystemProperties::proxyMode() failed: %Rrc"), __FUNCTION__, rc);
    380 
    381     if (enmProxyMode == ProxyMode_Manual)
    382     {
    383         Bstr strProxyURL;
    384         rc = ptrSystemProperties->COMGETTER(ProxyURL)(strProxyURL.asOutParam());
    385         if (FAILED(rc))
    386             return setError(rc, tr("%s: ISystemProperties::proxyURL() failed: %Rrc"), __FUNCTION__, rc);
    387         vrc = RTHttpSetProxyByUrl(hHttp, Utf8Str(strProxyURL).c_str());
     865    if (m->enmProxyMode == ProxyMode_Manual)
     866    {
     867        vrc = RTHttpSetProxyByUrl(hHttp, m->strProxyUrl.c_str());
    388868        if (RT_FAILURE(vrc))
    389             return setErrorVrc(vrc, tr("%s: RTHttpSetProxyByUrl() failed: %Rrc"), __FUNCTION__, vrc);
    390     }
    391     else if (enmProxyMode == ProxyMode_System)
     869            return setErrorVrc(vrc, tr("Update agent (%s): RTHttpSetProxyByUrl() failed: %Rrc"), mData.m_strName.c_str(), vrc);
     870    }
     871    else if (m->enmProxyMode == ProxyMode_System)
    392872    {
    393873        vrc = RTHttpUseSystemProxySettings(hHttp);
    394874        if (RT_FAILURE(vrc))
    395             return setErrorVrc(vrc, tr("%s: RTHttpUseSystemProxySettings() failed: %Rrc"), __FUNCTION__, vrc);
     875            return setErrorVrc(vrc, tr("Update agent (%s): RTHttpUseSystemProxySettings() failed: %Rrc"),
     876                                       mData.m_strName.c_str(), vrc);
    396877    }
    397878    else
    398         Assert(enmProxyMode == ProxyMode_NoProxy);
     879        Assert(m->enmProxyMode == ProxyMode_NoProxy);
    399880
    400881    /*
     
    405886    vrc = RTHttpGetBinary(hHttp, strUrl.c_str(), &pvResponse, &cbResponse);
    406887    if (RT_FAILURE(vrc))
    407         return setErrorVrc(vrc, tr("%s: RTHttpGetBinary() failed: %Rrc"), __FUNCTION__, vrc);
     888        return setErrorVrc(vrc, tr("Update agent (%s): RTHttpGetBinary() failed: %Rrc"), mData.m_strName.c_str(), vrc);
    408889
    409890    /* Note! We can do nothing that might throw exceptions till we call RTHttpFreeResponse! */
     
    432913    size_t const cchWord1 = (size_t)(pchResponse - pchWord1);
    433914
     915    HRESULT rc;
     916
     917    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     918
    434919    /* Decode the two word: */
    435920    static char const s_szUpToDate[] = "UPTODATE";
     
    437922        && memcmp(pchWord0, s_szUpToDate, sizeof(s_szUpToDate) - 1) == 0)
    438923    {
    439         m_updateNeeded = FALSE;
     924        mData.m_enmState = UpdateState_NotAvailable;
    440925        rc = S_OK;
    441926    }
    442927    else
    443928    {
     929        mData.m_enmState = UpdateState_Error; /* Play safe by default. */
     930
    444931        vrc = RTStrValidateEncodingEx(pchWord0, cchWord0, 0 /*fFlags*/);
    445932        if (RT_SUCCESS(vrc))
     
    448935        {
    449936            /** @todo Any additional sanity checks we could perform here? */
    450             rc = m_updateVersion.assignEx(pchWord0, cchWord0);
     937            rc = mData.m_lastResult.strVer.assignEx(pchWord0, cchWord0);
    451938            if (SUCCEEDED(rc))
     939                rc = mData.m_lastResult.strDownloadUrl.assignEx(pchWord1, cchWord1);
     940
     941            if (RT_SUCCESS(vrc))
    452942            {
    453                 rc = m_updateURL.assignEx(pchWord1, cchWord1);
    454                 if (SUCCEEDED(rc))
    455                     m_updateNeeded = TRUE;
     943                /** @todo Implement this on the backend first.
     944                 *        We also could do some guessing based on the installed version vs. reported update version? */
     945                mData.m_lastResult.enmSeverity = UpdateSeverity_Invalid;
     946                mData.m_enmState               = UpdateState_Available;
    456947            }
    457             LogRelFunc(("HTTP server reply = %.*s %.*s\n", cchWord0, pchWord0, cchWord1, pchWord1));
     948
     949            LogRel(("Update agent (%s): HTTP server replied: %.*s %.*s\n",
     950                    mData.m_strName.c_str(), cchWord0, pchWord0, cchWord1, pchWord1));
    458951        }
    459952        else
    460             rc = setErrorVrc(vrc, tr("Invalid server response: %Rrc (%.*Rhxs -- %.*Rhxs)"),
    461                              vrc, cchWord0, pchWord0, cchWord1, pchWord1);
     953            rc = setErrorVrc(vrc, tr("Update agent (%s): Invalid server response: %Rrc (%.*Rhxs -- %.*Rhxs)"),
     954                             mData.m_strName.c_str(), vrc, cchWord0, pchWord0, cchWord1, pchWord1);
    462955    }
    463956
     
    467960}
    468961
    469 HRESULT HostUpdate::i_updateCheckTask(UpdateCheckTask *pTask)
    470 {
    471     LogFlowFuncEnter();
    472     AutoCaller autoCaller(this);
    473     HRESULT hrc = autoCaller.rc();
    474     if (SUCCEEDED(hrc))
    475     {
    476         try
    477         {
    478             switch (pTask->m_checkType)
    479             {
    480                 case UpdateCheckType_VirtualBox:
    481                     hrc = i_checkForVBoxUpdate();
    482                     break;
    483 # if 0
    484                 case UpdateCheckType_ExtensionPack:
    485                     hrc = i_checkForExtPackUpdate();
    486                     break;
    487 
    488                 case UpdateCheckType_GuestAdditions:
    489                     hrc = i_checkForGuestAdditionsUpdate();
    490                     break;
    491 # endif
    492                 default:
    493                     hrc = setError(E_FAIL, tr("Update check type %d is not implemented"), pTask->m_checkType);
    494                     break;
    495             }
    496         }
    497         catch (...)
    498         {
    499             AssertFailed();
    500             hrc = E_UNEXPECTED;
    501         }
    502     }
    503 
    504     if (!pTask->m_ptrProgress.isNull())
    505         pTask->m_ptrProgress->i_notifyComplete(hrc);
    506 
    507     LogFlowFunc(("rc=%Rhrc\n", hrc));
    508     LogFlowFuncLeave();
    509     return hrc;
    510 }
    511 
    512 #endif /* VBOX_WITH_HOST_UPDATE_CHECK */
    513 
    514 
    515 ////////////////////////////////////////////////////////////////////////////////
    516 //
    517 // HostUpdate constructor / destructor
    518 //
    519 // ////////////////////////////////////////////////////////////////////////////////
    520 HostUpdate::HostUpdate()
    521     : mVirtualBox(NULL)
    522 {
    523 }
    524 
    525 HostUpdate::~HostUpdate()
    526 {
    527 }
    528 
    529 
    530 HRESULT HostUpdate::FinalConstruct()
    531 {
    532     return BaseFinalConstruct();
    533 }
    534 
    535 void HostUpdate::FinalRelease()
    536 {
    537     uninit();
    538 
    539     BaseFinalRelease();
    540 }
    541 
    542 HRESULT HostUpdate::init(VirtualBox *aVirtualBox)
    543 {
    544     // Enclose the state transition NotReady->InInit->Ready.
    545     AutoInitSpan autoInitSpan(this);
    546     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    547 
    548     /* Weak reference to a VirtualBox object */
    549     unconst(mVirtualBox) = aVirtualBox;
    550 
    551     autoInitSpan.setSucceeded();
    552     return S_OK;
    553 }
    554 
    555 void HostUpdate::uninit()
    556 {
    557     // Enclose the state transition Ready->InUninit->NotReady.
    558     AutoUninitSpan autoUninitSpan(this);
    559     if (autoUninitSpan.uninitDone())
    560         return;
    561 }
    562 
    563 HRESULT HostUpdate::updateCheck(UpdateCheckType_T aCheckType,
    564                                 ComPtr<IProgress> &aProgress)
    565 {
    566 #ifdef VBOX_WITH_HOST_UPDATE_CHECK
    567     /* Validate input */
    568     switch (aCheckType)
    569     {
    570         case UpdateCheckType_VirtualBox:
    571             break;
    572         case UpdateCheckType_ExtensionPack:
    573             return setError(E_NOTIMPL, tr("UpdateCheckType::ExtensionPack is not implemented"));
    574         case UpdateCheckType_GuestAdditions:
    575             return setError(E_NOTIMPL, tr("UpdateCheckType::GuestAdditions is not implemented"));
    576         default:
    577             return setError(E_INVALIDARG, tr("Invalid aCheckType value %d"), aCheckType);
    578     }
    579 
    580     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    581 
    582     // Check whether VirtualBox updates have been disabled before spawning the task thread.
    583     ComPtr<ISystemProperties> pSystemProperties;
    584     HRESULT rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
    585     AssertComRCReturn(rc, rc);
    586 
    587     BOOL fVBoxUpdateEnabled = true;
    588     rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled);
    589     AssertComRCReturn(rc, rc);
    590 
    591     /** @todo r=bird: Not sure if this makes sense, it should at least have a
    592      * better status code and a proper error message.  Also, isn't this really
    593      * something the caller should check?  Presumably the caller already check
    594      * whther this was a good time to perform an update check (i.e. the configured
    595      * time has elapsed since last check) ...
    596      *
    597      * It would make sense to allow performing a one-off update check even if the
    598      * automatic update checking is disabled, wouldn't it? */
    599     if (!fVBoxUpdateEnabled)
    600         return E_NOTIMPL;
    601 
    602     ComObjPtr<Progress> pProgress;
    603     rc = pProgress.createObject();
    604     if (FAILED(rc))
    605         return rc;
    606 
    607     rc = pProgress->init(mVirtualBox,
    608                          static_cast<IHostUpdate*>(this),
    609                          tr("Checking for software update..."),
    610                          TRUE /* aCancelable */);
    611     if (FAILED(rc))
    612         return rc;
    613 
    614     /* initialize the worker task */
    615     UpdateCheckTask *pTask = new UpdateCheckTask(aCheckType, this, pProgress);
    616     rc = pTask->createThread();
    617     pTask = NULL;
    618     if (FAILED(rc))
    619         return rc;
    620 
    621     rc = pProgress.queryInterfaceTo(aProgress.asOutParam());
    622 
    623     return rc;
    624 #else  /* !VBOX_WITH_HOST_UPDATE_CHECK */
    625     RT_NOREF(aCheckType, aProgress);
    626     return setError(E_NOTIMPL, tr("Update checking support was not compiled into this VirtualBox build"));
    627 #endif /* !VBOX_WITH_HOST_UPDATE_CHECK */
    628 }
    629 
    630 HRESULT HostUpdate::getUpdateVersion(com::Utf8Str &aUpdateVersion)
    631 {
    632     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    633 
    634     aUpdateVersion = m_updateVersion;
    635 
    636     return S_OK;
    637 }
    638 
    639 HRESULT HostUpdate::getUpdateURL(com::Utf8Str &aUpdateURL)
    640 {
    641     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    642 
    643     aUpdateURL = m_updateURL;
    644 
    645     return S_OK;
    646 }
    647 
    648 HRESULT HostUpdate::getUpdateResponse(BOOL *aUpdateNeeded)
    649 {
    650     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    651 
    652     *aUpdateNeeded = m_updateNeeded;
    653 
    654     return S_OK;
    655 }
    656 
    657 HRESULT HostUpdate::getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded)
    658 {
    659     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    660 
    661     HRESULT rc;
    662     ComPtr<ISystemProperties> pSystemProperties;
    663     rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
    664     if (FAILED(rc))
    665         return rc;
    666 
    667     /*
    668      * Is update checking enabled?
    669      */
    670     BOOL fVBoxUpdateEnabled;
    671     rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled);
    672     if (FAILED(rc))
    673         return rc;
    674 
    675     if (!fVBoxUpdateEnabled)
    676     {
    677         *aUpdateCheckNeeded = false;
    678         return S_OK;
    679     }
    680 
    681     /*
    682      * When was the last update?
    683      */
    684     Bstr strVBoxUpdateLastCheckDate;
    685     rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam());
    686     if (FAILED(rc))
    687         return rc;
    688 
    689     // No prior update check performed so do so now
    690     if (strVBoxUpdateLastCheckDate.isEmpty())
    691     {
    692         *aUpdateCheckNeeded = true;
    693         return S_OK;
    694     }
    695 
    696     // convert stored timestamp to time spec
    697     RTTIMESPEC LastCheckTime;
    698     if (!RTTimeSpecFromString(&LastCheckTime, Utf8Str(strVBoxUpdateLastCheckDate).c_str()))
    699     {
    700         *aUpdateCheckNeeded = true;
    701         return S_OK;
    702     }
    703 
    704     /*
    705      * Compare last update with how often we are supposed to check for updates.
    706      */
    707     ULONG uVBoxUpdateFrequency = 0;  // value in days
    708     rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency);
    709     if (FAILED(rc))
    710         return rc;
    711 
    712     if (!uVBoxUpdateFrequency)
    713     {
    714         /* Consider config (enable, 0 day interval) as checking once but never again.
    715            We've already check since we've got a date. */
    716         *aUpdateCheckNeeded = false;
    717         return S_OK;
    718     }
    719     uint64_t const cSecsInXDays = uVBoxUpdateFrequency * RT_SEC_1DAY_64;
    720 
    721     RTTIMESPEC TimeDiff;
    722     RTTimeSpecSub(RTTimeNow(&TimeDiff), &LastCheckTime);
    723 
    724     LogRelFunc(("Checking if seconds since last check (%lld) >= Number of seconds in %lu day%s (%lld)\n",
    725                 RTTimeSpecGetSeconds(&TimeDiff), uVBoxUpdateFrequency, uVBoxUpdateFrequency > 1 ? "s" : "", cSecsInXDays));
    726 
    727     if (RTTimeSpecGetSeconds(&TimeDiff) >= (int64_t)cSecsInXDays)
    728         *aUpdateCheckNeeded = true;
    729 
    730     return S_OK;
    731 }
    732 
    733 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r94598 r94643  
    8080# include "PerformanceImpl.h"
    8181#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     82#ifdef VBOX_WITH_UPDATE_AGENT
     83# include "UpdateAgentImpl.h"
     84#endif
    8285#include "EventImpl.h"
    8386#ifdef VBOX_WITH_EXTPACK
  • trunk/src/VBox/Main/xml/Settings.cpp

    r94598 r94643  
    16381638    , uLogHistoryCount(3)
    16391639    , fExclusiveHwVirt(true)
    1640     , fVBoxUpdateEnabled(true)
    1641     , uVBoxUpdateCount(0)
    1642     , uVBoxUpdateFrequency(1)
    1643     , uVBoxUpdateTarget(VBoxUpdateTarget_Stable)
    16441640{
    16451641#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
     
    16471643#endif
    16481644}
     1645
     1646#ifdef VBOX_WITH_UPDATE_AGENT
     1647UpdateAgent::UpdateAgent()
     1648   : fEnabled(false)
     1649   , enmChannel(UpdateChannel_Stable)
     1650   , uCheckFreqSeconds(RT_SEC_1DAY)
     1651   , enmProxyMode(ProxyMode_NoProxy)
     1652   , uCheckCount(0)
     1653{
     1654}
     1655#endif /* VBOX_WITH_UPDATE_AGENT */
    16491656
    16501657/**
     
    23322339                            fCopyProxySettingsFromExtraData = true;
    23332340                        pelmGlobalChild->getAttributeValue("proxyUrl", systemProperties.strProxyUrl);
    2334                         pelmGlobalChild->getAttributeValue("updateEnabled", systemProperties.fVBoxUpdateEnabled);
    2335                         pelmGlobalChild->getAttributeValue("updateCount", systemProperties.uVBoxUpdateCount);
    2336                         pelmGlobalChild->getAttributeValue("updateFrequency", systemProperties.uVBoxUpdateFrequency);
    2337                         pelmGlobalChild->getAttributeValue("updateTarget", systemProperties.uVBoxUpdateTarget);
    2338                         pelmGlobalChild->getAttributeValue("updateLastCheckDate",
    2339                             systemProperties.strVBoxUpdateLastCheckDate);
    23402341                        pelmGlobalChild->getAttributeValue("LanguageId", systemProperties.strLanguageId);
    23412342                    }
     2343#ifdef VBOX_WITH_UPDATE_AGENT
     2344                    else if (pelmGlobalChild->nameEquals("Updates"))
     2345                    {
     2346                        /* We keep the updates configuration as part of the host for now, as the API exposes the IHost::updateHost attribute,
     2347                         * but use an own "Updates" branch in the XML for better structurizing stuff in the future. */
     2348                        UpdateAgent &updateHost = host.updateHost;
     2349
     2350                        xml::NodesLoop nlLevel4(*pelmGlobalChild);
     2351                        const xml::ElementNode *pelmLevel4Child;
     2352                        while ((pelmLevel4Child = nlLevel4.forAllNodes()))
     2353                        {
     2354                            if (pelmLevel4Child->nameEquals("Host"))
     2355                            {
     2356                                pelmLevel4Child->getAttributeValue("enabled", updateHost.fEnabled);
     2357                                pelmLevel4Child->getAttributeValue("channel", (uint32_t&)updateHost.enmChannel);
     2358                                pelmLevel4Child->getAttributeValue("checkFrequency", updateHost.uCheckFreqSeconds);
     2359                                pelmLevel4Child->getAttributeValue("repoUrl", updateHost.strRepoUrl);
     2360                                pelmLevel4Child->getAttributeValue("proxyMode", (uint32_t&)updateHost.enmProxyMode);
     2361                                pelmLevel4Child->getAttributeValue("proxyUrl", (uint32_t&)updateHost.enmProxyMode);
     2362                                pelmLevel4Child->getAttributeValue("lastCheckDate", updateHost.strLastCheckDate);
     2363                                pelmLevel4Child->getAttributeValue("checkCount", updateHost.uCheckCount);
     2364                            }
     2365                            /** @todo Add update settings for ExtPack and Guest Additions here later. See @bugref{7983}. */
     2366                        }
     2367
     2368                        /* Global enabled switch for updates. Currently bound to host updates, as this is the only update we have so far. */
     2369                        pelmGlobalChild->getAttributeValue("enabled", updateHost.fEnabled);
     2370                    }
     2371#endif
    23422372                    else if (pelmGlobalChild->nameEquals("ExtraData"))
    23432373                        readExtraData(*pelmGlobalChild, mapExtraDataItems);
     
    25612591#endif /* VBOX_WITH_CLOUD_NET */
    25622592
     2593#ifdef VBOX_WITH_UPDATE_AGENT
     2594    /* We keep the updates configuration as part of the host for now, as the API exposes the IHost::updateHost attribute,
     2595     * but use an own "Updates" branch in the XML for better structurizing stuff in the future. */
     2596    UpdateAgent &updateHost = host.updateHost;
     2597
     2598    xml::ElementNode *pelmUpdates = pelmGlobal->createChild("Updates");
     2599    /* Global enabled switch for updates. Currently bound to host updates, as this is the only update we have so far. */
     2600    pelmUpdates->setAttribute("enabled", updateHost.fEnabled);
     2601
     2602    xml::ElementNode *pelmUpdateHost = pelmUpdates->createChild("Host");
     2603    pelmUpdateHost->setAttribute("enabled", updateHost.fEnabled);
     2604    pelmUpdateHost->setAttribute("channel", (int32_t)updateHost.enmChannel);
     2605    pelmUpdateHost->setAttribute("checkFrequency", updateHost.uCheckFreqSeconds);
     2606    if (updateHost.strRepoUrl.length())
     2607        pelmUpdateHost->setAttribute("repoUrl", updateHost.strRepoUrl);
     2608    pelmUpdateHost->setAttribute("proxyMode", (int32_t)updateHost.enmProxyMode);
     2609    if (updateHost.strProxyUrl.length())
     2610        pelmUpdateHost->setAttribute("proxyUrl", updateHost.strProxyUrl);
     2611    if (updateHost.strLastCheckDate.length())
     2612        pelmUpdateHost->setAttribute("lastCheckDate", updateHost.strLastCheckDate);
     2613    pelmUpdateHost->setAttribute("checkCount", updateHost.uCheckCount);
     2614    /** @todo Add update settings for ExtPack and Guest Additions here later. See @bugref{7983}. */
     2615#endif
    25632616
    25642617    xml::ElementNode *pelmSysProps = pelmGlobal->createChild("SystemProperties");
     
    25842637    pelmSysProps->setAttribute("proxyMode", systemProperties.uProxyMode);
    25852638    pelmSysProps->setAttribute("exclusiveHwVirt", systemProperties.fExclusiveHwVirt);
    2586     pelmSysProps->setAttribute("updateEnabled", systemProperties.fVBoxUpdateEnabled);
    2587     pelmSysProps->setAttribute("updateCount", systemProperties.uVBoxUpdateCount);
    2588     pelmSysProps->setAttribute("updateFrequency", systemProperties.uVBoxUpdateFrequency);
    2589     pelmSysProps->setAttribute("updateTarget", systemProperties.uVBoxUpdateTarget);
    2590     if (systemProperties.strVBoxUpdateLastCheckDate.length())
    2591         pelmSysProps->setAttribute("updateLastCheckDate", systemProperties.strVBoxUpdateLastCheckDate);
    25922639    if (systemProperties.strLanguageId.isNotEmpty())
    25932640        pelmSysProps->setAttribute("LanguageId", systemProperties.strLanguageId);
Note: See TracChangeset for help on using the changeset viewer.

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