Browse Source

Fixed downloadFromUrl

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
b1ed521d6b
  1. 22
      qBittorrent.kdevelop
  2. 2
      src/GUI.cpp
  3. 11
      src/bittorrent.cpp
  4. 2
      src/downloadFromURLImp.h

22
qBittorrent.kdevelop

@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
<ignoreparts/>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<defaultencoding></defaultencoding>
<description/>
<defaultencoding/>
<versioncontrol>kdevsubversion</versioncontrol>
</general>
<kdevfileview>
@ -72,11 +72,11 @@ @@ -72,11 +72,11 @@
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell></dbgshell>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<dbgshell/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
@ -154,8 +154,8 @@ @@ -154,8 +154,8 @@
<run>
<directoryradio>executable</directoryradio>
<mainprogram>/home/chris/qbittorrent_svn/trunk/src/qbittorrent</mainprogram>
<programargs></programargs>
<globaldebugarguments></globaldebugarguments>
<programargs/>
<globaldebugarguments/>
<globalcwd>/home/chris/qbittorrent_svn/trunk</globalcwd>
<useglobalprogram>true</useglobalprogram>
<terminal>false</terminal>
@ -169,7 +169,7 @@ @@ -169,7 +169,7 @@
<runmultiplejobs>false</runmultiplejobs>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin></makebin>
<makebin/>
<prio>0</prio>
<envvars/>
</make>
@ -186,7 +186,7 @@ @@ -186,7 +186,7 @@
</filetemplates>
</cppsupportpart>
<ctagspart>
<customArguments></customArguments>
<customArguments/>
<customTagfilePath>/home/chris/qbittorrent_svn/trunk/tags</customTagfilePath>
<activeTagsFiles/>
</ctagspart>

2
src/GUI.cpp

@ -1618,5 +1618,5 @@ void GUI::OptionsSaved(const QString& info, bool deleteOptions){ @@ -1618,5 +1618,5 @@ void GUI::OptionsSaved(const QString& info, bool deleteOptions){
// an url
void GUI::on_actionDownload_from_URL_triggered(){
downloadFromURLDialog = new downloadFromURL(this);
connect(downloadFromURLDialog, SIGNAL(downloadFinished(QString, QString, int, QString)), &BTSession, SLOT(processDownloadedFile(QString, QString, int, QString)));
connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), &BTSession, SLOT(downloadFromURLList(const QStringList&)));
}

11
src/bittorrent.cpp

@ -408,7 +408,7 @@ void bittorrent::disableDHT(){ @@ -408,7 +408,7 @@ void bittorrent::disableDHT(){
// and ask torrent_handle to consider them
void bittorrent::loadFilteredFiles(torrent_handle &h){
torrent_info torrentInfo = h.get_torrent_info();
unsigned int nbTorrents = torrentInfo.num_files();
unsigned int nbFiles = torrentInfo.num_files();
if(!h.is_valid()){
qDebug("/!\\ Error: Invalid handle");
return;
@ -417,20 +417,22 @@ void bittorrent::loadFilteredFiles(torrent_handle &h){ @@ -417,20 +417,22 @@ void bittorrent::loadFilteredFiles(torrent_handle &h){
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".priorities");
// Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug("* Error: Couldn't open priorities file");
return;
}
QByteArray pieces_priorities = pieces_file.readAll();
pieces_file.close();
QList<QByteArray> pieces_priorities_list = pieces_priorities.split('\n');
if((unsigned int)pieces_priorities_list.size() != nbTorrents+1){
std::cerr << "Error: Corrupted pieces file\n";
if((unsigned int)pieces_priorities_list.size() != nbFiles+1){
std::cerr << "* Error: Corrupted priorities file\n";
return;
}
for(unsigned int i=0; i<nbTorrents; ++i){
for(unsigned int i=0; i<nbFiles; ++i){
int priority = pieces_priorities_list.at(i).toInt();
if( priority < 0 || priority > 7){
priority = 1;
}
qDebug("Setting piece piority to %d", priority);
h.piece_priority(i, priority);
}
}
@ -836,6 +838,7 @@ void bittorrent::processDownloadedFile(const QString& url, const QString& file_p @@ -836,6 +838,7 @@ void bittorrent::processDownloadedFile(const QString& url, const QString& file_p
void bittorrent::downloadFromURLList(const QStringList& url_list){
QString url;
qDebug("DownloadFromUrlList");
foreach(url, url_list){
downloadFromUrl(url);
}

2
src/downloadFromURLImp.h

@ -37,7 +37,6 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -37,7 +37,6 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
icon_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/url.png")));
connect(this, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), parent, SLOT(downloadFromURLList(const QStringList&)));
show();
}
@ -65,6 +64,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -65,6 +64,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
return;
}
emit urlsReadyToBeDownloaded(url_list_cleaned);
qDebug("Emitted urlsReadytobedownloaded signal");
close();
}

Loading…
Cancel
Save