Example #1
0
void TorrentImportDlg::importTorrent()
{
  qDebug() << Q_FUNC_INFO << "ENTER";
  TorrentImportDlg dlg;
  if (dlg.exec()) {
    qDebug() << "Loading the torrent file...";
    boost::intrusive_ptr<libtorrent::torrent_info> t = dlg.torrent();
    if (!t->is_valid())
      return;
    QString torrent_path = dlg.getTorrentPath();
    QString content_path = dlg.getContentPath();
    if (torrent_path.isEmpty() || content_path.isEmpty() || !QFile(torrent_path).exists()) {
      qWarning() << "Incorrect input, aborting." << torrent_path << content_path;
      return;
    }
    const QString hash = misc::toQString(t->info_hash());
    qDebug() << "Torrent hash is" << hash;
    TorrentTempData::setSavePath(hash, content_path);
    TorrentTempData::setSeedingMode(hash, dlg.skipFileChecking());
    qDebug("Adding the torrent to the session...");
    QBtSession::instance()->addTorrent(torrent_path);
    // Remember the last opened folder
    QIniSettings settings;
    settings.setValue(QString::fromUtf8("MainWindowLastDir"), torrent_path);
    settings.setValue("TorrentImport/LastContentDir", content_path);
    return;
  }
  qDebug() << Q_FUNC_INFO << "EXIT";
  return;
}
void TorrentImportDlg::importTorrent()
{
    qDebug() << Q_FUNC_INFO << "ENTER";
    TorrentImportDlg dlg;
    if (dlg.exec()) {
        qDebug() << "Loading the torrent file...";
        boost::intrusive_ptr<libtorrent::torrent_info> t = dlg.torrent();
        if (!t->is_valid())
            return;
        QString torrent_path = dlg.getTorrentPath();
        QString content_path = dlg.getContentPath();
        if (torrent_path.isEmpty() || content_path.isEmpty() || !QFile(torrent_path).exists()) {
            qWarning() << "Incorrect input, aborting." << torrent_path << content_path;
            return;
        }
        const QString hash = misc::toQString(t->info_hash());
        qDebug() << "Torrent hash is" << hash;
        TorrentTempData::setSavePath(hash, content_path);
        TorrentTempData::setSeedingMode(hash, dlg.skipFileChecking());
        qDebug("Adding the torrent to the session...");
        QBtSession::instance()->addTorrent(torrent_path, false, QString(), false, true);
        // Remember the last opened folder
        Preferences* const pref = Preferences::instance();
        pref->setMainLastDir(fsutils::fromNativePath(torrent_path));
        pref->setTorImportLastContentDir(fsutils::fromNativePath(content_path));
        return;
    }
    qDebug() << Q_FUNC_INFO << "EXIT";
    return;
}