Browse Source

- Fixed torrent creation (closes #402025)

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
c4aa23c86b
  1. 17
      src/createtorrent_imp.cpp
  2. 3
      src/createtorrent_imp.h

17
src/createtorrent_imp.cpp

@ -184,7 +184,6 @@ void createtorrent::on_createButton_clicked(){ @@ -184,7 +184,6 @@ void createtorrent::on_createButton_clicked(){
void createtorrent::handleCreationFailure(QString msg) {
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg));
hide();
}
void createtorrent::handleCreationSuccess(QString path, const char* branch_path) {
@ -205,7 +204,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path) @@ -205,7 +204,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path)
emit torrent_to_seed(path);
}
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
hide();
close();
}
void createtorrent::updateProgressBar(int progress) {
@ -228,8 +227,12 @@ void torrentCreatorThread::create(QString _input_path, QString _save_path, QStri @@ -228,8 +227,12 @@ void torrentCreatorThread::create(QString _input_path, QString _save_path, QStri
start();
}
void sendProgressUpdateSignal(int i, int num, QDialog *parent){
((createtorrent*)parent)->updateProgressBar((int)(i*100./(float)num));
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() {
@ -254,15 +257,13 @@ void torrentCreatorThread::run() { @@ -254,15 +257,13 @@ void torrentCreatorThread::run() {
}
if(abort) return;
// calculate the hash for all pieces
set_piece_hashes(t, full_path.branch_path(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), parent));
set_piece_hashes(t, full_path.branch_path(), 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);
t.set_comment((const char*)comment.toLocal8Bit());
// Is private ?
if(is_private){
t.set_priv(true);
}
t.set_prive(is_private);
if(abort) return;
// create the torrent and print it to out
ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary);

3
src/createtorrent_imp.h

@ -57,6 +57,7 @@ class torrentCreatorThread : public QThread { @@ -57,6 +57,7 @@ class torrentCreatorThread : public QThread {
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);
protected:
void run();
@ -64,6 +65,8 @@ class torrentCreatorThread : public QThread { @@ -64,6 +65,8 @@ class torrentCreatorThread : public QThread {
signals:
void creationFailure(QString msg);
void creationSuccess(QString path, const char* branch_path);
signals:
void updateProgress(int progress);
};

Loading…
Cancel
Save