Browse Source

-FEATURE: Url seeds are now displayed in torrent properties and are editable

- Broke compatibility with Qt4.2. Will fix this a bit later (in the meantime, edit properties.ui)
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
9cbab8d63e
  1. 1
      Changelog
  2. 2
      TODO
  3. 7
      src/GUI.cpp
  4. 1
      src/GUI.h
  5. 24
      src/bittorrent.cpp
  6. 2
      src/bittorrent.h
  7. 410
      src/properties.ui
  8. 118
      src/properties_imp.cpp
  9. 6
      src/properties_imp.h

1
Changelog

@ -27,6 +27,7 @@
- FEATURE: Improved a lot downloading from urls (using libcommoncpp2 instead of libcurl) - FEATURE: Improved a lot downloading from urls (using libcommoncpp2 instead of libcurl)
- FEATURE: A search request can now be terminated by another - FEATURE: A search request can now be terminated by another
- FEATURE: User is now warned when fast resume data was rejected - FEATURE: User is now warned when fast resume data was rejected
- FEATURE: Url seeds are now displayed in torrent properties and are editable
- I18N: Added Hungarian translation - I18N: Added Hungarian translation
- BUGFIX: Progress of paused torrents is now correct on restart - BUGFIX: Progress of paused torrents is now correct on restart
- BUGFIX: Progress column gets sorted on restart it is was during last execution - BUGFIX: Progress column gets sorted on restart it is was during last execution

2
TODO

@ -31,7 +31,6 @@
// in v1.0.0 (partial) - WIP // in v1.0.0 (partial) - WIP
- Check storage st creation + hasher in torrent creation - Check storage st creation + hasher in torrent creation
- test IPv6 support (How? Who uses IPv6?) - test IPv6 support (How? Who uses IPv6?)
- Display Url seeds in torrent properties and allow to edit them
- Sorting in Download Status column should be smarter than just an alphabetical sort - Sorting in Download Status column should be smarter than just an alphabetical sort
- Allow to scan multiple directories? - Allow to scan multiple directories?
- Fix all (or almost all) opened bugs in bug tracker - Fix all (or almost all) opened bugs in bug tracker
@ -43,6 +42,7 @@
- Windows port (Chris - Peerkoel) - Windows port (Chris - Peerkoel)
- Translations update - Translations update
- Optimize and cleanup code - Optimize and cleanup code
- Improve trackers edition code
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :
- upload/download limit per torrent - upload/download limit per torrent
- double free or corruption on exit - double free or corruption on exit

7
src/GUI.cpp

@ -147,6 +147,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString))); connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString))); connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
connect(BTSession, SIGNAL(aboutToDownloadFromUrl(QString)), this, SLOT(displayDownloadingUrlInfos(QString))); connect(BTSession, SIGNAL(aboutToDownloadFromUrl(QString)), this, SLOT(displayDownloadingUrlInfos(QString)));
connect(BTSession, SIGNAL(urlSeedProblem(QString, QString)), this, SLOT(addUrlSeedError(QString, QString)));
// creating options // creating options
options = new options_imp(this); options = new options_imp(this);
connect(options, SIGNAL(status_changed(QString, bool)), this, SLOT(OptionsSaved(QString, bool))); connect(options, SIGNAL(status_changed(QString, bool)), this, SLOT(OptionsSaved(QString, bool)));
@ -324,7 +325,11 @@ void GUI::setInfoBar(QString info, QString color){
} }
void GUI::addFastResumeRejectedAlert(QString name){ void GUI::addFastResumeRejectedAlert(QString name){
setInfoBar(tr("Fast resume data was rejected for torrent %1, checking again...").arg(name)); setInfoBar(tr("Fast resume data was rejected for torrent %1, checking again...").arg(name), "red");
}
void GUI::addUrlSeedError(QString url, QString msg){
setInfoBar(tr("Url seed lookup failed for url: %1, message: %2").arg(url).arg(msg), "red");
} }
void GUI::balloonClicked(){ void GUI::balloonClicked(){

1
src/GUI.h

@ -190,6 +190,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void setTabText(int index, QString text); void setTabText(int index, QString text);
void updateFileSize(QString hash); void updateFileSize(QString hash);
void sortProgressColumnDelayed(); void sortProgressColumnDelayed();
void addUrlSeedError(QString url, QString msg);
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);

24
src/bittorrent.cpp

@ -163,6 +163,7 @@ void bittorrent::deleteTorrent(QString hash, bool permanent){
torrentBackup.remove(hash+".trackers"); torrentBackup.remove(hash+".trackers");
torrentBackup.remove(hash+".speedLimits"); torrentBackup.remove(hash+".speedLimits");
torrentBackup.remove(hash+".ratio"); torrentBackup.remove(hash+".ratio");
torrentBackup.remove(hash+".urlseeds");
// Remove it from ETAs hash tables // Remove it from ETAs hash tables
ETAstats.take(hash); ETAstats.take(hash);
ETAs.take(hash); ETAs.take(hash);
@ -213,6 +214,22 @@ void bittorrent::resumeTorrent(QString hash){
} }
} }
void bittorrent::loadWebSeeds(QString fileHash){
QFile urlseeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".urlseeds");
if(!urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
QByteArray urlseeds_lines = urlseeds_file.readAll();
urlseeds_file.close();
QList<QByteArray> url_seeds = urlseeds_lines.split('\n');
QByteArray url_seed;
torrent_handle h = getTorrentHandle(fileHash);
torrent_info torrentInfo = h.get_torrent_info();
foreach(url_seed, url_seeds){
if(!url_seed.isEmpty())
qDebug("Loading custom url seed: %s", (const char*)url_seed.data());
torrentInfo.add_url_seed(misc::toString((const char*)url_seed.data()));
}
}
// Add a torrent to the bittorrent session // Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, bool onStartup, QString from_url){ void bittorrent::addTorrent(QString path, bool fromScanDir, bool onStartup, QString from_url){
torrent_handle h; torrent_handle h;
@ -311,6 +328,8 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, bool onStartup, QStr
qDebug("Torrent hash is " + hash.toUtf8()); qDebug("Torrent hash is " + hash.toUtf8());
// Load filtered files // Load filtered files
loadFilesPriorities(h); loadFilesPriorities(h);
// Load custom url seeds
loadWebSeeds(hash);
// Load speed limit from hard drive // Load speed limit from hard drive
loadTorrentSpeedLimits(hash); loadTorrentSpeedLimits(hash);
// Load ratio data // Load ratio data
@ -894,6 +913,9 @@ void bittorrent::readAlerts(){
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())){ else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())){
emit fastResumeDataRejected(QString(p->handle.name().c_str())); emit fastResumeDataRejected(QString(p->handle.name().c_str()));
} }
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())){
emit urlSeedProblem(QString(p->url.c_str()), QString(p->msg().c_str()));
}
a = s->pop_alert(); a = s->pop_alert();
} }
} }
@ -951,6 +973,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
loadFilesPriorities(new_h); loadFilesPriorities(new_h);
// Load speed limit from hard drive // Load speed limit from hard drive
loadTorrentSpeedLimits(fileHash); loadTorrentSpeedLimits(fileHash);
// Load custom url seeds
loadWebSeeds(fileHash);
// Load ratio data // Load ratio data
loadDownloadUploadForTorrent(fileHash); loadDownloadUploadForTorrent(fileHash);
// Pause torrent if it was paused last time // Pause torrent if it was paused last time

2
src/bittorrent.h

@ -106,6 +106,7 @@ class bittorrent : public QObject{
void saveDownloadUploadForTorrent(QString hash); void saveDownloadUploadForTorrent(QString hash);
void loadDownloadUploadForTorrent(QString hash); void loadDownloadUploadForTorrent(QString hash);
void HandleDownloadFailure(QString url, QString reason); void HandleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash);
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setMaxConnections(int maxConnec); void setMaxConnections(int maxConnec);
@ -147,6 +148,7 @@ class bittorrent : public QObject{
void peerBlocked(QString); void peerBlocked(QString);
void downloadFromUrlFailure(QString url, QString reason); void downloadFromUrlFailure(QString url, QString reason);
void fastResumeDataRejected(QString name); void fastResumeDataRejected(QString name);
void urlSeedProblem(QString url, QString msg);
}; };

410
src/properties.ui

@ -13,28 +13,46 @@
<string>Torrent Properties</string> <string>Torrent Properties</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QTabWidget" name="torrentContent" > <widget class="QTabWidget" name="torrentContent" >
<property name="currentIndex" > <property name="currentIndex" >
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab" > <widget class="QWidget" name="tab_1" >
<attribute name="title" > <attribute name="title" >
<string>Main infos</string> <string>Main infos</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QLabel" name="fileName" > <widget class="QLabel" name="fileName" >
<property name="maximumSize" > <property name="maximumSize" >
@ -81,28 +99,55 @@
<string>Torrent infos</string> <string>Torrent infos</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="savePath_lbl" > <widget class="QLabel" name="savePath_lbl" >
<property name="minimumSize" > <property name="minimumSize" >
@ -189,12 +234,21 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="save_path" > <widget class="QLabel" name="save_path" >
<property name="minimumSize" > <property name="minimumSize" >
@ -276,9 +330,7 @@
<item> <item>
<widget class="QGroupBox" name="groupBox" > <widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -304,28 +356,55 @@
<string>Current session</string> <string>Current session</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_5" > <widget class="QLabel" name="label_5" >
<property name="font" > <property name="font" >
@ -402,12 +481,21 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="upTotal" > <widget class="QLabel" name="upTotal" >
<property name="text" > <property name="text" >
@ -476,23 +564,30 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3" > <widget class="QWidget" name="tab_2" >
<attribute name="title" > <attribute name="title" >
<string>Trackers</string> <string>Trackers</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBox_2" > <widget class="QGroupBox" name="groupBox_2" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -518,20 +613,38 @@
<string>Tracker</string> <string>Tracker</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_9" > <widget class="QLabel" name="label_9" >
<property name="font" > <property name="font" >
@ -552,18 +665,25 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QListWidget" name="trackersURLS" > <widget class="QListWidget" name="trackersURLS" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -572,12 +692,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -648,12 +777,21 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -724,12 +862,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_10" > <widget class="QLabel" name="label_10" >
<property name="font" > <property name="font" >
@ -759,12 +906,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2" >
<property name="maximumSize" > <property name="maximumSize" >
@ -822,17 +978,118 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2" > <widget class="QWidget" name="tab_3" >
<attribute name="title" >
<string>Url seeds</string>
</attribute>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="webSeeds_lbl" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>The following web seeds are available for this torrent:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWebSeeds" />
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteWS_button" >
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addWS_button" >
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4" >
<attribute name="title" > <attribute name="title" >
<string>Torrent content</string> <string>Torrent content</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4" >
<property name="font" > <property name="font" >
@ -906,12 +1163,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >

118
src/properties_imp.cpp

@ -41,6 +41,8 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
removeTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png"))); removeTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
lowerTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/downarrow.png"))); lowerTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/downarrow.png")));
riseTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/uparrow.png"))); riseTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/uparrow.png")));
addWS_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
deleteWS_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
// Set Properties list model // Set Properties list model
PropListModel = new QStandardItemModel(0,4); PropListModel = new QStandardItemModel(0,4);
@ -61,6 +63,8 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
connect(actionNormal, SIGNAL(triggered()), this, SLOT(normalSelection())); connect(actionNormal, SIGNAL(triggered()), this, SLOT(normalSelection()));
connect(actionHigh, SIGNAL(triggered()), this, SLOT(highSelection())); connect(actionHigh, SIGNAL(triggered()), this, SLOT(highSelection()));
connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection())); connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection()));
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
// get Infos from torrent handle // get Infos from torrent handle
fileHash = QString(misc::toString(h.info_hash()).c_str()); fileHash = QString(misc::toString(h.info_hash()).c_str());
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
@ -112,6 +116,9 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
PropListModel->setData(PropListModel->index(row, PROGRESS), QVariant((double)fp[i])); PropListModel->setData(PropListModel->index(row, PROGRESS), QVariant((double)fp[i]));
} }
loadPiecesPriorities(); loadPiecesPriorities();
// List web seeds
loadWebSeedsFromFile();
loadWebSeeds();
// Incremental download // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental")){
incrementalDownload->setChecked(true); incrementalDownload->setChecked(true);
@ -130,6 +137,27 @@ properties::~properties(){
delete PropListModel; delete PropListModel;
} }
void properties::loadWebSeeds(){
QString url_seed;
torrent_info torrentInfo = h.get_torrent_info();
std::vector<std::string> url_seeds = torrentInfo.url_seeds();
unsigned int nbSeeds = url_seeds.size();
// Clear url seeds list
listWebSeeds->clear();
// Add hard coded url seeds
for(unsigned int i=0; i<nbSeeds; ++i){
url_seed = QString(url_seeds[i].c_str());
if(manualUrlSeeds.indexOf(url_seed) == -1)
qDebug("Added hard-coded url seed to list: %s", (const char*)url_seed.toUtf8());
listWebSeeds->addItem(url_seed);
}
// Add manually added url seeds
foreach(url_seed, manualUrlSeeds){
listWebSeeds->addItem(url_seed);
qDebug("Added custom url seed to list: %s", (const char*)url_seed.toUtf8());
}
}
void properties::loadPiecesPriorities(){ void properties::loadPiecesPriorities(){
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
unsigned int nbFiles = torrentInfo.num_files(); unsigned int nbFiles = torrentInfo.num_files();
@ -238,6 +266,28 @@ void properties::loadTrackers(){
} }
} }
void properties::askWebSeed(){
bool ok;
// Ask user for a new url seed
QString url_seed = QInputDialog::getText(this, tr("New url seed"),
tr("New url seed:"), QLineEdit::Normal,
"http://www.", &ok);
if(!ok) return;
torrent_info torrentInfo = h.get_torrent_info();
qDebug("Adding %s web seed", (const char*)url_seed.toUtf8());
if(manualUrlSeeds.indexOf(url_seed) != -1) {
QMessageBox::warning(this, tr("qBittorrent"),
tr("This url seed is already in the list."),
QMessageBox::Ok);
return;
}
manualUrlSeeds << url_seed;
torrentInfo.add_url_seed(url_seed.toStdString());
saveWebSeeds();
// Refresh the seeds list
loadWebSeeds();
}
// Ask the user for a new tracker // Ask the user for a new tracker
// and add it to the download list // and add it to the download list
// if it is not already in it // if it is not already in it
@ -259,18 +309,44 @@ void properties::askForTracker(){
loadTrackers(); loadTrackers();
} }
void properties::deleteSelectedUrlSeeds(){
QList<QListWidgetItem *> selectedItems;
selectedItems = listWebSeeds->selectedItems();
QListWidgetItem *item;
bool error = false;
foreach(item, selectedItems){
QString url_seed = item->text();
int index = manualUrlSeeds.indexOf(url_seed);
if(index != -1){
manualUrlSeeds.removeAt(index);
qDebug("Removed an url seeds from manualUrlSeeds list");
}else{
error = true;
}
}
// Save them to disk
saveWebSeeds();
// Refresh list
loadWebSeeds();
if(error){
QMessageBox::warning(this, tr("qBittorrent"),
tr("Hard-coded url seeds cannot be deleted."),
QMessageBox::Ok);
}
}
void properties::deleteSelectedTrackers(){ void properties::deleteSelectedTrackers(){
std::vector<announce_entry> trackers = h.trackers(); std::vector<announce_entry> trackers = h.trackers();
QList<QListWidgetItem *> selectedItems; QList<QListWidgetItem *> selectedItems;
selectedItems = trackersURLS->selectedItems(); selectedItems = trackersURLS->selectedItems();
QListWidgetItem *item; QListWidgetItem *item;
unsigned int nbTrackers = trackers.size(); unsigned int nbTrackers = trackers.size();
if(nbTrackers == (unsigned int) selectedItems.size()){ if(nbTrackers == (unsigned int) selectedItems.size()){
QMessageBox::warning(this, tr("qBittorrent"), QMessageBox::warning(this, tr("qBittorrent"),
tr("Trackers list can't be empty."), tr("Trackers list can't be empty."),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
foreach(item, selectedItems){ foreach(item, selectedItems){
QString url = item->text(); QString url = item->text();
for(unsigned int i=0; i<nbTrackers; ++i){ for(unsigned int i=0; i<nbTrackers; ++i){
@ -401,6 +477,34 @@ void properties::on_okButton_clicked(){
close(); close();
} }
void properties::loadWebSeedsFromFile(){
QFile urlseeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".urlseeds");
if(!urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
QByteArray urlseeds_lines = urlseeds_file.readAll();
urlseeds_file.close();
QList<QByteArray> url_seeds = urlseeds_lines.split('\n');
manualUrlSeeds.clear();
QByteArray url_seed;
foreach(url_seed, url_seeds){
if(!url_seed.isEmpty())
manualUrlSeeds << url_seed;
}
}
void properties::saveWebSeeds(){
QFile urlseeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".urlseeds");
if(!urlseeds_file.open(QIODevice::WriteOnly | QIODevice::Text)){
std::cerr << "Error: Could not save url seeds\n";
return;
}
QString url_seed;
foreach(url_seed, manualUrlSeeds){
urlseeds_file.write(QByteArray((const char*)(url_seed+"\n").toUtf8()));
}
urlseeds_file.close();
qDebug("url seeds were saved");
}
void properties::savePiecesPriorities(){ void properties::savePiecesPriorities(){
if(!changedFilteredfiles) return; if(!changedFilteredfiles) return;
qDebug("Saving pieces priorities"); qDebug("Saving pieces priorities");

6
src/properties_imp.h

@ -43,6 +43,7 @@ class properties : public QDialog, private Ui::properties{
bool has_filtered_files; bool has_filtered_files;
bool changedFilteredfiles; bool changedFilteredfiles;
bittorrent *BTSession; bittorrent *BTSession;
QStringList manualUrlSeeds;
protected slots: protected slots:
void on_okButton_clicked(); void on_okButton_clicked();
@ -62,6 +63,11 @@ class properties : public QDialog, private Ui::properties{
void normalSelection(); void normalSelection();
void highSelection(); void highSelection();
void maximumSelection(); void maximumSelection();
void loadWebSeeds();
void askWebSeed();
void saveWebSeeds();
void loadWebSeedsFromFile();
void deleteSelectedUrlSeeds();
signals: signals:
void filteredFilesChanged(QString fileHash); void filteredFilesChanged(QString fileHash);

Loading…
Cancel
Save