Changeset 58480 in vbox
- Timestamp:
- Oct 29, 2015 12:58:18 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103794
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/net
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.cpp
r58426 r58480 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UINetworkRequest stuffimplementation.3 * VBox Qt GUI - UINetworkRequest class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 31 31 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 32 32 33 34 33 UINetworkRequest::UINetworkRequest(UINetworkRequestType type, 35 34 const QList<QUrl> &urls, … … 39 38 : QObject(pNetworkManager) 40 39 , m_type(type) 41 , m_uuid(QUuid::createUuid())42 40 , m_requests(urls) 43 41 , m_requestHeaders(requestHeaders) 42 , m_pCustomer(pCustomer) 43 , m_pNetworkManager(pNetworkManager) 44 , m_uuid(QUuid::createUuid()) 44 45 , m_iCurrentRequestIndex(0) 45 , m_pCustomer(pCustomer)46 46 , m_fRunning(false) 47 47 { 48 /* Initialize: */49 initialize();48 /* Prepare: */ 49 prepare(); 50 50 } 51 51 52 52 UINetworkRequest::~UINetworkRequest() 53 53 { 54 /* Destroy network-reply: */ 55 cleanupNetworkReply(); 56 57 /* Unregister network-request from network-manager: */ 58 manager()->unregisterNetworkRequest(m_uuid); 59 } 60 61 UINetworkManager* UINetworkRequest::manager() const 62 { 63 AssertPtrReturn(parent(), 0); 64 return qobject_cast<UINetworkManager*>(parent()); 54 /* Cleanup: */ 55 cleanup(); 65 56 } 66 57 … … 70 61 } 71 62 72 /* Network-reply progress handler: */73 63 void UINetworkRequest::sltHandleNetworkReplyProgress(qint64 iReceived, qint64 iTotal) 74 64 { … … 79 69 } 80 70 81 /* Network-reply finish handler: */82 71 void UINetworkRequest::sltHandleNetworkReplyFinish() 83 72 { … … 145 134 } 146 135 147 /* Slot to retry network-request: */148 136 void UINetworkRequest::sltRetry() 149 137 { … … 159 147 } 160 148 161 /* Slot to cancel network-request: */162 149 void UINetworkRequest::sltCancel() 163 150 { 164 151 /* Abort network-reply if present: */ 165 abortNetworkReply(); 166 } 167 168 /* Initialize: */ 169 void UINetworkRequest::initialize() 170 { 171 /* Prepare listeners for parent(): */ 172 connect(parent(), SIGNAL(sigCancelNetworkRequests()), this, SLOT(sltCancel()), Qt::QueuedConnection); 152 if (m_pReply) 153 { 154 if (m_fRunning) 155 m_pReply->abort(); 156 else 157 emit sigCanceled(m_uuid); 158 } 159 } 160 161 void UINetworkRequest::prepare() 162 { 163 /* Prepare listeners for manager(): */ 164 connect(manager(), SIGNAL(sigCancelNetworkRequests()), this, SLOT(sltCancel()), Qt::QueuedConnection); 173 165 174 166 /* Register network-request in network-manager: */ … … 179 171 m_request = m_requests.at(m_iCurrentRequestIndex); 180 172 181 /* Create network-reply: */173 /* Prepare network-reply: */ 182 174 prepareNetworkReply(); 183 175 } 184 176 185 /* Prepare network-reply: */186 177 void UINetworkRequest::prepareNetworkReply() 187 178 { … … 202 193 } 203 194 204 /* Cleanup network-reply: */205 195 void UINetworkRequest::cleanupNetworkReply() 206 196 { … … 212 202 } 213 203 214 /* Abort network-reply: */ 215 void UINetworkRequest::abortNetworkReply() 216 { 217 /* Abort network-reply if present: */ 218 if (m_pReply) 219 { 220 if (m_fRunning) 221 m_pReply->abort(); 222 else 223 emit sigCanceled(m_uuid); 224 } 225 } 226 204 void UINetworkRequest::cleanup() 205 { 206 /* Cleanup network-reply: */ 207 cleanupNetworkReply(); 208 209 /* Unregister network-request from network-manager: */ 210 manager()->unregisterNetworkRequest(m_uuid); 211 } 212 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.h
r58426 r58480 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UINetworkRequest stuffdeclaration.3 * VBox Qt GUI - UINetworkRequest class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UINetworkRequest_h__19 #define __ UINetworkRequest_h__18 #ifndef ___UINetworkRequest_h___ 19 #define ___UINetworkRequest_h___ 20 20 21 21 /* Qt includes: */ … … 64 64 UINetworkCustomer *pCustomer, 65 65 UINetworkManager *pNetworkManager); 66 /** Destructs network 66 /** Destructs network-request. */ 67 67 ~UINetworkRequest(); 68 68 69 /** Returns parent network-manager. */70 UINetworkManager* manager() const;71 69 /* Getters: */ 72 const QUuid& uuid() const { return m_uuid; }73 70 const QString description() const; 74 71 UINetworkCustomer* customer() { return m_pCustomer; } 72 /** Returns parent network-manager. */ 73 UINetworkManager* manager() const { return m_pNetworkManager; } 74 const QUuid& uuid() const { return m_uuid; } 75 75 UINetworkReply* reply() { return m_pReply; } 76 76 … … 89 89 private: 90 90 91 /* Initialize: */ 92 void initialize(); 93 91 /* Prepare: */ 92 void prepare(); 94 93 /* Prepare network-reply: */ 95 94 void prepareNetworkReply(); 95 96 96 /* Cleanup network-reply: */ 97 97 void cleanupNetworkReply(); 98 /* Abort network-reply: */99 void abortNetworkReply();98 /* Cleanup: */ 99 void cleanup(); 100 100 101 101 /* Variables: */ 102 UINetworkRequestType m_type; 103 QUuid m_uuid; 104 QList<QUrl> m_requests; 102 const UINetworkRequestType m_type; 103 const QList<QUrl> m_requests; 105 104 /** Holds the request headers. */ 106 105 const UserDictionary m_requestHeaders; 106 UINetworkCustomer *m_pCustomer; 107 UINetworkManager *m_pNetworkManager; 108 const QUuid m_uuid; 109 107 110 QUrl m_request; 108 111 int m_iCurrentRequestIndex; 109 QString m_strDescription;110 UINetworkCustomer *m_pCustomer; 112 bool m_fRunning; 113 111 114 QPointer<UINetworkReply> m_pReply; 112 bool m_fRunning;113 115 }; 114 116 115 #endif // __UINetworkRequest_h__ 117 #endif /* !___UINetworkRequest_h___ */ 118
Note:
See TracChangeset
for help on using the changeset viewer.