Changeset 90579 in vbox
- Timestamp:
- Aug 9, 2021 2:49:12 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 146185
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r90569 r90579 847 847 src/notificationcenter/UINotificationObjects.h \ 848 848 src/notificationcenter/UINotificationProgressTask.h \ 849 src/objects/UIExecutionQueue.h \ 849 850 src/settings/UISettingsDialog.h \ 850 851 src/settings/UISettingsDialogSpecific.h \ … … 1396 1397 src/notificationcenter/UINotificationObjects.cpp \ 1397 1398 src/notificationcenter/UINotificationProgressTask.cpp \ 1399 src/objects/UIExecutionQueue.cpp \ 1398 1400 src/objects/UIRichTextString.cpp \ 1399 1401 src/settings/UISettingsDefs.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkCustomer.cpp
r90547 r90579 21 21 22 22 23 UINetworkCustomer::UINetworkCustomer(QObject *pParent /* = 0 */, bool fForceCall /* = true */) 24 : QObject(pParent) 25 , m_fForceCall(fForceCall) 23 UINetworkCustomer::UINetworkCustomer() 26 24 { 27 25 } -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkCustomer.h
r90547 r90579 46 46 public: 47 47 48 /** Constructs network customer passing @a pParent to the base-class. 49 * @param fForceCall Brings whether this customer has forced privelegies. */ 50 UINetworkCustomer(QObject *pParent = 0, bool fForceCall = true); 48 /** Constructs network customer passing @a pParent to the base-class. */ 49 UINetworkCustomer(); 51 50 /** Destructs network customer. */ 52 51 virtual ~UINetworkCustomer() /* override */; 53 54 /** Returns whether this customer has forced privelegies. */55 bool isItForceCall() const { return m_fForceCall; }56 52 57 53 /** Returns description of the current network operation. */ … … 84 80 private: 85 81 86 /** Holds whether this customer has forced privelegies. */87 bool m_fForceCall;88 89 82 /** Holds the network-request ID. */ 90 83 QUuid m_uId; -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp
r90564 r90579 27 27 #include "UICommon.h" 28 28 #include "VBoxUtils.h" 29 #include "UIExecutionQueue.h" 29 30 #include "UIExtraDataManager.h" 30 31 #include "UIMessageCenter.h" … … 43 44 44 45 /* Other VBox includes: */ 45 //# include <iprt/err.h>46 46 #include <iprt/path.h> 47 47 #include <iprt/system.h> … … 51 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 52 53 /* Forward declarations: */ 54 class UIUpdateStep; 55 56 57 /** QObject subclass providing GUI with 58 * an object to manage queue of update-steps. */ 59 class UIUpdateQueue : public QObject 53 54 /** UINetworkCustomer extension for new version check. */ 55 class UINewVersionChecker : public UINetworkCustomer 60 56 { 61 57 Q_OBJECT; … … 63 59 signals: 64 60 65 /** Starts the queue. */ 66 void sigStartQueue(); 67 68 /** Notifies about queue is finished. */ 69 void sigQueueFinished(); 61 /** Notifies about new version check complete. */ 62 void sigNewVersionChecked(); 70 63 71 64 public: 72 65 73 /** Constructs update queue passing @a pParent to the base-class. */ 74 UIUpdateQueue(UIUpdateManager *pParent) : QObject(pParent) {} 75 76 /** Starts the queue. */ 77 void start() { emit sigStartQueue(); } 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); 78 83 79 84 private: 80 85 81 /** Returns whether queue is empty. */ 82 bool isEmpty() const { return m_pLastStep.isNull(); } 83 84 /** Defines the last queued @a pStep. */ 85 void setLastStep(UIUpdateStep *pStep) { m_pLastStep = pStep; } 86 /** Returns the last queued step. */ 87 UIUpdateStep *lastStep() const { return m_pLastStep; } 88 89 /** Holds the last queued step reference. */ 90 QPointer<UIUpdateStep> m_pLastStep; 91 92 /** Allows step to manage queue. */ 93 friend class UIUpdateStep; 94 }; 95 96 97 /** Update step interface. 98 * UINetworkCustomer extension which allows background network updates. */ 99 class UIUpdateStep : public UINetworkCustomer 100 { 101 Q_OBJECT; 102 103 signals: 104 105 /** Notifies about step is finished. */ 106 void sigStepComplete(); 107 108 public: 109 110 /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */ 111 UIUpdateStep(UIUpdateQueue *pQueue, bool fForceCall); 112 113 protected: 114 115 /** Handles network reply progress for @a iReceived amount of bytes among @a iTotal. */ 116 virtual void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal) /* override */; 117 /** Handles network reply finishing with specified @a strError. */ 118 virtual void processNetworkReplyFailed(const QString &strError) /* override */; 119 /** Handles network reply canceling for a passed @a pReply. */ 120 virtual void processNetworkReplyCanceled(UINetworkReply *pReply) /* override */; 121 /** Handles network reply finishing for a passed @a pReply. */ 122 virtual void processNetworkReplyFinished(UINetworkReply *pReply) /* override */; 123 124 protected slots: 125 126 /** Starts the step. */ 127 virtual void sltStartStep() = 0; 128 }; 129 130 131 /** Update step subclass to check for the new VirtualBox version. */ 132 class UIUpdateStepVirtualBox : public UIUpdateStep 133 { 134 Q_OBJECT; 135 136 public: 137 138 /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */ 139 UIUpdateStepVirtualBox(UIUpdateQueue *pQueue, bool fForceCall) 140 : UIUpdateStep(pQueue, fForceCall) 141 , m_url("https://update.virtualbox.org/query.php") 142 {} 143 144 protected: 145 146 /** Returns description of the current network operation. */ 147 virtual QString description() const /* override */; 148 149 /** Handles network reply finishing with specified @a strError. */ 150 virtual void processNetworkReplyFailed(const QString &strError) /* override */; 151 /** Handles network reply canceling for a passed @a pReply. */ 152 virtual void processNetworkReplyCanceled(UINetworkReply *pReply) /* override */; 153 /** Handles network reply finishing for a passed @a pReply. */ 154 virtual void processNetworkReplyFinished(UINetworkReply *pReply) /* override */; 155 156 protected slots: 157 158 /** Starts the step. */ 159 virtual void sltStartStep() /* override */; 160 161 private: 86 /** Returns whether this customer has forced privelegies. */ 87 bool isItForceCall() const { return m_fForceCall; } 162 88 163 89 /** Generates platform information. */ 164 90 static QString platformInfo(); 165 91 166 /** Holds the update step URL. */ 167 QUrl m_url; 92 /** Holds whether this customer has forced privelegies. */ 93 bool m_fForceCall; 94 /** Holds the new version checker URL. */ 95 QUrl m_url; 168 96 }; 169 97 170 98 171 /** U pdate step subclass to check for the new VirtualBox Extension Packversion. */172 class UIUpdateStepVirtualBox ExtensionPack : public UIUpdateStep99 /** UIExecutionStep extension to check for the new VirtualBox version. */ 100 class UIUpdateStepVirtualBox : public UIExecutionStep 173 101 { 174 102 Q_OBJECT; … … 176 104 public: 177 105 178 /** Constructs update step passing @a pQueue and @a fForceCall to the base-class. */ 179 UIUpdateStepVirtualBoxExtensionPack(UIUpdateQueue *pQueue, bool fForceCall) 180 : UIUpdateStep(pQueue, fForceCall) 181 {} 182 183 protected slots: 184 185 /** Starts the step. */ 186 virtual void sltStartStep() /* override */; 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 UIExecutionStep 123 { 124 Q_OBJECT; 125 126 public: 127 128 /** Constructs extension step. */ 129 UIUpdateStepVirtualBoxExtensionPack(); 130 131 /** Executes the step. */ 132 virtual void exec() /* override */; 187 133 188 134 private slots: … … 199 145 200 146 /********************************************************************************************************************************* 201 * Class UI UpdateStep implementation.*147 * Class UINewVersionChecker implementation. * 202 148 *********************************************************************************************************************************/ 203 149 204 UIUpdateStep::UIUpdateStep(UIUpdateQueue *pQueue, bool fForceCall) 205 : UINetworkCustomer(pQueue, fForceCall) 206 { 207 /* If queue has no steps yet: */ 208 if (pQueue->isEmpty()) 209 { 210 /* Connect starting-signal of the queue to starting-slot of this step: */ 211 connect(pQueue, &UIUpdateQueue::sigStartQueue, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection); 212 } 213 /* If queue has at least one step already: */ 214 else 215 { 216 /* Reconnect completion-signal of the last-step from completion-signal of the queue to starting-slot of this step: */ 217 disconnect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished); 218 connect(pQueue->lastStep(), &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::sltStartStep, Qt::QueuedConnection); 219 } 220 221 /* Connect completion-signal of this step to the completion-signal of the queue: */ 222 connect(this, &UIUpdateStep::sigStepComplete, pQueue, &UIUpdateQueue::sigQueueFinished, Qt::QueuedConnection); 223 /* Connect completion-signal of this step to the destruction-slot of this step: */ 224 connect(this, &UIUpdateStep::sigStepComplete, this, &UIUpdateStep::deleteLater, Qt::QueuedConnection); 225 226 /* Remember this step as the last one: */ 227 pQueue->setLastStep(this); 228 } 229 230 void UIUpdateStep::processNetworkReplyProgress(qint64, qint64) 231 { 232 } 233 234 void UIUpdateStep::processNetworkReplyFailed(const QString &) 235 { 236 } 237 238 void UIUpdateStep::processNetworkReplyCanceled(UINetworkReply *) 239 { 240 } 241 242 void UIUpdateStep::processNetworkReplyFinished(UINetworkReply *) 243 { 244 } 245 246 247 /********************************************************************************************************************************* 248 * Class UIUpdateStepVirtualBox implementation. * 249 *********************************************************************************************************************************/ 250 251 QString UIUpdateStepVirtualBox::description() const 252 { 253 return tr("Checking for a new VirtualBox version..."); 254 } 255 256 void UIUpdateStepVirtualBox::processNetworkReplyFailed(const QString &strError) 257 { 258 Q_UNUSED(strError); 259 260 /* Notify about step completion: */ 261 emit sigStepComplete(); 262 } 263 264 void UIUpdateStepVirtualBox::processNetworkReplyCanceled(UINetworkReply *pReply) 265 { 266 Q_UNUSED(pReply); 267 268 /* Notify about step completion: */ 269 emit sigStepComplete(); 270 } 271 272 void UIUpdateStepVirtualBox::processNetworkReplyFinished(UINetworkReply *pReply) 273 { 274 /* Deserialize incoming data: */ 275 QString strResponseData(pReply->readAll()); 276 277 #ifdef VBOX_NEW_VERSION_TEST 278 strResponseData = VBOX_NEW_VERSION_TEST; 279 #endif 280 /* Newer version of necessary package found: */ 281 if (strResponseData.indexOf(QRegExp("^\\d+\\.\\d+\\.\\d+(_[0-9A-Z]+)? \\S+$")) == 0) 282 { 283 QStringList response = strResponseData.split(" ", QString::SkipEmptyParts); 284 msgCenter().showUpdateSuccess(response[0], response[1]); 285 } 286 /* No newer version of necessary package found: */ 287 else 288 { 289 if (isItForceCall()) 290 msgCenter().showUpdateNotFound(); 291 } 292 293 /* Increment update check counter: */ 294 gEDataManager->incrementApplicationUpdateCheckCounter(); 295 296 /* Notify about step completion: */ 297 emit sigStepComplete(); 298 } 299 300 void UIUpdateStepVirtualBox::sltStartStep() 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() 301 157 { 302 158 /* Compose query: */ … … 320 176 url.addQueryItem("count", QString::number(gEDataManager->applicationUpdateCheckCounter())); 321 177 url.addQueryItem("branch", VBoxUpdateData(gEDataManager->applicationUpdateData()).branchName()); 322 QString strUserAgent(QString("VirtualBox %1 <%2>").arg(uiCommon().virtualBox().GetVersion()).arg(platformInfo()));178 const QString strUserAgent(QString("VirtualBox %1 <%2>").arg(uiCommon().virtualBox().GetVersion()).arg(platformInfo())); 323 179 324 180 /* Send GET request: */ … … 330 186 } 331 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_TEST 208 strResponseData = VBOX_NEW_VERSION_TEST; 209 #endif 210 /* 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 else 218 { 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 332 230 /* static */ 333 QString UI UpdateStepVirtualBox::platformInfo()231 QString UINewVersionChecker::platformInfo() 334 232 { 335 233 /* Prepare platform report: */ … … 406 304 407 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 /********************************************************************************************************************************* 408 331 * Class UIUpdateStepVirtualBoxExtensionPack implementation. * 409 332 *********************************************************************************************************************************/ 410 333 411 void UIUpdateStepVirtualBoxExtensionPack::sltStartStep() 412 { 413 /* Return if Selector UI issued a direct request to install EP: */ 334 UIUpdateStepVirtualBoxExtensionPack::UIUpdateStepVirtualBoxExtensionPack() 335 { 336 } 337 338 void UIUpdateStepVirtualBoxExtensionPack::exec() 339 { 340 /* Return if VirtualBox Manager issued a direct request to install EP: */ 414 341 if (gUpdateManager->isEPInstallationRequested()) 415 342 { 416 emit sigStep Complete();343 emit sigStepFinished(); 417 344 return; 418 345 } … … 421 348 if (UINotificationDownloaderExtensionPack::exists()) 422 349 { 423 emit sigStep Complete();350 emit sigStepFinished(); 424 351 return; 425 352 } … … 430 357 if (extPackManager.isNull()) 431 358 { 432 emit sigStep Complete();359 emit sigStepFinished(); 433 360 return; 434 361 } … … 439 366 if (extPack.isNull()) 440 367 { 441 emit sigStep Complete();368 emit sigStepFinished(); 442 369 return; 443 370 } … … 457 384 else 458 385 { 459 emit sigStep Complete();386 emit sigStepFinished(); 460 387 return; 461 388 } … … 468 395 if (UIVersion(strExtPackVersion) >= vboxVersion) 469 396 { 470 emit sigStep Complete();397 emit sigStepFinished(); 471 398 return; 472 399 } … … 478 405 msgCenter().askUserToDownloadExtensionPack(GUI_ExtPackName, strExtPackVersion, strVBoxVersion); 479 406 /* Never try to download for ENTERPRISE version: */ 480 emit sigStep Complete();407 emit sigStepFinished(); 481 408 return; 482 409 } … … 485 412 if (!msgCenter().warnAboutOutdatedExtensionPack(GUI_ExtPackName, strExtPackVersion)) 486 413 { 487 emit sigStep Complete();414 emit sigStepFinished(); 488 415 return; 489 416 } … … 496 423 /* Also, destroyed downloader is a signal to finish the step: */ 497 424 connect(pNotification, &UINotificationDownloaderExtensionPack::sigDownloaderDestroyed, 498 this, &UIUpdateStepVirtualBoxExtensionPack::sigStep Complete);425 this, &UIUpdateStepVirtualBoxExtensionPack::sigStepFinished); 499 426 /* Append and start notification: */ 500 427 gpNotificationCenter->append(pNotification); … … 515 442 /* Get the list of old extension pack files in VirtualBox homefolder: */ 516 443 const QStringList oldExtPackFiles = QDir(uiCommon().homeFolder()).entryList(QStringList("*.vbox-extpack"), 517 444 QDir::Files); 518 445 /* Propose to delete old extension pack files if there are any: */ 519 446 if (oldExtPackFiles.size()) … … 540 467 541 468 UIUpdateManager::UIUpdateManager() 542 : m_pQueue(new UI UpdateQueue(this))469 : m_pQueue(new UIExecutionQueue(this)) 543 470 , m_fIsRunning(false) 544 471 , m_uTime(1 /* day */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ * 1000 /* ms */) … … 550 477 551 478 /* Configure queue: */ 552 connect(m_pQueue, &UI UpdateQueue::sigQueueFinished, this, &UIUpdateManager::sltHandleUpdateFinishing);479 connect(m_pQueue, &UIExecutionQueue::sigQueueFinished, this, &UIUpdateManager::sltHandleUpdateFinishing); 553 480 554 481 #ifdef VBOX_WITH_UPDATE_REQUEST … … 621 548 { 622 549 /* Prepare update queue: */ 623 new UIUpdateStepVirtualBox(m_pQueue, fForceCall);624 new UIUpdateStepVirtualBoxExtensionPack(m_pQueue, fForceCall);550 m_pQueue->enqueue(new UIUpdateStepVirtualBox(fForceCall)); 551 m_pQueue->enqueue(new UIUpdateStepVirtualBoxExtensionPack); 625 552 /* Start update queue: */ 626 553 m_pQueue->start(); -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.h
r86996 r90579 29 29 30 30 /* Forward declarations: */ 31 class UI UpdateQueue;31 class UIExecutionQueue; 32 32 33 33 /** Singleton to perform new version checks … … 74 74 static UIUpdateManager *s_pInstance; 75 75 76 /** Holds the updatequeue instance. */77 UI UpdateQueue *m_pQueue;76 /** Holds the execution queue instance. */ 77 UIExecutionQueue *m_pQueue; 78 78 /** Holds whether Update Manager is running. */ 79 bool m_fIsRunning;79 bool m_fIsRunning; 80 80 /** Holds the refresh period. */ 81 quint64 m_uTime;81 quint64 m_uTime; 82 82 83 83 /** Holds whether the Extension Pack installation is requested. */
Note:
See TracChangeset
for help on using the changeset viewer.