Changeset 90586 in vbox
- Timestamp:
- Aug 10, 2021 9:37:06 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r90579 r90586 940 940 src/networking/UINetworkRequest.h \ 941 941 src/networking/UINetworkReply.h \ 942 src/networking/UINewVersionChecker.h \ 942 943 src/networking/UIUpdateManager.h \ 943 944 src/settings/editors/UIUpdateSettingsEditor.h \ … … 1493 1494 src/networking/UINetworkReply.cpp \ 1494 1495 src/networking/UIUpdateDefs.cpp \ 1496 src/networking/UINewVersionChecker.cpp \ 1495 1497 src/networking/UIUpdateManager.cpp \ 1496 1498 src/settings/editors/UIUpdateSettingsEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UINewVersionChecker.cpp
r90579 r90586 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI UpdateManager class implementation.3 * VBox Qt GUI - UINewVersionChecker class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* Qt includes: */ 19 #include <QDir>20 #include <QPointer>21 #include <QTimer>22 #include <QUrl>23 19 #include <QUrlQuery> 24 20 25 21 /* GUI includes: */ 26 #include "QIProcess.h"27 22 #include "UICommon.h" 28 #include "VBoxUtils.h"29 #include "UIExecutionQueue.h"30 23 #include "UIExtraDataManager.h" 31 24 #include "UIMessageCenter.h" 32 #include "UIModalWindowManager.h" 33 #include "UINetworkRequestManager.h" 34 #include "UINetworkCustomer.h" 35 #include "UINetworkRequest.h" 36 #include "UINotificationCenter.h" 25 #include "UINetworkReply.h" 26 #include "UINewVersionChecker.h" 37 27 #include "UIUpdateDefs.h" 38 #include "UIUpdateManager.h" 39 40 /* COM includes: */ 41 #include "CExtPack.h" 42 #include "CExtPackManager.h" 43 #include "CSystemProperties.h" 28 #ifdef Q_OS_LINUX 29 # include "QIProcess.h" 30 #endif 44 31 45 32 /* Other VBox includes: */ 46 #include <iprt/path.h>47 33 #include <iprt/system.h> 48 #include <VBox/version.h> 34 #ifdef Q_OS_LINUX 35 # include <iprt/path.h> 36 #endif 49 37 50 /* enable to test the version update check */51 //#define VBOX_NEW_VERSION_TEST "5.1.12_0 http://unknown.unknown.org/0.0.0/VirtualBox-0.0.0-0-unknown.pkg"52 53 54 /** UINetworkCustomer extension for new version check. */55 class UINewVersionChecker : public UINetworkCustomer56 {57 Q_OBJECT;58 59 signals:60 61 /** Notifies about new version check complete. */62 void sigNewVersionChecked();63 64 public:65 66 /** Constructs new version checker.67 * @param fForceCall Brings whether this customer has forced privelegies. */68 UINewVersionChecker(bool fForceCall);69 70 /** Starts new version check. */71 void start();72 73 protected:74 75 /** Handles network reply progress for @a iReceived amount of bytes among @a iTotal. */76 virtual void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal);77 /** Handles network reply failed with specified @a strError. */78 virtual void processNetworkReplyFailed(const QString &strError);79 /** Handles network reply canceling for a passed @a pReply. */80 virtual void processNetworkReplyCanceled(UINetworkReply *pReply);81 /** Handles network reply finishing for a passed @a pReply. */82 virtual void processNetworkReplyFinished(UINetworkReply *pReply);83 84 private:85 86 /** Returns whether this customer has forced privelegies. */87 bool isItForceCall() const { return m_fForceCall; }88 89 /** Generates platform information. */90 static QString platformInfo();91 92 /** Holds whether this customer has forced privelegies. */93 bool m_fForceCall;94 /** Holds the new version checker URL. */95 QUrl m_url;96 };97 98 99 /** UIExecutionStep extension to check for the new VirtualBox version. */100 class UIUpdateStepVirtualBox : public UIExecutionStep101 {102 Q_OBJECT;103 104 public:105 106 /** Constructs extension step. */107 UIUpdateStepVirtualBox(bool fForceCall);108 /** Destructs extension step. */109 virtual ~UIUpdateStepVirtualBox() /* override final */;110 111 /** Executes the step. */112 virtual void exec() /* override */;113 114 private:115 116 /** Holds the new version checker instance. */117 UINewVersionChecker *m_pNewVersionChecker;118 };119 120 121 /** UIExecutionStep extension to check for the new VirtualBox Extension Pack version. */122 class UIUpdateStepVirtualBoxExtensionPack : public UIExecutionStep123 {124 Q_OBJECT;125 126 public:127 128 /** Constructs extension step. */129 UIUpdateStepVirtualBoxExtensionPack();130 131 /** Executes the step. */132 virtual void exec() /* override */;133 134 private slots:135 136 /** Handles downloaded Extension Pack.137 * @param strSource Brings the EP source.138 * @param strTarget Brings the EP target.139 * @param strDigest Brings the EP digest. */140 void sltHandleDownloadedExtensionPack(const QString &strSource,141 const QString &strTarget,142 const QString &strDigest);143 };144 145 146 /*********************************************************************************************************************************147 * Class UINewVersionChecker implementation. *148 *********************************************************************************************************************************/149 38 150 39 UINewVersionChecker::UINewVersionChecker(bool fForceCall) … … 301 190 return strPlatform; 302 191 } 303 304 305 /*********************************************************************************************************************************306 * Class UIUpdateStepVirtualBox implementation. *307 *********************************************************************************************************************************/308 309 UIUpdateStepVirtualBox::UIUpdateStepVirtualBox(bool fForceCall)310 : m_pNewVersionChecker(0)311 {312 m_pNewVersionChecker = new UINewVersionChecker(fForceCall);313 if (m_pNewVersionChecker)314 connect(m_pNewVersionChecker, &UINewVersionChecker::sigNewVersionChecked,315 this, &UIUpdateStepVirtualBox::sigStepFinished);316 }317 318 UIUpdateStepVirtualBox::~UIUpdateStepVirtualBox()319 {320 delete m_pNewVersionChecker;321 m_pNewVersionChecker = 0;322 }323 324 void UIUpdateStepVirtualBox::exec()325 {326 m_pNewVersionChecker->start();327 }328 329 330 /*********************************************************************************************************************************331 * Class UIUpdateStepVirtualBoxExtensionPack implementation. *332 *********************************************************************************************************************************/333 334 UIUpdateStepVirtualBoxExtensionPack::UIUpdateStepVirtualBoxExtensionPack()335 {336 }337 338 void UIUpdateStepVirtualBoxExtensionPack::exec()339 {340 /* Return if VirtualBox Manager issued a direct request to install EP: */341 if (gUpdateManager->isEPInstallationRequested())342 {343 emit sigStepFinished();344 return;345 }346 347 /* Return if already downloading: */348 if (UINotificationDownloaderExtensionPack::exists())349 {350 emit sigStepFinished();351 return;352 }353 354 /* Get extension pack manager: */355 CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager();356 /* Return if extension pack manager is NOT available: */357 if (extPackManager.isNull())358 {359 emit sigStepFinished();360 return;361 }362 363 /* Get extension pack: */364 CExtPack extPack = extPackManager.Find(GUI_ExtPackName);365 /* Return if extension pack is NOT installed: */366 if (extPack.isNull())367 {368 emit sigStepFinished();369 return;370 }371 372 /* Get VirtualBox version: */373 UIVersion vboxVersion(uiCommon().vboxVersionStringNormalized());374 /* Get extension pack version: */375 QString strExtPackVersion(extPack.GetVersion());376 377 /* If this version being developed: */378 if (vboxVersion.z() % 2 == 1)379 {380 /* If this version being developed on release branch (we use released one): */381 if (vboxVersion.z() < 97)382 vboxVersion.setZ(vboxVersion.z() - 1);383 /* If this version being developed on trunk (we skip check at all): */384 else385 {386 emit sigStepFinished();387 return;388 }389 }390 391 /* Get updated VirtualBox version: */392 const QString strVBoxVersion = vboxVersion.toString();393 394 /* Skip the check if the extension pack is equal to or newer than VBox. */395 if (UIVersion(strExtPackVersion) >= vboxVersion)396 {397 emit sigStepFinished();398 return;399 }400 401 QString strExtPackEdition(extPack.GetEdition());402 if (strExtPackEdition.contains("ENTERPRISE"))403 {404 /* Inform the user that he should update the extension pack: */405 msgCenter().askUserToDownloadExtensionPack(GUI_ExtPackName, strExtPackVersion, strVBoxVersion);406 /* Never try to download for ENTERPRISE version: */407 emit sigStepFinished();408 return;409 }410 411 /* Ask the user about extension pack downloading: */412 if (!msgCenter().warnAboutOutdatedExtensionPack(GUI_ExtPackName, strExtPackVersion))413 {414 emit sigStepFinished();415 return;416 }417 418 /* Download extension pack: */419 UINotificationDownloaderExtensionPack *pNotification = UINotificationDownloaderExtensionPack::instance(GUI_ExtPackName);420 /* After downloading finished => propose to install the Extension Pack: */421 connect(pNotification, &UINotificationDownloaderExtensionPack::sigExtensionPackDownloaded,422 this, &UIUpdateStepVirtualBoxExtensionPack::sltHandleDownloadedExtensionPack);423 /* Also, destroyed downloader is a signal to finish the step: */424 connect(pNotification, &UINotificationDownloaderExtensionPack::sigDownloaderDestroyed,425 this, &UIUpdateStepVirtualBoxExtensionPack::sigStepFinished);426 /* Append and start notification: */427 gpNotificationCenter->append(pNotification);428 }429 430 void UIUpdateStepVirtualBoxExtensionPack::sltHandleDownloadedExtensionPack(const QString &strSource,431 const QString &strTarget,432 const QString &strDigest)433 {434 /* Warn the user about extension pack was downloaded and saved, propose to install it: */435 if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))436 uiCommon().doExtPackInstallation(strTarget, strDigest, windowManager().mainWindowShown(), NULL);437 /* Propose to delete the downloaded extension pack: */438 if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget)))439 {440 /* Delete the downloaded extension pack: */441 QFile::remove(QDir::toNativeSeparators(strTarget));442 /* Get the list of old extension pack files in VirtualBox homefolder: */443 const QStringList oldExtPackFiles = QDir(uiCommon().homeFolder()).entryList(QStringList("*.vbox-extpack"),444 QDir::Files);445 /* Propose to delete old extension pack files if there are any: */446 if (oldExtPackFiles.size())447 {448 if (msgCenter().proposeDeleteOldExtentionPacks(oldExtPackFiles))449 {450 foreach (const QString &strExtPackFile, oldExtPackFiles)451 {452 /* Delete the old extension pack file: */453 QFile::remove(QDir::toNativeSeparators(QDir(uiCommon().homeFolder()).filePath(strExtPackFile)));454 }455 }456 }457 }458 }459 460 461 /*********************************************************************************************************************************462 * Class UIUpdateManager implementation. *463 *********************************************************************************************************************************/464 465 /* static */466 UIUpdateManager* UIUpdateManager::s_pInstance = 0;467 468 UIUpdateManager::UIUpdateManager()469 : m_pQueue(new UIExecutionQueue(this))470 , m_fIsRunning(false)471 , m_uTime(1 /* day */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ * 1000 /* ms */)472 , m_fEPInstallationRequested(false)473 {474 /* Prepare instance: */475 if (s_pInstance != this)476 s_pInstance = this;477 478 /* Configure queue: */479 connect(m_pQueue, &UIExecutionQueue::sigQueueFinished, this, &UIUpdateManager::sltHandleUpdateFinishing);480 481 #ifdef VBOX_WITH_UPDATE_REQUEST482 /* Ask updater to check for the first time, for Selector UI only: */483 if (gEDataManager->applicationUpdateEnabled() && uiCommon().uiType() == UICommon::UIType_SelectorUI)484 QTimer::singleShot(0, this, SLOT(sltCheckIfUpdateIsNecessary()));485 #endif /* VBOX_WITH_UPDATE_REQUEST */486 }487 488 UIUpdateManager::~UIUpdateManager()489 {490 /* Cleanup instance: */491 if (s_pInstance == this)492 s_pInstance = 0;493 }494 495 /* static */496 void UIUpdateManager::schedule()497 {498 /* Ensure instance is NOT created: */499 if (s_pInstance)500 return;501 502 /* Create instance: */503 new UIUpdateManager;504 }505 506 /* static */507 void UIUpdateManager::shutdown()508 {509 /* Ensure instance is created: */510 if (!s_pInstance)511 return;512 513 /* Delete instance: */514 delete s_pInstance;515 }516 517 void UIUpdateManager::sltForceCheck()518 {519 /* Force call for new version check: */520 sltCheckIfUpdateIsNecessary(true /* force call */);521 }522 523 void UIUpdateManager::sltCheckIfUpdateIsNecessary(bool fForceCall /* = false */)524 {525 /* If already running: */526 if (m_fIsRunning)527 {528 /* And we have a force-call: */529 if (fForceCall)530 {531 /// @todo show notification-center532 }533 return;534 }535 536 /* Set as running: */537 m_fIsRunning = true;538 539 /* Load/decode curent update data: */540 VBoxUpdateData currentData(gEDataManager->applicationUpdateData());541 542 /* If update is really necessary: */543 if (544 #ifdef VBOX_NEW_VERSION_TEST545 true ||546 #endif547 fForceCall || currentData.isNeedToCheck())548 {549 /* Prepare update queue: */550 m_pQueue->enqueue(new UIUpdateStepVirtualBox(fForceCall));551 m_pQueue->enqueue(new UIUpdateStepVirtualBoxExtensionPack);552 /* Start update queue: */553 m_pQueue->start();554 }555 else556 sltHandleUpdateFinishing();557 }558 559 void UIUpdateManager::sltHandleUpdateFinishing()560 {561 /* Load/decode curent update data: */562 VBoxUpdateData currentData(gEDataManager->applicationUpdateData());563 /* Encode/save new update data: */564 VBoxUpdateData newData(currentData.periodIndex(), currentData.branchIndex());565 gEDataManager->setApplicationUpdateData(newData.data());566 567 #ifdef VBOX_WITH_UPDATE_REQUEST568 /* Ask updater to check for the next time: */569 QTimer::singleShot(m_uTime, this, SLOT(sltCheckIfUpdateIsNecessary()));570 #endif /* VBOX_WITH_UPDATE_REQUEST */571 572 /* Set as not running: */573 m_fIsRunning = false;574 }575 576 #include "UIUpdateManager.moc"577 -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UINewVersionChecker.h
r90579 r90586 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI UpdateManager class declaration.3 * VBox Qt GUI - UINewVersionChecker class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_networking_UI UpdateManager_h19 #define FEQT_INCLUDED_SRC_networking_UI UpdateManager_h18 #ifndef FEQT_INCLUDED_SRC_networking_UINewVersionChecker_h 19 #define FEQT_INCLUDED_SRC_networking_UINewVersionChecker_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once 22 22 #endif 23 23 24 /* Qt includes: */25 #include <QObject>26 27 24 /* GUI includes: */ 28 25 #include "UILibraryDefs.h" 26 #include "UINetworkCustomer.h" 29 27 30 /* Forward declarations: */ 31 class UIExecutionQueue; 32 33 /** Singleton to perform new version checks 34 * and update of various VirtualBox parts. */ 35 class SHARED_LIBRARY_STUFF UIUpdateManager : public QObject 28 /** UINetworkCustomer extension for new version check. */ 29 class SHARED_LIBRARY_STUFF UINewVersionChecker : public UINetworkCustomer 36 30 { 37 31 Q_OBJECT; 38 32 39 /** Constructs Update Manager. */ 40 UIUpdateManager(); 41 /** Destructs Update Manager. */42 ~UIUpdateManager();33 signals: 34 35 /** Notifies about new version check complete. */ 36 void sigNewVersionChecked(); 43 37 44 38 public: 45 39 46 /** Schedules manager. */ 47 static void schedule(); 48 /** Shutdowns manager. */ 49 static void shutdown(); 50 /** Returns manager instance. */ 51 static UIUpdateManager *instance() { return s_pInstance; } 40 /** Constructs new version checker. 41 * @param fForceCall Brings whether this customer has forced privelegies. */ 42 UINewVersionChecker(bool fForceCall); 52 43 53 /** Returns whether the Extension Pack installation is requested. */ 54 bool isEPInstallationRequested() const { return m_fEPInstallationRequested; } 55 /** Defines whether the Extension Pack installation is @a fRequested. */ 56 void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; } 44 /** Starts new version check. */ 45 void start(); 57 46 58 p ublic slots:47 protected: 59 48 60 /** Performs forced new version check. */ 61 void sltForceCheck(); 62 63 private slots: 64 65 /** Checks whether update is necessary. */ 66 void sltCheckIfUpdateIsNecessary(bool fForceCall = false); 67 68 /** Handles update finishing. */ 69 void sltHandleUpdateFinishing(); 49 /** Handles network reply progress for @a iReceived amount of bytes among @a iTotal. */ 50 virtual void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal); 51 /** Handles network reply failed with specified @a strError. */ 52 virtual void processNetworkReplyFailed(const QString &strError); 53 /** Handles network reply canceling for a passed @a pReply. */ 54 virtual void processNetworkReplyCanceled(UINetworkReply *pReply); 55 /** Handles network reply finishing for a passed @a pReply. */ 56 virtual void processNetworkReplyFinished(UINetworkReply *pReply); 70 57 71 58 private: 72 59 73 /** Holds the singleton instance. */74 static UIUpdateManager *s_pInstance;60 /** Returns whether this customer has forced privelegies. */ 61 bool isItForceCall() const { return m_fForceCall; } 75 62 76 /** Holds the execution queue instance. */ 77 UIExecutionQueue *m_pQueue; 78 /** Holds whether Update Manager is running. */ 79 bool m_fIsRunning; 80 /** Holds the refresh period. */ 81 quint64 m_uTime; 63 /** Generates platform information. */ 64 static QString platformInfo(); 82 65 83 /** Holds whether the Extension Pack installation is requested. */ 84 bool m_fEPInstallationRequested; 66 /** Holds whether this customer has forced privelegies. */ 67 bool m_fForceCall; 68 /** Holds the new version checker URL. */ 69 QUrl m_url; 85 70 }; 86 71 87 /** Singleton Update Manager 'official' name. */ 88 #define gUpdateManager UIUpdateManager::instance() 89 90 #endif /* !FEQT_INCLUDED_SRC_networking_UIUpdateManager_h */ 91 72 #endif /* !FEQT_INCLUDED_SRC_networking_UINewVersionChecker_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp
r90579 r90586 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 /* Qt includes: */ 19 19 #include <QDir> 20 #include <QPointer>21 20 #include <QTimer> 22 #include <QUrl>23 #include <QUrlQuery>24 21 25 22 /* GUI includes: */ 26 #include "QIProcess.h"27 23 #include "UICommon.h" 28 #include "VBoxUtils.h"29 24 #include "UIExecutionQueue.h" 30 25 #include "UIExtraDataManager.h" 31 26 #include "UIMessageCenter.h" 32 27 #include "UIModalWindowManager.h" 33 #include "UINetworkRequestManager.h" 34 #include "UINetworkCustomer.h" 35 #include "UINetworkRequest.h" 28 #include "UINewVersionChecker.h" 36 29 #include "UINotificationCenter.h" 37 30 #include "UIUpdateDefs.h" … … 41 34 #include "CExtPack.h" 42 35 #include "CExtPackManager.h" 43 #include "CSystemProperties.h"44 45 /* Other VBox includes: */46 #include <iprt/path.h>47 #include <iprt/system.h>48 #include <VBox/version.h>49 50 /* enable to test the version update check */51 //#define VBOX_NEW_VERSION_TEST "5.1.12_0 http://unknown.unknown.org/0.0.0/VirtualBox-0.0.0-0-unknown.pkg"52 53 54 /** UINetworkCustomer extension for new version check. */55 class UINewVersionChecker : public UINetworkCustomer56 {57 Q_OBJECT;58 59 signals:60 61 /** Notifies about new version check complete. */62 void sigNewVersionChecked();63 64 public:65 66 /** Constructs new version checker.67 * @param fForceCall Brings whether this customer has forced privelegies. */68 UINewVersionChecker(bool fForceCall);69 70 /** Starts new version check. */71 void start();72 73 protected:74 75 /** Handles network reply progress for @a iReceived amount of bytes among @a iTotal. */76 virtual void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal);77 /** Handles network reply failed with specified @a strError. */78 virtual void processNetworkReplyFailed(const QString &strError);79 /** Handles network reply canceling for a passed @a pReply. */80 virtual void processNetworkReplyCanceled(UINetworkReply *pReply);81 /** Handles network reply finishing for a passed @a pReply. */82 virtual void processNetworkReplyFinished(UINetworkReply *pReply);83 84 private:85 86 /** Returns whether this customer has forced privelegies. */87 bool isItForceCall() const { return m_fForceCall; }88 89 /** Generates platform information. */90 static QString platformInfo();91 92 /** Holds whether this customer has forced privelegies. */93 bool m_fForceCall;94 /** Holds the new version checker URL. */95 QUrl m_url;96 };97 36 98 37 … … 142 81 const QString &strDigest); 143 82 }; 144 145 146 /*********************************************************************************************************************************147 * Class UINewVersionChecker implementation. *148 *********************************************************************************************************************************/149 150 UINewVersionChecker::UINewVersionChecker(bool fForceCall)151 : m_fForceCall(fForceCall)152 , m_url("https://update.virtualbox.org/query.php")153 {154 }155 156 void UINewVersionChecker::start()157 {158 /* Compose query: */159 QUrlQuery url;160 url.addQueryItem("platform", uiCommon().virtualBox().GetPackageType());161 /* Check if branding is active: */162 if (uiCommon().brandingIsActive())163 {164 /* Branding: Check whether we have a local branding file which tells us our version suffix "FOO"165 (e.g. 3.06.54321_FOO) to identify this installation: */166 url.addQueryItem("version", QString("%1_%2_%3").arg(uiCommon().virtualBox().GetVersion())167 .arg(uiCommon().virtualBox().GetRevision())168 .arg(uiCommon().brandingGetKey("VerSuffix")));169 }170 else171 {172 /* Use hard coded version set by VBOX_VERSION_STRING: */173 url.addQueryItem("version", QString("%1_%2").arg(uiCommon().virtualBox().GetVersion())174 .arg(uiCommon().virtualBox().GetRevision()));175 }176 url.addQueryItem("count", QString::number(gEDataManager->applicationUpdateCheckCounter()));177 url.addQueryItem("branch", VBoxUpdateData(gEDataManager->applicationUpdateData()).branchName());178 const QString strUserAgent(QString("VirtualBox %1 <%2>").arg(uiCommon().virtualBox().GetVersion()).arg(platformInfo()));179 180 /* Send GET request: */181 UserDictionary headers;182 headers["User-Agent"] = strUserAgent;183 QUrl fullUrl(m_url);184 fullUrl.setQuery(url);185 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, QString(), headers);186 }187 188 void UINewVersionChecker::processNetworkReplyProgress(qint64, qint64)189 {190 }191 192 void UINewVersionChecker::processNetworkReplyFailed(const QString &)193 {194 emit sigNewVersionChecked();195 }196 197 void UINewVersionChecker::processNetworkReplyCanceled(UINetworkReply *)198 {199 emit sigNewVersionChecked();200 }201 202 void UINewVersionChecker::processNetworkReplyFinished(UINetworkReply *pReply)203 {204 /* Deserialize incoming data: */205 const QString strResponseData(pReply->readAll());206 207 #ifdef VBOX_NEW_VERSION_TEST208 strResponseData = VBOX_NEW_VERSION_TEST;209 #endif210 /* Newer version of necessary package found: */211 if (strResponseData.indexOf(QRegExp("^\\d+\\.\\d+\\.\\d+(_[0-9A-Z]+)? \\S+$")) == 0)212 {213 const QStringList response = strResponseData.split(" ", QString::SkipEmptyParts);214 msgCenter().showUpdateSuccess(response[0], response[1]);215 }216 /* No newer version of necessary package found: */217 else218 {219 if (isItForceCall())220 msgCenter().showUpdateNotFound();221 }222 223 /* Increment update check counter: */224 gEDataManager->incrementApplicationUpdateCheckCounter();225 226 /* Notify about completion: */227 emit sigNewVersionChecked();228 }229 230 /* static */231 QString UINewVersionChecker::platformInfo()232 {233 /* Prepare platform report: */234 QString strPlatform;235 236 #if defined (Q_OS_WIN)237 strPlatform = "win";238 #elif defined (Q_OS_LINUX)239 strPlatform = "linux";240 #elif defined (Q_OS_MACX)241 strPlatform = "macosx";242 #elif defined (Q_OS_OS2)243 strPlatform = "os2";244 #elif defined (Q_OS_FREEBSD)245 strPlatform = "freebsd";246 #elif defined (Q_OS_SOLARIS)247 strPlatform = "solaris";248 #else249 strPlatform = "unknown";250 #endif251 252 /* The format is <system>.<bitness>: */253 strPlatform += QString(".%1").arg(ARCH_BITS);254 255 /* Add more system information: */256 int vrc;257 #ifdef Q_OS_LINUX258 // WORKAROUND:259 // On Linux we try to generate information using script first of all..260 261 /* Get script path: */262 char szAppPrivPath[RTPATH_MAX];263 vrc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath));264 AssertRC(vrc);265 if (RT_SUCCESS(vrc))266 {267 /* Run script: */268 QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh");269 if (!result.isNull())270 strPlatform += QString(" [%1]").arg(QString(result).trimmed());271 else272 vrc = VERR_TRY_AGAIN; /* (take the fallback path) */273 }274 if (RT_FAILURE(vrc))275 #endif /* Q_OS_LINUX */276 {277 /* Use RTSystemQueryOSInfo: */278 char szTmp[256];279 QStringList components;280 281 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));282 if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')283 components << QString("Product: %1").arg(szTmp);284 285 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));286 if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')287 components << QString("Release: %1").arg(szTmp);288 289 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));290 if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')291 components << QString("Version: %1").arg(szTmp);292 293 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp));294 if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')295 components << QString("SP: %1").arg(szTmp);296 297 if (!components.isEmpty())298 strPlatform += QString(" [%1]").arg(components.join(" | "));299 }300 301 return strPlatform;302 }303 83 304 84 … … 574 354 } 575 355 356 576 357 #include "UIUpdateManager.moc" 577 -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.h
r90579 r90586 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 89 89 90 90 #endif /* !FEQT_INCLUDED_SRC_networking_UIUpdateManager_h */ 91
Note:
See TracChangeset
for help on using the changeset viewer.