d34409ad02ea0d28e08a6c4b089a412fdb3b4c9cvboxsync * VBox Qt GUI - UINetworkManager stuff implementation.
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync * Copyright (C) 2011-2012 Oracle Corporation
080759a48e3714821389086c4863320d166fc5ccvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
080759a48e3714821389086c4863320d166fc5ccvboxsync * available from http://www.virtualbox.org. This file is free software;
080759a48e3714821389086c4863320d166fc5ccvboxsync * you can redistribute it and/or modify it under the terms of the GNU
080759a48e3714821389086c4863320d166fc5ccvboxsync * General Public License (GPL) as published by the Free Software
080759a48e3714821389086c4863320d166fc5ccvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
080759a48e3714821389086c4863320d166fc5ccvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
080759a48e3714821389086c4863320d166fc5ccvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync/* Global includes: */
080759a48e3714821389086c4863320d166fc5ccvboxsync/* Local includes: */
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
080759a48e3714821389086c4863320d166fc5ccvboxsyncUINetworkManager* UINetworkManager::m_pInstance = 0;
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Check that instance do NOT exist: */
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Create instance: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Prepare instance: */
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Check that instance exists: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Cleanup instance: */
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Destroy instance: */
13825383b1d7b2c56ed9512bb01c6a060e10fff6vboxsyncUINetworkManagerDialog* UINetworkManager::window() const
430474e5ec398f769830a548d818d75ff37d5113vboxsyncUINetworkManagerIndicator* UINetworkManager::indicator() const
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Show network-manager dialog: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsyncvoid UINetworkManager::createNetworkRequest(const QNetworkRequest &request, UINetworkRequestType type, const QString &strDescription,
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Create network-request: */
13825383b1d7b2c56ed9512bb01c6a060e10fff6vboxsync UINetworkRequest *pNetworkRequest = new UINetworkRequest(request, type, strDescription, pCustomer, this);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Prepare created network-request: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsyncvoid UINetworkManager::createNetworkRequest(const QList<QNetworkRequest> &requests, UINetworkRequestType type, const QString &strDescription,
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Create network-request: */
13825383b1d7b2c56ed9512bb01c6a060e10fff6vboxsync UINetworkRequest *pNetworkRequest = new UINetworkRequest(requests, type, strDescription, pCustomer, this);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Prepare created network-request: */
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Prepare instance: */
080759a48e3714821389086c4863320d166fc5ccvboxsync /* Cleanup instance: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Prepare network-manager dialog: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync m_pNetworkManagerDialog = new UINetworkManagerDialog;
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync connect(m_pNetworkManagerDialog, SIGNAL(sigCancelNetworkRequests()), this, SIGNAL(sigCancelNetworkRequests()));
430474e5ec398f769830a548d818d75ff37d5113vboxsync /* Prepare network-manager state-indicator: */
07b5649901efe9d0612a944abd10b6dbd9701077vboxsync m_pNetworkManagerIndicator = new UINetworkManagerIndicator;
1dc1687a2420d4a5406d3dde085842b8de388fb4vboxsync connect(m_pNetworkManagerIndicator, SIGNAL(sigMouseDoubleClick(QIStatusBarIndicator*, QMouseEvent*)), this, SLOT(show()));
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Cleanup network-requests first: */
430474e5ec398f769830a548d818d75ff37d5113vboxsync /* Cleanup network-manager state-indicator: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Cleanup network-manager dialog: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsyncvoid UINetworkManager::prepareNetworkRequest(UINetworkRequest *pNetworkRequest)
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Prepare listeners for network-request: */
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync connect(pNetworkRequest, SIGNAL(sigProgress(const QUuid&, qint64, qint64)),
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync this, SLOT(sltHandleNetworkRequestProgress(const QUuid&, qint64, qint64)));
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync connect(pNetworkRequest, SIGNAL(sigCanceled(const QUuid&)),
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync this, SLOT(sltHandleNetworkRequestCancel(const QUuid&)));
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync connect(pNetworkRequest, SIGNAL(sigFinished(const QUuid&)),
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync this, SLOT(sltHandleNetworkRequestFinish(const QUuid&)));
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync connect(pNetworkRequest, SIGNAL(sigFailed(const QUuid&, const QString&)),
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync this, SLOT(sltHandleNetworkRequestFailure(const QUuid&, const QString&)));
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Add network-request into map: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync m_requests.insert(pNetworkRequest->uuid(), pNetworkRequest);
3ae772c8449c1aa673490c7bcb5b47c1cc7b6468vboxsyncvoid UINetworkManager::cleanupNetworkRequest(QUuid uuid)
5d21e43767a8ad1220a67c8954e95d687a433783vboxsync /* Delete network-request from map: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get all the request IDs: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Cleanup corresponding requests: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsyncvoid UINetworkManager::sltHandleNetworkRequestProgress(const QUuid &uuid, qint64 iReceived, qint64 iTotal)
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Make sure corresponding map contains received ID: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync AssertMsg(m_requests.contains(uuid), ("Network-request NOT found!\n"));
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding network-request: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkRequest *pNetworkRequest = m_requests.value(uuid);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding customer: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkCustomer *pNetworkCustomer = pNetworkRequest->customer();
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Send to customer to process: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync pNetworkCustomer->processNetworkReplyProgress(iReceived, iTotal);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsyncvoid UINetworkManager::sltHandleNetworkRequestCancel(const QUuid &uuid)
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Make sure corresponding map contains received ID: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync AssertMsg(m_requests.contains(uuid), ("Network-request NOT found!\n"));
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding network-request: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkRequest *pNetworkRequest = m_requests.value(uuid);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding customer: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkCustomer *pNetworkCustomer = pNetworkRequest->customer();
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Send to customer to process: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync pNetworkCustomer->processNetworkReplyCanceled(pNetworkRequest->reply());
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Cleanup network-request: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsyncvoid UINetworkManager::sltHandleNetworkRequestFinish(const QUuid &uuid)
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Make sure corresponding map contains received ID: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync AssertMsg(m_requests.contains(uuid), ("Network-request NOT found!\n"));
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding network-request: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkRequest *pNetworkRequest = m_requests.value(uuid);
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Get corresponding customer: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync UINetworkCustomer *pNetworkCustomer = pNetworkRequest->customer();
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Send to customer to process: */
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync pNetworkCustomer->processNetworkReplyFinished(pNetworkRequest->reply());
f36543a0783c9fadf211ea3e98ef6578f5736ccdvboxsync /* Cleanup network-request: */
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsyncvoid UINetworkManager::sltHandleNetworkRequestFailure(const QUuid &uuid, const QString &)
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync /* Make sure corresponding map contains received ID: */
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync AssertMsg(m_requests.contains(uuid), ("Network-request NOT found!\n"));
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync /* Get corresponding network-request: */
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync UINetworkRequest *pNetworkRequest = m_requests.value(uuid);
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync /* Get corresponding customer: */
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync UINetworkCustomer *pNetworkCustomer = pNetworkRequest->customer();
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync /* If customer made a force-call: */
35568bc855b9ac11d922f73c9d49d363db3f4993vboxsync /* Just show the dialog: */