Fix compilation warnings in smtp.h (cgreco)

This commit is contained in:
Christophe Dumez
2011-06-05 16:09:02 +00:00
commit 43dd012b79
741 changed files with 261428 additions and 0 deletions

View File

@@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>createTorrentDialog</class>
<widget class="QDialog" name="createTorrentDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>592</width>
<height>658</height>
</rect>
</property>
<property name="windowTitle">
<string>Torrent Creation Tool</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="createTorrent_title">
<property name="minimumSize">
<size>
<width>0</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>27</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Torrent file creation</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_input">
<property name="text">
<string>File or folder to add to the torrent:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textInputPath"/>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="addFile_button">
<property name="text">
<string>Add file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addFolder_button">
<property name="text">
<string>Add folder</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_announce_url">
<property name="text">
<string>Tracker URLs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="urlSeeds_lbl">
<property name="text">
<string>Web seeds urls:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_comment">
<property name="text">
<string>Comment:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QTextEdit" name="txt_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTextEdit" name="trackers_list">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="URLSeeds_list">
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="txtPieceSize">
<property name="text">
<string>Piece size:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboPieceSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>3</number>
</property>
<item>
<property name="text">
<string>32 KiB</string>
</property>
</item>
<item>
<property name="text">
<string>64 KiB</string>
</property>
</item>
<item>
<property name="text">
<string>128 KiB</string>
</property>
</item>
<item>
<property name="text">
<string>256 KiB</string>
</property>
</item>
<item>
<property name="text">
<string>512 KiB</string>
</property>
</item>
<item>
<property name="text">
<string>1 MiB</string>
</property>
</item>
<item>
<property name="text">
<string>2 MiB</string>
</property>
</item>
<item>
<property name="text">
<string>4 MiB</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkAutoPieceSize">
<property name="text">
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_private">
<property name="text">
<string>Private (won't be distributed on DHT network if enabled)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkStartSeeding">
<property name="text">
<string>Start seeding after creation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progressLbl">
<property name="text">
<string>Progress:</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createButton">
<property name="text">
<string>Create and save...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,10 @@
INCLUDEPATH += $$PWD
FORMS += $$PWD/createtorrent.ui
HEADERS += $$PWD/torrentcreatordlg.h \
$$PWD/torrentcreatorthread.h
SOURCES += $$PWD/torrentcreatordlg.cpp \
$$PWD/torrentcreatorthread.cpp

View File

@@ -0,0 +1,282 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
#include "torrentpersistentdata.h"
#include "torrentcreatordlg.h"
#include "misc.h"
#include "qinisettings.h"
#include "torrentcreatorthread.h"
#include "iconprovider.h"
const uint NB_PIECES_MIN = 1200;
const uint NB_PIECES_MAX = 2200;
using namespace libtorrent;
TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent): QDialog(parent), creatorThread(0) {
setupUi(this);
// Icons
addFile_button->setIcon(IconProvider::instance()->getIcon("document-new"));
addFolder_button->setIcon(IconProvider::instance()->getIcon("folder-new"));
createButton->setIcon(IconProvider::instance()->getIcon("document-save"));
cancelButton->setIcon(IconProvider::instance()->getIcon("dialog-cancel"));
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
showProgressBar(false);
loadTrackerList();
// Piece sizes
m_piece_sizes << 32 << 64 << 128 << 256 << 512 << 1024 << 2048 << 4096;
loadSettings();
show();
}
TorrentCreatorDlg::~TorrentCreatorDlg() {
if(creatorThread)
delete creatorThread;
}
void TorrentCreatorDlg::on_addFolder_button_clicked(){
QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
if(!dir.isEmpty()) {
settings.setValue("CreateTorrent/last_add_path", dir);
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
dir = dir.replace("/", "\\");
#endif
textInputPath->setText(dir);
// Update piece size
if(checkAutoPieceSize->isChecked())
updateOptimalPieceSize();
}
}
void TorrentCreatorDlg::on_addFile_button_clicked(){
QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
if(!file.isEmpty()) {
settings.setValue("CreateTorrent/last_add_path", misc::removeLastPathPart(file));
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
file = file.replace("/", "\\");
#endif
textInputPath->setText(file);
// Update piece size
if(checkAutoPieceSize->isChecked())
updateOptimalPieceSize();
}
}
int TorrentCreatorDlg::getPieceSize() const {
return m_piece_sizes.at(comboPieceSize->currentIndex())*1024;
}
// Main function that create a .torrent file
void TorrentCreatorDlg::on_createButton_clicked(){
QString input = textInputPath->text().trimmed();
if (input.endsWith(QDir::separator()))
input.chop(1);
if(input.isEmpty()){
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
return;
}
QStringList trackers = trackers_list->toPlainText().split("\n");
if(!trackers_list->toPlainText().trimmed().isEmpty())
saveTrackerList();
QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_save_path", QDir::homePath()).toString();
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), last_path, tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
if(!destination.isEmpty()) {
settings.setValue("CreateTorrent/last_save_path", misc::removeLastPathPart(destination));
if(!destination.toUpper().endsWith(".TORRENT"))
destination += QString::fromUtf8(".torrent");
} else {
return;
}
// Disable dialog
setInteractionEnabled(false);
showProgressBar(true);
// Set busy cursor
setCursor(QCursor(Qt::WaitCursor));
// Actually create the torrent
QStringList url_seeds = URLSeeds_list->toPlainText().split("\n");
QString comment = txt_comment->toPlainText();
// Create the creator thread
creatorThread = new TorrentCreatorThread(this);
connect(creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
}
void TorrentCreatorDlg::handleCreationFailure(QString msg) {
// Remove busy cursor
setCursor(QCursor(Qt::ArrowCursor));
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg));
setInteractionEnabled(true);
showProgressBar(false);
}
void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path) {
// Remove busy cursor
setCursor(QCursor(Qt::ArrowCursor));
if(checkStartSeeding->isChecked()) {
QString root_folder;
// Create save path temp data
boost::intrusive_ptr<torrent_info> t;
try {
t = new torrent_info(path.toUtf8().data());
root_folder = misc::truncateRootFolder(t);
} catch(std::exception&) {
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
return;
}
QString hash = misc::toQString(t->info_hash());
QString save_path = branch_path;
if(!root_folder.isEmpty()) {
save_path = QDir(save_path).absoluteFilePath(root_folder);
}
TorrentTempData::setSavePath(hash, save_path);
#if LIBTORRENT_VERSION_MINOR > 14
// Enable seeding mode (do not recheck the files)
TorrentTempData::setSeedingMode(hash, true);
#endif
emit torrent_to_seed(path);
}
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
close();
}
void TorrentCreatorDlg::on_cancelButton_clicked() {
// End torrent creation thread
if(creatorThread && creatorThread->isRunning()) {
creatorThread->abortCreation();
creatorThread->terminate();
// Wait for termination
creatorThread->wait();
}
// Close the dialog
close();
}
void TorrentCreatorDlg::updateProgressBar(int progress) {
progressBar->setValue(progress);
}
void TorrentCreatorDlg::setInteractionEnabled(bool enabled)
{
textInputPath->setEnabled(enabled);
addFile_button->setEnabled(enabled);
addFolder_button->setEnabled(enabled);
trackers_list->setEnabled(enabled);
URLSeeds_list->setEnabled(enabled);
txt_comment->setEnabled(enabled);
comboPieceSize->setEnabled(enabled);
check_private->setEnabled(enabled);
checkStartSeeding->setEnabled(enabled);
createButton->setEnabled(enabled);
//cancelButton->setEnabled(!enabled);
}
void TorrentCreatorDlg::showProgressBar(bool show)
{
progressLbl->setVisible(show);
progressBar->setVisible(show);
}
void TorrentCreatorDlg::on_checkAutoPieceSize_clicked(bool checked)
{
comboPieceSize->setEnabled(!checked);
if(checked) {
updateOptimalPieceSize();
}
}
void TorrentCreatorDlg::updateOptimalPieceSize()
{
quint64 torrent_size = misc::computePathSize(textInputPath->text());
qDebug("Torrent size is %lld", torrent_size);
if(torrent_size == 0) return;
int i = 0;
qulonglong nb_pieces = 0;
do {
nb_pieces = (double)torrent_size/(m_piece_sizes.at(i)*1024.);
qDebug("nb_pieces=%lld with piece_size=%s", nb_pieces, qPrintable(comboPieceSize->itemText(i)));
if(nb_pieces <= NB_PIECES_MIN) {
if(i > 1)
--i;
break;
}
if(nb_pieces < NB_PIECES_MAX) {
qDebug("Good, nb_pieces=%lld < %d", nb_pieces, NB_PIECES_MAX);
break;
}
++i;
}while(i<m_piece_sizes.size());
comboPieceSize->setCurrentIndex(i);
}
void TorrentCreatorDlg::saveTrackerList()
{
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue("CreateTorrent/TrackerList", trackers_list->toPlainText());
}
void TorrentCreatorDlg::loadTrackerList()
{
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
trackers_list->setPlainText(settings.value("CreateTorrent/TrackerList", "").toString());
}
void TorrentCreatorDlg::saveSettings()
{
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue("CreateTorrent/dimensions", saveGeometry());
}
void TorrentCreatorDlg::loadSettings()
{
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
restoreGeometry(settings.value("CreateTorrent/dimensions").toByteArray());
}
void TorrentCreatorDlg::closeEvent(QCloseEvent *event)
{
qDebug() << Q_FUNC_INFO;
saveSettings();
QDialog::closeEvent(event);
}

View File

@@ -0,0 +1,78 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef CREATE_TORRENT_IMP_H
#define CREATE_TORRENT_IMP_H
#include "ui_createtorrent.h"
class TorrentCreatorThread;
class TorrentCreatorDlg : public QDialog, private Ui::createTorrentDialog{
Q_OBJECT
public:
TorrentCreatorDlg(QWidget *parent = 0);
~TorrentCreatorDlg();
int getPieceSize() const;
signals:
void torrent_to_seed(QString path);
public slots:
void updateProgressBar(int progress);
void on_cancelButton_clicked();
protected slots:
void on_createButton_clicked();
void on_addFile_button_clicked();
void on_addFolder_button_clicked();
void handleCreationFailure(QString msg);
void handleCreationSuccess(QString path, QString branch_path);
void setInteractionEnabled(bool enabled);
void showProgressBar(bool show);
void on_checkAutoPieceSize_clicked(bool checked);
void updateOptimalPieceSize();
void saveTrackerList();
void loadTrackerList();
protected:
void closeEvent(QCloseEvent *event);
private:
void saveSettings();
void loadSettings();
private:
TorrentCreatorThread *creatorThread;
QList<int> m_piece_sizes;
};
#endif

View File

@@ -0,0 +1,130 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/bind.hpp>
#include <libtorrent/version.hpp>
#include <libtorrent/entry.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/file.hpp>
#include <libtorrent/storage.hpp>
#include <libtorrent/hasher.hpp>
#include <libtorrent/file_pool.hpp>
#include <libtorrent/create_torrent.hpp>
#include <QFile>
#include "torrentcreatorthread.h"
#include "misc.h"
using namespace libtorrent;
using namespace boost::filesystem;
// do not include files and folders whose
// name starts with a .
bool file_filter(boost::filesystem::path const& filename)
{
if (filename.leaf()[0] == '.') return false;
std::cerr << filename << std::endl;
return true;
}
void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size)
{
input_path = _input_path;
save_path = _save_path;
if(QFile(save_path).exists())
misc::safeRemove(save_path);
trackers = _trackers;
url_seeds = _url_seeds;
comment = _comment;
is_private = _is_private;
piece_size = _piece_size;
path::default_name_check(no_check);
abort = false;
start();
}
void sendProgressUpdateSignal(int i, int num, TorrentCreatorThread *parent){
parent->sendProgressSignal((int)(i*100./(float)num));
}
void TorrentCreatorThread::sendProgressSignal(int progress) {
emit updateProgress(progress);
}
void TorrentCreatorThread::run() {
emit updateProgress(0);
QString creator_str("qBittorrent "VERSION);
try {
file_storage fs;
// Adding files to the torrent
libtorrent::add_files(fs, input_path.toUtf8().constData(), file_filter);
if(abort) return;
create_torrent t(fs, piece_size);
// Add url seeds
foreach(const QString &seed, url_seeds){
t.add_url_seed(seed.trimmed().toStdString());
}
foreach(const QString &tracker, trackers) {
t.add_tracker(tracker.trimmed().toStdString());
}
if(abort) return;
// calculate the hash for all pieces
const QString parent_path = misc::branchPath(input_path);
set_piece_hashes(t, parent_path.toUtf8().constData(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
// Set qBittorrent as creator and add user comment to
// torrent_info structure
t.set_creator(creator_str.toUtf8().constData());
t.set_comment(comment.toUtf8().constData());
// Is private ?
t.set_priv(is_private);
if(abort) return;
// create the torrent and print it to out
qDebug("Saving to %s", qPrintable(save_path));
std::vector<char> torrent;
bencode(back_inserter(torrent), t.generate());
QFile outfile(save_path);
if(!torrent.empty() && outfile.open(QIODevice::WriteOnly)) {
outfile.write(&torrent[0], torrent.size());
outfile.close();
emit updateProgress(100);
emit creationSuccess(save_path, parent_path);
} else {
throw std::exception();
}
} catch (std::exception& e){
emit creationFailure(QString::fromLocal8Bit(e.what()));
}
}

View File

@@ -0,0 +1,73 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTCREATORTHREAD_H
#define TORRENTCREATORTHREAD_H
#include <QThread>
#include <QStringList>
#include <QDialog>
class TorrentCreatorThread : public QThread {
Q_OBJECT
public:
TorrentCreatorThread(QDialog *_parent) {
parent = _parent;
}
~TorrentCreatorThread() {
abort = true;
wait();
}
void create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size);
void sendProgressSignal(int progress);
void abortCreation() { abort = true; }
protected:
void run();
signals:
void creationFailure(QString msg);
void creationSuccess(QString path, QString branch_path);
void updateProgress(int progress);
private:
QString input_path;
QString save_path;
QStringList trackers;
QStringList url_seeds;
QString comment;
bool is_private;
int piece_size;
bool abort;
QDialog *parent;
};
#endif // TORRENTCREATORTHREAD_H