Changeset 41145 in vbox
- Timestamp:
- May 3, 2012 4:40:59 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/net
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
r39932 r41145 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIUpdateManager class implementation. 3 * 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIUpdateManager class implementation 4 6 */ 5 7 6 8 /* 7 * Copyright (C) 2006-201 1Oracle Corporation9 * Copyright (C) 2006-2012 Oracle Corporation 8 10 * 9 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 19 18 20 /* Global includes: */ 19 #include <QEventLoop>20 21 #include <QNetworkReply> 21 22 #include <QTimer> … … 36 37 #include "VBoxDefs.h" 37 38 39 /* Forward declarations: */ 40 class UIUpdateStep; 41 38 42 /* Using declarations: */ 39 43 using namespace VBoxGlobalDefs; 40 44 41 /* Interface representing update step: */ 45 /* Queue for processing update-steps: */ 46 class UIUpdateQueue : public QObject 47 { 48 Q_OBJECT; 49 50 signals: 51 52 /* Starting-signal of the queue: */ 53 void sigStartQueue(); 54 55 /* Completion-signal of the queue: */ 56 void sigQueueFinished(); 57 58 public: 59 60 /* Constructor: */ 61 UIUpdateQueue(UIUpdateManager *pParent) : QObject(pParent) {} 62 63 /* Starts a queue: */ 64 void start() { emit sigStartQueue(); } 65 66 private: 67 68 /* Helpers: */ 69 bool isEmpty() const { return m_pLastStep.isNull(); } 70 UIUpdateStep* lastStep() const { return m_pLastStep; } 71 void setLastStep(UIUpdateStep *pStep) { m_pLastStep = pStep; } 72 73 /* Variables: */ 74 QPointer<UIUpdateStep> m_pLastStep; 75 76 /* Friend classes: */ 77 friend class UIUpdateStep; 78 }; 79 80 /* Interface representing update-step: */ 42 81 class UIUpdateStep : public UINetworkCustomer 43 82 { … … 52 91 53 92 /* Constructor: */ 54 UIUpdateStep() 55 { 56 /* Connect completion-signal of the step to the destruction-slot of the step: */ 93 UIUpdateStep(UIUpdateQueue *pQueue) : UINetworkCustomer(pQueue) 94 { 95 /* If queue has no steps yet: */ 96 if (pQueue->isEmpty()) 97 { 98 /* Connect starting-signal of the queue to starting-slot of this step: */ 99 connect(pQueue, SIGNAL(sigStartQueue()), this, SLOT(sltStartStep()), Qt::QueuedConnection); 100 } 101 /* If queue has at least one step already: */ 102 else 103 { 104 /* Reconnect completion-signal of the last-step from completion-signal of the queue to starting-slot of this step: */ 105 disconnect(pQueue->lastStep(), SIGNAL(sigStepComplete()), pQueue, SIGNAL(sigQueueFinished())); 106 connect(pQueue->lastStep(), SIGNAL(sigStepComplete()), this, SLOT(sltStartStep()), Qt::QueuedConnection); 107 } 108 109 /* Connect completion-signal of this step to the completion-signal of the queue: */ 110 connect(this, SIGNAL(sigStepComplete()), pQueue, SIGNAL(sigQueueFinished()), Qt::QueuedConnection); 111 /* Connect completion-signal of this step to the destruction-slot of this step: */ 57 112 connect(this, SIGNAL(sigStepComplete()), this, SLOT(deleteLater()), Qt::QueuedConnection); 113 114 /* Remember this step as the last one: */ 115 pQueue->setLastStep(this); 58 116 } 59 117 … … 73 131 }; 74 132 75 /* Queue for processing update steps: */76 class UIUpdate Queue : public QObject133 /* Update-step to check for the new VirtualBox version: */ 134 class UIUpdateStepVirtualBox : public UIUpdateStep 77 135 { 78 136 Q_OBJECT; 79 137 80 signals:81 82 /* Starting-signal of the queue: */83 void sigStartQueue();84 85 /* Completion-signal of the queue: */86 void sigQueueFinished();87 88 138 public: 89 139 90 140 /* Constructor: */ 91 UIUpdateQueue(UIUpdateManager *pParent) : QObject(pParent) {} 92 93 /* Enqueue passed-step with previously queued (if any) passed-steps: */ 94 void add(UIUpdateStep *pStep) 95 { 96 /* Set 'this' as parent for passed step, 97 * that way passed-step could be cleaned-up in case of queue destruction: */ 98 pStep->setParent(this); 99 100 /* If queue had no passed-steps yet: */ 101 if (!m_pLastStep) 102 { 103 /* Connect starting-signal of the queue to starting-slot of the passed-step: */ 104 connect(this, SIGNAL(sigStartQueue()), pStep, SLOT(sltStartStep()), Qt::QueuedConnection); 105 } 106 /* If queue already had at least one passed-step: */ 107 else 108 { 109 /* Reconnect completion-signal of the last-step from completion-signal of the queue to starting-slot of the passed-step: */ 110 disconnect(m_pLastStep, SIGNAL(sigStepComplete()), this, SIGNAL(sigQueueFinished())); 111 connect(m_pLastStep, SIGNAL(sigStepComplete()), pStep, SLOT(sltStartStep()), Qt::QueuedConnection); 112 } 113 114 /* Connect completion-signal of the passed-step to the completion-signal of the queue: */ 115 connect(pStep, SIGNAL(sigStepComplete()), this, SIGNAL(sigQueueFinished()), Qt::QueuedConnection); 116 117 /* Remember last-step: */ 118 m_pLastStep = pStep; 119 } 120 121 /* Starts a queue: */ 122 void start() 123 { 124 /* Emit signal which starts queue: */ 125 emit sigStartQueue(); 126 } 127 128 private: 129 130 /* Guarded pointer to the last passed-step: */ 131 QPointer<UIUpdateStep> m_pLastStep; 132 }; 133 134 /* Update step to check for the new VirtualBox version: */ 135 class UIUpdateStepVirtualBox : public UIUpdateStep 136 { 137 Q_OBJECT; 138 139 public: 140 141 /* Constructor: */ 142 UIUpdateStepVirtualBox(bool fForceCall) 143 : m_url("http://update.virtualbox.org/query.php") 141 UIUpdateStepVirtualBox(UIUpdateQueue *pQueue, bool fForceCall) 142 : UIUpdateStep(pQueue) 143 , m_url("http://update.virtualbox.org/query.php") 144 144 , m_fForceCall(fForceCall) 145 145 { … … 243 243 }; 244 244 245 /* Update 245 /* Update-step to check for the new VirtualBox Extension Pack version: */ 246 246 class UIUpdateStepVirtualBoxExtensionPack : public UIUpdateStep 247 247 { … … 251 251 252 252 /* Constructor: */ 253 UIUpdateStepVirtualBoxExtensionPack() {} 253 UIUpdateStepVirtualBoxExtensionPack(UIUpdateQueue *pQueue) 254 : UIUpdateStep(pQueue) 255 { 256 } 254 257 255 258 private slots: … … 409 412 { 410 413 /* Prepare update queue: */ 411 m_pQueue->add(new UIUpdateStepVirtualBox(fForceCall));412 m_pQueue->add(new UIUpdateStepVirtualBoxExtensionPack);414 new UIUpdateStepVirtualBox(m_pQueue, fForceCall); 415 new UIUpdateStepVirtualBoxExtensionPack(m_pQueue); 413 416 /* Start update queue: */ 414 417 m_pQueue->start(); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h
r39932 r41145 6 6 7 7 /* 8 * Copyright (C) 2006-201 1Oracle Corporation8 * Copyright (C) 2006-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 class UIUpdateQueue; 27 27 28 /* Singleton to perform new version checks and29 * updatesof various VirtualBox parts. */28 /* Singleton to perform new version checks 29 * and update of various VirtualBox parts. */ 30 30 class UIUpdateManager : public QObject 31 31 { … … 69 69 70 70 #endif // __UIUpdateManager_h__ 71
Note:
See TracChangeset
for help on using the changeset viewer.