Browse Source

Add source field in Torrent creator. Closes #7965.

This field is often used for cross-seeding between (private) trackers.
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
8dcf326576
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 10
      src/base/bittorrent/torrentcreatorthread.cpp
  2. 1
      src/base/bittorrent/torrentcreatorthread.h
  3. 7
      src/gui/torrentcreatordlg.cpp
  4. 1
      src/gui/torrentcreatordlg.h
  5. 10
      src/gui/torrentcreatordlg.ui

10
src/base/bittorrent/torrentcreatorthread.cpp

@ -124,6 +124,14 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return; if (isInterruptionRequested()) return;
libt::entry entry = newTorrent.generate();
// add source field
if (!m_params.source.isEmpty())
entry["info"]["source"] = m_params.source.toStdString();
if (isInterruptionRequested()) return;
// create the torrent // create the torrent
std::ofstream outfile( std::ofstream outfile(
#ifdef _MSC_VER #ifdef _MSC_VER
@ -137,7 +145,7 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return; if (isInterruptionRequested()) return;
libt::bencode(std::ostream_iterator<char>(outfile), newTorrent.generate()); libt::bencode(std::ostream_iterator<char>(outfile), entry);
outfile.close(); outfile.close();
emit updateProgress(100); emit updateProgress(100);

1
src/base/bittorrent/torrentcreatorthread.h

@ -43,6 +43,7 @@ namespace BitTorrent
QString inputPath; QString inputPath;
QString savePath; QString savePath;
QString comment; QString comment;
QString source;
QStringList trackers; QStringList trackers;
QStringList urlSeeds; QStringList urlSeeds;
}; };

7
src/gui/torrentcreatordlg.cpp

@ -60,6 +60,7 @@ TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent, const QString &defaultPath
, m_storeWebSeedList(SETTINGS_KEY("WebSeedList")) , m_storeWebSeedList(SETTINGS_KEY("WebSeedList"))
, m_storeComments(SETTINGS_KEY("Comments")) , m_storeComments(SETTINGS_KEY("Comments"))
, m_storeLastSavePath(SETTINGS_KEY("LastSavePath"), QDir::homePath()) , m_storeLastSavePath(SETTINGS_KEY("LastSavePath"), QDir::homePath())
, m_storeSource(SETTINGS_KEY("Source"))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -165,9 +166,11 @@ void TorrentCreatorDlg::onCreateButtonClicked()
.replace(QRegularExpression("\n\n[\n]+"), "\n\n").split('\n'); .replace(QRegularExpression("\n\n[\n]+"), "\n\n").split('\n');
const QStringList urlSeeds = m_ui->URLSeedsList->toPlainText().split('\n', QString::SkipEmptyParts); const QStringList urlSeeds = m_ui->URLSeedsList->toPlainText().split('\n', QString::SkipEmptyParts);
const QString comment = m_ui->txtComment->toPlainText(); const QString comment = m_ui->txtComment->toPlainText();
const QString source = m_ui->lineEditSource->text();
// run the creator thread // run the creator thread
m_creatorThread->create({ m_ui->checkPrivate->isChecked(), getPieceSize(), input, destination, comment, trackers, urlSeeds }); m_creatorThread->create({ m_ui->checkPrivate->isChecked(), getPieceSize()
, input, destination, comment, source, trackers, urlSeeds });
} }
void TorrentCreatorDlg::handleCreationFailure(const QString &msg) void TorrentCreatorDlg::handleCreationFailure(const QString &msg)
@ -241,6 +244,7 @@ void TorrentCreatorDlg::saveSettings()
m_storeTrackerList = m_ui->trackersList->toPlainText(); m_storeTrackerList = m_ui->trackersList->toPlainText();
m_storeWebSeedList = m_ui->URLSeedsList->toPlainText(); m_storeWebSeedList = m_ui->URLSeedsList->toPlainText();
m_storeComments = m_ui->txtComment->toPlainText(); m_storeComments = m_ui->txtComment->toPlainText();
m_storeSource = m_ui->lineEditSource->text();
m_storeDialogSize = size(); m_storeDialogSize = size();
} }
@ -258,6 +262,7 @@ void TorrentCreatorDlg::loadSettings()
m_ui->trackersList->setPlainText(m_storeTrackerList); m_ui->trackersList->setPlainText(m_storeTrackerList);
m_ui->URLSeedsList->setPlainText(m_storeWebSeedList); m_ui->URLSeedsList->setPlainText(m_storeWebSeedList);
m_ui->txtComment->setPlainText(m_storeComments); m_ui->txtComment->setPlainText(m_storeComments);
m_ui->lineEditSource->setText(m_storeSource);
if (m_storeDialogSize.value().isValid()) if (m_storeDialogSize.value().isValid())
resize(m_storeDialogSize); resize(m_storeDialogSize);

1
src/gui/torrentcreatordlg.h

@ -85,6 +85,7 @@ private:
CachedSettingValue<QString> m_storeWebSeedList; CachedSettingValue<QString> m_storeWebSeedList;
CachedSettingValue<QString> m_storeComments; CachedSettingValue<QString> m_storeComments;
CachedSettingValue<QString> m_storeLastSavePath; CachedSettingValue<QString> m_storeLastSavePath;
CachedSettingValue<QString> m_storeSource;
}; };
#endif #endif

10
src/gui/torrentcreatordlg.ui

@ -273,6 +273,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="labelSource">
<property name="text">
<string>Source:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditSource"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save