void DataCheckerJob::start() { registerWithTracker(); DataChecker* dc = 0; const TorrentStats & stats = torrent()->getStats(); if (stats.multi_file_torrent) dc = new MultiDataChecker(from, to); else dc = new SingleDataChecker(from, to); connect(dc,SIGNAL(progress(quint32,quint32)), this,SLOT(progress(quint32,quint32)),Qt::QueuedConnection); connect(dc,SIGNAL(status(quint32,quint32,quint32,quint32)), this,SLOT(status(quint32,quint32,quint32,quint32)),Qt::QueuedConnection); TorrentControl* tor = torrent(); dcheck_thread = new DataCheckerThread( dc,tor->downloadedChunksBitSet(), stats.output_path,tor->getTorrent(), tor->getTorDir() + "dnd" + bt::DirSeparator()); connect(dcheck_thread,SIGNAL(finished()),this,SLOT(threadFinished()),Qt::QueuedConnection); torrent()->beforeDataCheck(); setTotalAmount(Bytes,to - from + 1); data_checker_slot.add(this); if (!started) infoMessage(this,i18n("Waiting for other data checks to finish")); }
void TorrentListCtrl::OnRetry(wxCommandEvent &/*event*/) { DataType info( GetSelectedData() ); torrent().RemoveTorrentByName( info.name ); RemoveTorrentInfo( info ); torrent().RequestFileByName( info.name ); }
void TorrentOptionsPanel::OnApply( wxCommandEvent& /*unused*/ ) { sett().SetTorrentUploadRate( FromwxString<long>( m_maxUp->GetValue() ) ); sett().SetTorrentDownloadRate( FromwxString<long>( m_maxDown->GetValue() ) ); sett().SetTorrentPort( FromwxString<long>( m_p2pport->GetValue() ) ); sett().SetTorrentMaxConnections( FromwxString<long>( m_maxConnections->GetValue() ) ); sett().SetTorrentThrottledUploadRate( FromwxString<long>( m_gamestart_throttle_up->GetValue() ) ); sett().SetTorrentThrottledDownloadRate( FromwxString<long>( m_gamestart_throttle_down->GetValue() ) ); // if mode == pause selected --> m_gamestart_throttle->GetValue() == 0 sett().SetTorrentSystemSuspendMode( m_gamestart_throttle->GetValue() ); torrent().UpdateSettings(); }
void Cdlg_make_torrent::OnLoadTrackers() { UpdateData(true); CFileDialog dlg(true, "torrent", NULL, OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "Torrents|*.torrent|", this); if (IDOK != dlg.DoModal()) return; Cvirtual_binary d; d.load(static_cast<std::string>(dlg.GetPathName())); Cbt_torrent torrent(d.range()); if (!torrent.valid()) return; m_tracker = torrent.announce().c_str(); m_trackers.Empty(); const Cbt_torrent::t_announces& announces = torrent.announces(); for (Cbt_torrent::t_announces::const_iterator i = announces.begin(); i != announces.end(); i++) { m_trackers += i->c_str(); m_trackers += "\r\n"; } UpdateData(false); }
int QalfHandler::storeTorrent(QString &moderatorEmail, QString &signature, QString &title, QString &authors, QString &license, QString &keywords, QString &category, QByteArray &torrentData) { // loading torrent in torrent structure QalfTorrent torrent(torrentData) ; // getting hash and key QString hash = torrent.hashToStr() ; QalfDb * db = QalfDb::getDbObject() ; QHash<QString,QString> keyInfo = db->getKeyInfo(moderatorEmail) ; if(!keyInfo.isEmpty() && keyInfo["trusted"] == "1") { // verifying signature QalfCrypto crypto ; qDebug() << "keyInfo" << keyInfo["key"] ; bool verification = crypto.verify(signature, hash, keyInfo["key"]) ; if(verification) { // storing on hd QalfConfig * config = QalfConfig::getConfigObject() ; QString torrentDirProp("torrentDir") ; QString torrentFilename = config->getProperty(torrentDirProp)+QString(QDir::separator())+hash+".torrent" ; QFile file(torrentFilename) ; if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return CANNOTSTORETORRENT; QTextStream out(&file); out << torrentData ; // storing meta information in db return NO_ERROR ; } else { return BADSIGNATURE ; } } else { return USERNOTTRUSTED ; } }
void DataCheckerJob::threadFinished() { if (!killed) { DataChecker* dc = dcheck_thread->getDataChecker(); torrent()->afterDataCheck(this,dc->getResult()); if (!dcheck_thread->getError().isEmpty()) { setErrorText(dcheck_thread->getError()); setError(KIO::ERR_UNKNOWN); } else setError(0); } else setError(0); dcheck_thread->deleteLater(); dcheck_thread = 0; if (!killed) // Job::kill already emitted the result emitResult(); release(); }
void TorrentListCtrl::OnCancel(wxCommandEvent &/*event*/) { torrent().RemoveTorrentByName(GetSelectedData().name); RemoveTorrentInfo(GetSelectedData()); }
int mymain(int argc, char** argv) { install_segfault_handler(); Sint16 piece_size = 16; std::string path; std::vector<std::string> webseeds; po::options_description desc("Usage", 80, 40); desc.add_options() ("path,I", po::value<std::string > (&path)->required(), "") ("piece-size,s", po::value<Sint16 > (&piece_size)->default_value(16), "In KiB") ("webseed,w", po::value<std::vector<std::string> > (&webseeds)->required(), "") ("help,h", "produce help message") ; po::positional_options_description pos; pos.add("path", 1); pos.add("webseed", -1); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(desc).positional(pos).run(), vm); if (vm.count("help")) { cout << desc << "\n"; return 1; } try { po::notify(vm); for (int i = 0; i < cubic_coords::NR_OF_FACES; ++i) { std::string face = cubic_coords::face_to_string((cubic_coords::FACE)i); std::string face_path = path + PATHSEPARATOR + face + PATHSEPARATOR; std::string torrent_path = path + PATHSEPARATOR + face + ".torrent"; std::cout << face << " face..." << std::flush; lt::file_storage files; lt::add_files(files, face_path); lt::create_torrent torrent(files, piece_size*1024, -1, lt::create_torrent::merkle); for(std::vector<std::string>::iterator it = webseeds.begin(); it!=webseeds.end(); ++it) { torrent.add_http_seed(*it); } lt::set_piece_hashes(torrent, path); std::ofstream out(torrent_path, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); lt::bencode(std::ostream_iterator<char>(out), torrent.generate()); if (!out.is_open() || !out.good()) { throw file_write_error(torrent_path); } out.close(); std::cout << "done" << std::endl; } } catch (const po::required_option& ex) { std::cout << "Missing option: " << ex.get_option_name() << std::endl; } log::destroy_instance(); return 0; }