UIDownloaderUserManual.cpp revision 6a26bb78e94a73f6033178cf61a20caf316b86b2
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIDownloaderUserManual class implementation
*/
/*
* Copyright (C) 2006-2012 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.
*/
/* Global includes: */
#include <QDir>
#include <QFile>
/* Local includes: */
#include "UIDownloaderUserManual.h"
#include "UINetworkReply.h"
#include "QIFileDialog.h"
#include "VBoxGlobal.h"
#include "UIMessageCenter.h"
/* static */
/* static */
{
if (!m_spInstance)
return m_spInstance;
}
/* static */
{
return m_spInstance;
}
{
/* Prepare instance: */
if (!m_spInstance)
m_spInstance = this;
/* Set description: */
/* Compose User Manual filename: */
/* Add sources: */
addSource(QString("http://download.virtualbox.org/virtualbox/%1/").arg(vboxGlobal().vboxVersionStringNormalized()) + strUserManualShortFileName);
/* Set target: */
QString strUserManualDestination = QDir(vboxGlobal().virtualBox().GetHomeFolder()).absoluteFilePath(strUserManualShortFileName);
}
{
/* Cleanup instance: */
if (m_spInstance == this)
m_spInstance = 0;
}
{
return msgCenter().confirmUserManualDownload(source().toString(), pReply->header(QNetworkRequest::ContentLengthHeader).toInt());
}
{
/* Read received data into the buffer: */
/* Serialize that buffer into the file: */
while (true)
{
/* Try to open file for writing: */
{
/* Write buffer into the file: */
/* Warn the user about user-manual loaded and saved: */
/* Warn the listener about user-manual was downloaded: */
break;
}
/* Warn user about user-manual was downloaded but was NOT saved: */
msgCenter().warnAboutUserManualCantBeSaved(source().toString(), QDir::toNativeSeparators(target()));
/* Ask the user for another location for the user-manual file: */
tr("Select folder to save User Manual to"), true);
/* Check if user had really set a new target: */
else
break;
}
}