Index: trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp	(revision 71439)
+++ trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp	(revision 71447)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2017 Oracle Corporation
+ * Copyright (C) 2006-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -21,24 +21,24 @@
 
 /* Qt includes: */
-# include <QTimer>
 # include <QDir>
 # include <QPointer>
+# include <QTimer>
 # include <QUrl>
 # include <QUrlQuery>
 
 /* GUI includes: */
-# include "UIUpdateDefs.h"
-# include "UIUpdateManager.h"
+# include "QIProcess.h"
+# include "VBoxGlobal.h"
+# include "VBoxUtils.h"
+# include "UIDownloaderExtensionPack.h"
+# include "UIExtraDataManager.h"
+# include "UIGlobalSettingsExtension.h"
+# include "UIMessageCenter.h"
+# include "UIModalWindowManager.h"
 # include "UINetworkManager.h"
 # include "UINetworkCustomer.h"
 # include "UINetworkRequest.h"
-# include "VBoxGlobal.h"
-# include "UIMessageCenter.h"
-# include "UIExtraDataManager.h"
-# include "UIModalWindowManager.h"
-# include "VBoxUtils.h"
-# include "UIDownloaderExtensionPack.h"
-# include "UIGlobalSettingsExtension.h"
-# include "QIProcess.h"
+# include "UIUpdateDefs.h"
+# include "UIUpdateManager.h"
 
 /* COM includes: */
@@ -53,5 +53,4 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
-
 /* enable to test the version update check */
 //#define VBOX_NEW_VERSION_TEST "5.1.12_0 http://unknown.unknown.org/0.0.0/VirtualBox-0.0.0-0-unknown.pkg"
@@ -60,5 +59,7 @@
 class UIUpdateStep;
 
-/* Queue for processing update-steps: */
+
+/** QObject subclass providing GUI with
+  * an object to manage queue of update-steps. */
 class UIUpdateQueue : public QObject
 {
@@ -67,33 +68,38 @@
 signals:
 
-    /* Starting-signal of the queue: */
+    /** Starts the queue. */
     void sigStartQueue();
 
-    /* Completion-signal of the queue: */
+    /** Notifies about queue is finished. */
     void sigQueueFinished();
 
 public:
 
-    /* Constructor: */
+    /** Constructs update queue passing @a pParent to the base-class. */
     UIUpdateQueue(UIUpdateManager *pParent) : QObject(pParent) {}
 
-    /* Starts a queue: */
+    /** Starts the queue. */
     void start() { emit sigStartQueue(); }
 
 private:
 
-    /* Helpers: */
+    /** Returns whether queue is empty. */
     bool isEmpty() const { return m_pLastStep.isNull(); }
-    UIUpdateStep* lastStep() const { return m_pLastStep; }
+
+    /** Defines the last queued @a pStep. */
     void setLastStep(UIUpdateStep *pStep) { m_pLastStep = pStep; }
-
-    /* Variables: */
+    /** Returns the last queued step. */
+    UIUpdateStep *lastStep() const { return m_pLastStep; }
+
+    /** Holds the last queued step reference. */
     QPointer<UIUpdateStep> m_pLastStep;
 
-    /* Friend classes: */
+    /** Allows step to manage queue. */
     friend class UIUpdateStep;
 };
 
-/* Interface representing update-step: */
+
+/** Update step interface.
+  * UINetworkCustomer extension which allows background network updates. */
 class UIUpdateStep : public UINetworkCustomer
 {
@@ -102,51 +108,29 @@
 signals:
 
-    /* Completion-signal of the step: */
+    /** Notifies about step is finished. */
     void sigStepComplete();
 
 public:
 
-    /* Constructor: */
-    UIUpdateStep(UIUpdateQueue *pQueue, bool fForceCall) : UINetworkCustomer(pQueue, fForceCall)
-    {
-        /* If queue has no steps yet: */
-        if (pQueue->isEmpty())
-        {
-            /* Connect starting-signal of the queue to starting-slot of this step: */
-            connect(pQueue, &UIUpdateQueue::sigStartQueue, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection);
-        }
-        /* If queue has at least one step already: */
-        else
-        {
-            /* Reconnect completion-signal of the last-step from completion-signal of the queue to starting-slot of this step: */
-            disconnect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished);
-            connect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection);
-        }
-
-        /* Connect completion-signal of this step to the completion-signal of the queue: */
-        connect(this, &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished, Qt::QueuedConnection);
-        /* Connect completion-signal of this step to the destruction-slot of this step: */
-        connect(this, &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::deleteLater, Qt::QueuedConnection);
-
-        /* Remember this step as the last one: */
-        pQueue->setLastStep(this);
-    }
+    /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */
+    UIUpdateStep(UIUpdateQueue *pQueue, bool fForceCall);
+
+protected:
+
+    /** Handles network reply progress for @a iReceived amount of bytes among @a iTotal. */
+    virtual void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal) /* override */;
+    /** Handles network reply canceling for a passed @a pReply. */
+    virtual void processNetworkReplyCanceled(UINetworkReply *pReply) /* override */;
+    /** Handles network reply finishing for a passed @a pReply. */
+    virtual void processNetworkReplyFinished(UINetworkReply *pReply) /* override */;
 
 protected slots:
 
-    /* Starting-slot of the step: */
+    /** Starts the step. */
     virtual void sltStartStep() = 0;
-
-protected:
-
-    /* Network pregress handler dummy: */
-    void processNetworkReplyProgress(qint64, qint64) {}
-    /* Network reply canceled handler dummy: */
-    void processNetworkReplyCanceled(UINetworkReply*) {}
-    /* Network reply canceled handler dummy: */
-    void processNetworkReplyFinished(UINetworkReply*) {}
 };
 
-/* Update-step to check for the new VirtualBox version: */
+
+/** Update step subclass to check for the new VirtualBox version. */
 class UIUpdateStepVirtualBox : public UIUpdateStep
 {
@@ -155,174 +139,36 @@
 public:
 
-    /* Constructor: */
+    /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */
     UIUpdateStepVirtualBox(UIUpdateQueue *pQueue, bool fForceCall)
         : UIUpdateStep(pQueue, fForceCall)
         , m_url("https://update.virtualbox.org/query.php")
-    {
-    }
-
-private slots:
-
-    /* Startup slot: */
-    void sltStartStep() { prepareNetworkRequest(); }
+    {}
+
+protected:
+
+    /** Handles network reply canceling for a passed @a pReply. */
+    virtual void processNetworkReplyCanceled(UINetworkReply *pReply) /* override */;
+    /** Handles network reply finishing for a passed @a pReply. */
+    virtual void processNetworkReplyFinished(UINetworkReply *pReply) /* override */;
+
+    /** Returns description of the current network operation. */
+    virtual const QString description() const /* override */;
+
+protected slots:
+
+    /** Starts the step. */
+    virtual void sltStartStep() /* override */;
 
 private:
 
-    /** Returns description of the current network operation. */
-    virtual const QString description() const
-    {
-        return tr("Checking for a new VirtualBox version...");
-    }
-
-    /* Prepare network request: */
-    void prepareNetworkRequest()
-    {
-        /* Compose query: */
-        QUrlQuery url;
-        url.addQueryItem("platform", vboxGlobal().virtualBox().GetPackageType());
-        /* Check if branding is active: */
-        if (vboxGlobal().brandingIsActive())
-        {
-            /* Branding: Check whether we have a local branding file which tells us our version suffix "FOO"
-                         (e.g. 3.06.54321_FOO) to identify this installation: */
-            url.addQueryItem("version", QString("%1_%2_%3").arg(vboxGlobal().virtualBox().GetVersion())
-                                                           .arg(vboxGlobal().virtualBox().GetRevision())
-                                                           .arg(vboxGlobal().brandingGetKey("VerSuffix")));
-        }
-        else
-        {
-            /* Use hard coded version set by VBOX_VERSION_STRING: */
-            url.addQueryItem("version", QString("%1_%2").arg(vboxGlobal().virtualBox().GetVersion())
-                                                        .arg(vboxGlobal().virtualBox().GetRevision()));
-        }
-        url.addQueryItem("count", QString::number(gEDataManager->applicationUpdateCheckCounter()));
-        url.addQueryItem("branch", VBoxUpdateData(gEDataManager->applicationUpdateData()).branchName());
-        QString strUserAgent(QString("VirtualBox %1 <%2>").arg(vboxGlobal().virtualBox().GetVersion()).arg(platformInfo()));
-
-        /* Send GET request: */
-        UserDictionary headers;
-        headers["User-Agent"] = strUserAgent;
-        QUrl fullUrl(m_url);
-        fullUrl.setQuery(url);
-        createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, headers);
-    }
-
-    /* Handle network reply canceled: */
-    void processNetworkReplyCanceled(UINetworkReply* /* pReply */)
-    {
-        /* Notify about step completion: */
-        emit sigStepComplete();
-    }
-
-    /* Handle network reply: */
-    void processNetworkReplyFinished(UINetworkReply *pReply)
-    {
-        /* Deserialize incoming data: */
-        QString strResponseData(pReply->readAll());
-
-#ifdef VBOX_NEW_VERSION_TEST
-        strResponseData = VBOX_NEW_VERSION_TEST;
-#endif
-        /* Newer version of necessary package found: */
-        if (strResponseData.indexOf(QRegExp("^\\d+\\.\\d+\\.\\d+(_[0-9A-Z]+)? \\S+$")) == 0)
-        {
-            QStringList response = strResponseData.split(" ", QString::SkipEmptyParts);
-            msgCenter().showUpdateSuccess(response[0], response[1]);
-        }
-        /* No newer version of necessary package found: */
-        else
-        {
-            if (isItForceCall())
-                msgCenter().showUpdateNotFound();
-        }
-
-        /* Increment update check counter: */
-        gEDataManager->incrementApplicationUpdateCheckCounter();
-
-        /* Notify about step completion: */
-        emit sigStepComplete();
-    }
-
-    /* Platform information getter: */
-    static QString platformInfo()
-    {
-        /* Prepare platform report: */
-        QString strPlatform;
-
-#if defined (Q_OS_WIN)
-        strPlatform = "win";
-#elif defined (Q_OS_LINUX)
-        strPlatform = "linux";
-#elif defined (Q_OS_MACX)
-        strPlatform = "macosx";
-#elif defined (Q_OS_OS2)
-        strPlatform = "os2";
-#elif defined (Q_OS_FREEBSD)
-        strPlatform = "freebsd";
-#elif defined (Q_OS_SOLARIS)
-        strPlatform = "solaris";
-#else
-        strPlatform = "unknown";
-#endif
-
-        /* The format is <system>.<bitness>: */
-        strPlatform += QString(".%1").arg(ARCH_BITS);
-
-        /* Add more system information: */
-        int vrc;
-#if defined(Q_OS_LINUX)
-        /* On linux we wish to send information about the distribution
-           and such like, so we try invoke a helper script that retrives
-           and formats it for us. */
-
-        /* Get script path: */
-        char szAppPrivPath[RTPATH_MAX];
-        vrc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath)); AssertRC(vrc);
-        if (RT_SUCCESS(vrc))
-        {
-            /* Run script: */
-            QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh");
-            if (!result.isNull())
-                strPlatform += QString(" [%1]").arg(QString(result).trimmed());
-            else
-                vrc = VERR_TRY_AGAIN; /* (take the fallback path) */
-        }
-        if (RT_FAILURE(vrc))
-#endif
-        {
-            /* Use RTSystemQueryOSInfo: */
-            char szTmp[256];
-            QStringList components;
-
-            vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));
-            if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
-                components << QString("Product: %1").arg(szTmp);
-
-            vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));
-            if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
-                components << QString("Release: %1").arg(szTmp);
-
-            vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));
-            if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
-                components << QString("Version: %1").arg(szTmp);
-
-            vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp));
-            if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
-                components << QString("SP: %1").arg(szTmp);
-
-            if (!components.isEmpty())
-                strPlatform += QString(" [%1]").arg(components.join(" | "));
-        }
-
-        return strPlatform;
-    }
-
-private:
-
-    /* Variables: */
+    /** Generates platform information. */
+    static QString platformInfo();
+
+    /** Holds the update step URL. */
     QUrl m_url;
 };
 
-/* Update-step to check for the new VirtualBox Extension Pack version: */
+
+/** Update step subclass to check for the new VirtualBox Extension Pack version. */
 class UIUpdateStepVirtualBoxExtensionPack : public UIUpdateStep
 {
@@ -331,159 +177,348 @@
 public:
 
-    /* Constructor: */
+    /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */
     UIUpdateStepVirtualBoxExtensionPack(UIUpdateQueue *pQueue, bool fForceCall)
         : UIUpdateStep(pQueue, fForceCall)
-    {
-    }
+    {}
+
+protected slots:
+
+    /** Starts the step. */
+    virtual void sltStartStep() /* override */;
 
 private slots:
 
-    /* Startup slot: */
-    void sltStartStep()
-    {
-        /* Return if Selector UI has a direct request to install EP: */
-        if (vboxGlobal().isEPInstallationRequested())
+    /** Handles downloaded Extension Pack.
+      * @param  strSource  Brings the EP source.
+      * @param  strTarget  Brings the EP target.
+      * @param  strDigest  Brings the EP digest. */
+    void sltHandleDownloadedExtensionPack(const QString &strSource,
+                                          const QString &strTarget,
+                                          const QString &strDigest);
+};
+
+
+/*********************************************************************************************************************************
+*   Class UIUpdateStep implementation.                                                                                           *
+*********************************************************************************************************************************/
+
+UIUpdateStep::UIUpdateStep(UIUpdateQueue *pQueue, bool fForceCall)
+    : UINetworkCustomer(pQueue, fForceCall)
+{
+    /* If queue has no steps yet: */
+    if (pQueue->isEmpty())
+    {
+        /* Connect starting-signal of the queue to starting-slot of this step: */
+        connect(pQueue, &UIUpdateQueue::sigStartQueue, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection);
+    }
+    /* If queue has at least one step already: */
+    else
+    {
+        /* Reconnect completion-signal of the last-step from completion-signal of the queue to starting-slot of this step: */
+        disconnect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished);
+        connect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection);
+    }
+
+    /* Connect completion-signal of this step to the completion-signal of the queue: */
+    connect(this, &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished, Qt::QueuedConnection);
+    /* Connect completion-signal of this step to the destruction-slot of this step: */
+    connect(this, &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::deleteLater, Qt::QueuedConnection);
+
+    /* Remember this step as the last one: */
+    pQueue->setLastStep(this);
+}
+
+void UIUpdateStep::processNetworkReplyProgress(qint64, qint64)
+{
+}
+
+void UIUpdateStep::processNetworkReplyCanceled(UINetworkReply *)
+{
+}
+
+void UIUpdateStep::processNetworkReplyFinished(UINetworkReply *)
+{
+}
+
+
+/*********************************************************************************************************************************
+*   Class UIUpdateStepVirtualBox implementation.                                                                                 *
+*********************************************************************************************************************************/
+
+void UIUpdateStepVirtualBox::processNetworkReplyCanceled(UINetworkReply *pReply)
+{
+    Q_UNUSED(pReply);
+
+    /* Notify about step completion: */
+    emit sigStepComplete();
+}
+
+void UIUpdateStepVirtualBox::processNetworkReplyFinished(UINetworkReply *pReply)
+{
+    /* Deserialize incoming data: */
+    QString strResponseData(pReply->readAll());
+
+#ifdef VBOX_NEW_VERSION_TEST
+    strResponseData = VBOX_NEW_VERSION_TEST;
+#endif
+    /* Newer version of necessary package found: */
+    if (strResponseData.indexOf(QRegExp("^\\d+\\.\\d+\\.\\d+(_[0-9A-Z]+)? \\S+$")) == 0)
+    {
+        QStringList response = strResponseData.split(" ", QString::SkipEmptyParts);
+        msgCenter().showUpdateSuccess(response[0], response[1]);
+    }
+    /* No newer version of necessary package found: */
+    else
+    {
+        if (isItForceCall())
+            msgCenter().showUpdateNotFound();
+    }
+
+    /* Increment update check counter: */
+    gEDataManager->incrementApplicationUpdateCheckCounter();
+
+    /* Notify about step completion: */
+    emit sigStepComplete();
+}
+
+const QString UIUpdateStepVirtualBox::description() const
+{
+    return tr("Checking for a new VirtualBox version...");
+}
+
+void UIUpdateStepVirtualBox::sltStartStep()
+{
+    /* Compose query: */
+    QUrlQuery url;
+    url.addQueryItem("platform", vboxGlobal().virtualBox().GetPackageType());
+    /* Check if branding is active: */
+    if (vboxGlobal().brandingIsActive())
+    {
+        /* Branding: Check whether we have a local branding file which tells us our version suffix "FOO"
+                     (e.g. 3.06.54321_FOO) to identify this installation: */
+        url.addQueryItem("version", QString("%1_%2_%3").arg(vboxGlobal().virtualBox().GetVersion())
+                                                       .arg(vboxGlobal().virtualBox().GetRevision())
+                                                       .arg(vboxGlobal().brandingGetKey("VerSuffix")));
+    }
+    else
+    {
+        /* Use hard coded version set by VBOX_VERSION_STRING: */
+        url.addQueryItem("version", QString("%1_%2").arg(vboxGlobal().virtualBox().GetVersion())
+                                                    .arg(vboxGlobal().virtualBox().GetRevision()));
+    }
+    url.addQueryItem("count", QString::number(gEDataManager->applicationUpdateCheckCounter()));
+    url.addQueryItem("branch", VBoxUpdateData(gEDataManager->applicationUpdateData()).branchName());
+    QString strUserAgent(QString("VirtualBox %1 <%2>").arg(vboxGlobal().virtualBox().GetVersion()).arg(platformInfo()));
+
+    /* Send GET request: */
+    UserDictionary headers;
+    headers["User-Agent"] = strUserAgent;
+    QUrl fullUrl(m_url);
+    fullUrl.setQuery(url);
+    createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, headers);
+}
+
+/* static */
+QString UIUpdateStepVirtualBox::platformInfo()
+{
+    /* Prepare platform report: */
+    QString strPlatform;
+
+#if defined (Q_OS_WIN)
+    strPlatform = "win";
+#elif defined (Q_OS_LINUX)
+    strPlatform = "linux";
+#elif defined (Q_OS_MACX)
+    strPlatform = "macosx";
+#elif defined (Q_OS_OS2)
+    strPlatform = "os2";
+#elif defined (Q_OS_FREEBSD)
+    strPlatform = "freebsd";
+#elif defined (Q_OS_SOLARIS)
+    strPlatform = "solaris";
+#else
+    strPlatform = "unknown";
+#endif
+
+    /* The format is <system>.<bitness>: */
+    strPlatform += QString(".%1").arg(ARCH_BITS);
+
+    /* Add more system information: */
+    int vrc;
+#ifdef Q_OS_LINUX
+    // WORKAROUND:
+    // On Linux we try to generate information using script first of all..
+
+    /* Get script path: */
+    char szAppPrivPath[RTPATH_MAX];
+    vrc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath));
+    AssertRC(vrc);
+    if (RT_SUCCESS(vrc))
+    {
+        /* Run script: */
+        QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh");
+        if (!result.isNull())
+            strPlatform += QString(" [%1]").arg(QString(result).trimmed());
+        else
+            vrc = VERR_TRY_AGAIN; /* (take the fallback path) */
+    }
+    if (RT_FAILURE(vrc))
+#endif /* Q_OS_LINUX */
+    {
+        /* Use RTSystemQueryOSInfo: */
+        char szTmp[256];
+        QStringList components;
+
+        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));
+        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
+            components << QString("Product: %1").arg(szTmp);
+
+        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));
+        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
+            components << QString("Release: %1").arg(szTmp);
+
+        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));
+        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
+            components << QString("Version: %1").arg(szTmp);
+
+        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp));
+        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
+            components << QString("SP: %1").arg(szTmp);
+
+        if (!components.isEmpty())
+            strPlatform += QString(" [%1]").arg(components.join(" | "));
+    }
+
+    return strPlatform;
+}
+
+
+/*********************************************************************************************************************************
+*   Class UIUpdateStepVirtualBoxExtensionPack implementation.                                                                    *
+*********************************************************************************************************************************/
+
+void UIUpdateStepVirtualBoxExtensionPack::sltStartStep()
+{
+    /* Return if Selector UI has a direct request to install EP: */
+    if (vboxGlobal().isEPInstallationRequested())
+    {
+        emit sigStepComplete();
+        return;
+    }
+
+    /* Return if already downloading: */
+    if (UIDownloaderExtensionPack::current())
+    {
+        emit sigStepComplete();
+        return;
+    }
+
+    /* Get extension pack: */
+    CExtPack extPack = vboxGlobal().virtualBox().GetExtensionPackManager().Find(GUI_ExtPackName);
+    /* Return if extension pack is NOT installed: */
+    if (extPack.isNull())
+    {
+        emit sigStepComplete();
+        return;
+    }
+
+    /* Get VirtualBox version: */
+    UIVersion vboxVersion(vboxGlobal().vboxVersionStringNormalized());
+    /* Get extension pack version: */
+    QString strExtPackVersion(extPack.GetVersion());
+    QByteArray abExtPackVersion = strExtPackVersion.toUtf8();
+
+    /* If this version being developed: */
+    if (vboxVersion.z() % 2 == 1)
+    {
+        /* If this version being developed on release branch (we use released one): */
+        if (vboxVersion.z() < 97)
+            vboxVersion.setZ(vboxVersion.z() - 1);
+        /* If this version being developed on trunk (we skip check at all): */
+        else
         {
             emit sigStepComplete();
             return;
         }
-
-        /* Return if already downloading: */
-        if (UIDownloaderExtensionPack::current())
+    }
+
+    /* Get updated VirtualBox version: */
+    const QString strVBoxVersion = vboxVersion.toString();
+
+    /* Skip the check if the extension pack is equal to or newer than VBox.
+     * Note! Use RTStrVersionCompare for the comparison here as it takes the
+     *       beta/alpha/preview/whatever tags into consideration when comparing versions. */
+    if (RTStrVersionCompare(abExtPackVersion.constData(), strVBoxVersion.toUtf8().constData()) >= 0)
+    {
+        emit sigStepComplete();
+        return;
+    }
+
+    QString strExtPackEdition(extPack.GetEdition());
+    if (strExtPackEdition.contains("ENTERPRISE"))
+    {
+        /* Inform the user that he should update the extension pack: */
+        msgCenter().askUserToDownloadExtensionPack(GUI_ExtPackName, strExtPackVersion, strVBoxVersion);
+        /* Never try to download for ENTERPRISE version: */
+        emit sigStepComplete();
+        return;
+    }
+
+    /* Ask the user about extension pack downloading: */
+    if (!msgCenter().warAboutOutdatedExtensionPack(GUI_ExtPackName, strExtPackVersion))
+    {
+        emit sigStepComplete();
+        return;
+    }
+
+    /* Create and configure the Extension Pack downloader: */
+    UIDownloaderExtensionPack *pDl = UIDownloaderExtensionPack::create();
+    /* After downloading finished => propose to install the Extension Pack: */
+    connect(pDl, &UIDownloaderExtensionPack::sigDownloadFinished,
+            this, &UIUpdateStepVirtualBoxExtensionPack::sltHandleDownloadedExtensionPack);
+    /* Also, destroyed downloader is a signal to finish the step: */
+    connect(pDl, &UIDownloaderExtensionPack::destroyed,
+            this, &UIUpdateStepVirtualBoxExtensionPack::sigStepComplete);
+    /* Start downloading: */
+    pDl->start();
+}
+
+void UIUpdateStepVirtualBoxExtensionPack::sltHandleDownloadedExtensionPack(const QString &strSource,
+                                                                           const QString &strTarget,
+                                                                           const QString &strDigest)
+{
+    /* Warn the user about extension pack was downloaded and saved, propose to install it: */
+    if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))
+        UIGlobalSettingsExtension::doInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), 0);
+    /* Propose to delete the downloaded extension pack: */
+    if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget)))
+    {
+        /* Delete the downloaded extension pack: */
+        QFile::remove(QDir::toNativeSeparators(strTarget));
+        /* Get the list of old extension pack files in VirtualBox homefolder: */
+        const QStringList oldExtPackFiles = QDir(vboxGlobal().homeFolder()).entryList(QStringList("*.vbox-extpack"),
+                                                                                      QDir::Files);
+        /* Propose to delete old extension pack files if there are any: */
+        if (oldExtPackFiles.size())
         {
-            emit sigStepComplete();
-            return;
-        }
-
-        /* Get extension pack: */
-        CExtPack extPack = vboxGlobal().virtualBox().GetExtensionPackManager().Find(GUI_ExtPackName);
-        /* Return if extension pack is NOT installed: */
-        if (extPack.isNull())
-        {
-            emit sigStepComplete();
-            return;
-        }
-
-        /* Get VirtualBox version: */
-        UIVersion vboxVersion(vboxGlobal().vboxVersionStringNormalized());
-        /* Get extension pack version: */
-        QString strExtPackVersion(extPack.GetVersion());
-        QByteArray abExtPackVersion = strExtPackVersion.toUtf8();
-
-        /* If this version being developed: */
-        if (vboxVersion.z() % 2 == 1)
-        {
-            /* If this version being developed on release branch (we use released one): */
-            if (vboxVersion.z() < 97)
-                vboxVersion.setZ(vboxVersion.z() - 1);
-            /* If this version being developed on trunk (we skip check at all): */
-            else
+            if (msgCenter().proposeDeleteOldExtentionPacks(oldExtPackFiles))
             {
-                emit sigStepComplete();
-                return;
-            }
-        }
-
-        /* Get updated VirtualBox version: */
-        const QString strVBoxVersion = vboxVersion.toString();
-
-        /* Skip the check if the extension pack is equal to or newer than VBox.
-         * Note! Use RTStrVersionCompare for the comparison here as it takes the
-         *       beta/alpha/preview/whatever tags into consideration when comparing versions. */
-        if (RTStrVersionCompare(abExtPackVersion.constData(), strVBoxVersion.toUtf8().constData()) >= 0)
-        {
-            emit sigStepComplete();
-            return;
-        }
-
-        QString strExtPackEdition(extPack.GetEdition());
-        if (strExtPackEdition.contains("ENTERPRISE"))
-        {
-            /* Inform the user that he should update the extension pack: */
-            msgCenter().askUserToDownloadExtensionPack(GUI_ExtPackName, strExtPackVersion, strVBoxVersion);
-            /* Never try to download for ENTERPRISE version: */
-            emit sigStepComplete();
-            return;
-        }
-
-        /* Ask the user about extension pack downloading: */
-        if (!msgCenter().warAboutOutdatedExtensionPack(GUI_ExtPackName, strExtPackVersion))
-        {
-            emit sigStepComplete();
-            return;
-        }
-
-        /* Create and configure the Extension Pack downloader: */
-        UIDownloaderExtensionPack *pDl = UIDownloaderExtensionPack::create();
-        /* After downloading finished => propose to install the Extension Pack: */
-        connect(pDl, &UIDownloaderExtensionPack::sigDownloadFinished,
-                this, &UIUpdateStepVirtualBoxExtensionPack::sltHandleDownloadedExtensionPack);
-        /* Also, destroyed downloader is a signal to finish the step: */
-        connect(pDl, &UIDownloaderExtensionPack::destroyed,
-                this, &UIUpdateStepVirtualBoxExtensionPack::sigStepComplete);
-        /* Start downloading: */
-        pDl->start();
-    }
-
-    /* Finishing slot: */
-    void sltHandleDownloadedExtensionPack(const QString &strSource, const QString &strTarget, QString strDigest)
-    {
-        /* Warn the user about extension pack was downloaded and saved, propose to install it: */
-        if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))
-            UIGlobalSettingsExtension::doInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL);
-        /* Propose to delete the downloaded extension pack: */
-        if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget)))
-        {
-            /* Delete the downloaded extension pack: */
-            QFile::remove(QDir::toNativeSeparators(strTarget));
-            /* Get the list of old extension pack files in VirtualBox homefolder: */
-            const QStringList oldExtPackFiles = QDir(vboxGlobal().homeFolder()).entryList(QStringList("*.vbox-extpack"),
-                                                                                          QDir::Files);
-            /* Propose to delete old extension pack files if there are any: */
-            if (oldExtPackFiles.size())
-            {
-                if (msgCenter().proposeDeleteOldExtentionPacks(oldExtPackFiles))
+                foreach (const QString &strExtPackFile, oldExtPackFiles)
                 {
-                    foreach (const QString &strExtPackFile, oldExtPackFiles)
-                    {
-                        /* Delete the old extension pack file: */
-                        QFile::remove(QDir::toNativeSeparators(QDir(vboxGlobal().homeFolder()).filePath(strExtPackFile)));
-                    }
+                    /* Delete the old extension pack file: */
+                    QFile::remove(QDir::toNativeSeparators(QDir(vboxGlobal().homeFolder()).filePath(strExtPackFile)));
                 }
             }
         }
     }
-};
-
-/* UIUpdateManager stuff: */
-UIUpdateManager* UIUpdateManager::m_pInstance = 0;
+}
+
+
+/*********************************************************************************************************************************
+*   Class UIUpdateManager implementation.                                                                                        *
+*********************************************************************************************************************************/
 
 /* static */
-void UIUpdateManager::schedule()
-{
-    /* Ensure instance is NOT created: */
-    if (m_pInstance)
-        return;
-
-    /* Create instance: */
-    new UIUpdateManager;
-}
-
-/* static */
-void UIUpdateManager::shutdown()
-{
-    /* Ensure instance is created: */
-    if (!m_pInstance)
-        return;
-
-    /* Delete instance: */
-    delete m_pInstance;
-}
-
-void UIUpdateManager::sltForceCheck()
-{
-    /* Force call for new version check: */
-    sltCheckIfUpdateIsNecessary(true /* force call */);
-}
+UIUpdateManager* UIUpdateManager::s_pInstance = 0;
 
 UIUpdateManager::UIUpdateManager()
@@ -493,6 +528,6 @@
 {
     /* Prepare instance: */
-    if (m_pInstance != this)
-        m_pInstance = this;
+    if (s_pInstance != this)
+        s_pInstance = this;
 
     /* Configure queue: */
@@ -509,6 +544,34 @@
 {
     /* Cleanup instance: */
-    if (m_pInstance == this)
-        m_pInstance = 0;
+    if (s_pInstance == this)
+        s_pInstance = 0;
+}
+
+/* static */
+void UIUpdateManager::schedule()
+{
+    /* Ensure instance is NOT created: */
+    if (s_pInstance)
+        return;
+
+    /* Create instance: */
+    new UIUpdateManager;
+}
+
+/* static */
+void UIUpdateManager::shutdown()
+{
+    /* Ensure instance is created: */
+    if (!s_pInstance)
+        return;
+
+    /* Delete instance: */
+    delete s_pInstance;
+}
+
+void UIUpdateManager::sltForceCheck()
+{
+    /* Force call for new version check: */
+    sltCheckIfUpdateIsNecessary(true /* force call */);
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h	(revision 71439)
+++ trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h	(revision 71447)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2017 Oracle Corporation
+ * Copyright (C) 2006-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -16,8 +16,8 @@
  */
 
-#ifndef __UIUpdateManager_h__
-#define __UIUpdateManager_h__
+#ifndef ___UIUpdateManager_h___
+#define ___UIUpdateManager_h___
 
-/* Global includes: */
+/* Qt includes: */
 #include <QObject>
 
@@ -25,46 +25,53 @@
 class UIUpdateQueue;
 
-/* Singleton to perform new version checks
- * and update of various VirtualBox parts. */
+/** Singleton to perform new version checks
+  * and update of various VirtualBox parts. */
 class UIUpdateManager : public QObject
 {
     Q_OBJECT;
 
+    /** Constructs Update Manager. */
+    UIUpdateManager();
+    /** Destructs Update Manager. */
+    ~UIUpdateManager();
+
 public:
 
-    /* Schedule manager: */
+    /** Schedules manager. */
     static void schedule();
-    /* Shutdown manager: */
+    /** Shutdowns manager. */
     static void shutdown();
-    /* Manager instance: */
-    static UIUpdateManager* instance() { return m_pInstance; }
+    /** Returns manager instance. */
+    static UIUpdateManager *instance() { return s_pInstance; }
 
 public slots:
 
-    /* Force call for new version check: */
+    /** Performs forced new version check. */
     void sltForceCheck();
 
 private slots:
 
-    /* Slot to check if update is necessary: */
+    /** Checks whether update is necessary. */
     void sltCheckIfUpdateIsNecessary(bool fForceCall = false);
 
-    /* Slot to handle update finishing: */
+    /** Handles update finishing. */
     void sltHandleUpdateFinishing();
 
 private:
 
-    /* Constructor/destructor: */
-    UIUpdateManager();
-    ~UIUpdateManager();
+    /** Holds the singleton instance. */
+    static UIUpdateManager *s_pInstance;
 
-    /* Variables: */
-    static UIUpdateManager* m_pInstance;
+    /** Holds the update queue instance. */
     UIUpdateQueue *m_pQueue;
-    bool m_fIsRunning;
-    quint64 m_uTime;
+    /** Holds whether Update Manager is running. */
+    bool           m_fIsRunning;
+    /** Holds the refresh period. */
+    quint64        m_uTime;
 };
+
+/** Singleton Update Manager 'official' name. */
 #define gUpdateManager UIUpdateManager::instance()
 
-#endif // __UIUpdateManager_h__
+#endif /* !___UIUpdateManager_h___ */
 
