UIDownloader.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIDownloader class implementation
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* Local includes */
#include "UIDownloader.h"
#include "QIHttp.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
#include "VBoxSpecialControls.h"
/* Global includes */
#include <QFile>
#include <QProgressBar>
, m_pProgressBar(new QProgressBar(this))
, m_pCancelButton(new VBoxMiniCancelButton(this))
{
/* Progress Bar setup */
m_pProgressBar->setValue(0);
/* Cancel Button setup */
setContentsMargins(0, 0, 0, 0);
setFixedHeight(16);
/* Layout setup */
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
pMainLayout->setSpacing(0);
#endif /* !Q_WS_MAC */
}
{
}
{
return m_pCancelButton->text();
}
{
}
{
return m_pCancelButton->toolTip();
}
{
}
{
return m_pProgressBar->toolTip();
}
{
}
{
return m_strSource;
}
{
}
: m_pHttp(0)
{
}
{
}
{
}
{
}
{
return m_strTarget;
}
void UIDownloader::startDownload()
{
/* By default we are not using acknowledging step, so
* making downloading immediately */
}
/* This function is used to start acknowledging mechanism:
* checking file presence & size */
void UIDownloader::acknowledgeStart()
{
delete m_pHttp;
this, SLOT(acknowledgeFinished(bool)));
}
/* This function is used to store content length */
{
/* Abort connection as we already got all we need */
}
/* This function is used to ask the user about if he really want
* to download file of proposed size if no error present or
* abort download progress if error is present */
{
m_pHttp->disconnect(this);
{
{
/* Ask the user if he wish to download it */
if (confirmDownload())
else
break;
}
case QIHttp::MovedPermanentlyError:
case QIHttp::MovedTemporarilyError:
{
/* Restart downloading at new location */
break;
}
default:
{
/* Show error happens during acknowledging */
break;
}
}
}
/* This function is used to start downloading mechanism:
* downloading and saving the target */
void UIDownloader::downloadStart()
{
delete m_pHttp;
this, SLOT (downloadProcess(int, int)));
this, SLOT(downloadFinished(bool)));
}
/* this function is used to observe the downloading progress through
* changing the corresponding qprogressbar value */
{
}
/* This function is used to handle the 'downloading finished' issue
* through saving the downloaded into the file if there in no error or
* notifying the user about error happens */
{
m_pHttp->disconnect(this);
if (fError)
{
/* Show information about error happens */
else
}
else
{
/* Trying to serialize the incoming buffer into the target, this is the
* default behavior which have to be reimplemented in sub-class */
{
}
}
}
/* This slot is used to process cancel-button clicking */
void UIDownloader::cancelDownloading()
{
}
/* This function is used to abort download by showing aborting reason
* and calling the downloader's delete function */
{
}
/* This function is used to delete the downloader widget itself,
* should be reimplemented to enhance necessary functionality in sub-class */
void UIDownloader::suicide()
{
delete this;
}