videodownloader/network/optiondata.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

2015-09-08 17:05:59 +02:00
#include "./optiondata.h"
#include "./permissionstatus.h"
2015-04-22 19:32:04 +02:00
#include <QIODevice>
namespace Network {
/*!
* \class OptionData
* \brief The OptionData class wraps download option specific information.
*/
/*!
* \brief Constructs a new option data object.
*/
2017-05-01 03:22:50 +02:00
OptionData::OptionData(const QString &name, const QUrl &url, size_t redirectsTo, size_t redirectionOf)
: m_name(name)
, m_url(url)
, m_redirectsTo(redirectsTo)
, m_redirectionOf(redirectionOf)
, m_requestingNewOutputDevice(false)
, m_outputDevice(nullptr)
, m_outputDeviceReady(false)
, m_bytesWritten(0)
, m_stillWriting(false)
, m_downloadComplete(false)
, m_downloadAbortedInternally(false)
, m_hasOutputDeviceOwnership(false)
, m_overwritePermission(PermissionStatus::Unknown)
, m_appendPermission(PermissionStatus::Unknown)
, m_redirectPermission(PermissionStatus::Unknown)
, m_ignoreSslErrorsPermission(PermissionStatus::Unknown)
{
}
2015-04-22 19:32:04 +02:00
/*!
* \brief Destroys the assigned output device if ownership has been given, detaches the assigned
* output device if ownership has not been given.
*/
void OptionData::chuckOutputDevice()
{
2017-05-01 03:22:50 +02:00
if (m_outputDevice && m_hasOutputDeviceOwnership) {
2015-04-22 19:32:04 +02:00
delete m_outputDevice;
}
m_outputDevice = nullptr;
m_hasOutputDeviceOwnership = false;
}
/*!
* \brief Destroys the option data object. Also calls destroyDevice().
*/
OptionData::~OptionData()
{
chuckOutputDevice();
}
} // namespace Network