mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 23:17:21 -06:00
Rewrite code for returning information about torrents as JSON (Web UI)
- The new code is simpler, cleaner and more efficient
This commit is contained in:
@@ -89,7 +89,7 @@ void HttpServer::resetNbFailedAttemptsForIp(const QString& ip) {
|
||||
m_clientFailedAttempts.remove(ip);
|
||||
}
|
||||
|
||||
HttpServer::HttpServer(int msec, QObject* parent) : QTcpServer(parent),
|
||||
HttpServer::HttpServer(QObject* parent) : QTcpServer(parent),
|
||||
m_eventManager(new EventManager(this)) {
|
||||
|
||||
const Preferences pref;
|
||||
@@ -109,23 +109,6 @@ HttpServer::HttpServer(int msec, QObject* parent) : QTcpServer(parent),
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add torrents
|
||||
std::vector<torrent_handle> torrents = QBtSession::instance()->getTorrents();
|
||||
std::vector<torrent_handle>::iterator torrentIT;
|
||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||
if (h.is_valid())
|
||||
m_eventManager->addedTorrent(h);
|
||||
}
|
||||
|
||||
//connect QBtSession::instance() to manager
|
||||
connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), m_eventManager, SLOT(addedTorrent(QTorrentHandle)));
|
||||
connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), m_eventManager, SLOT(deletedTorrent(QString)));
|
||||
|
||||
//set timer
|
||||
connect(&m_timer, SIGNAL(timeout()), SLOT(onTimer()));
|
||||
m_timer.start(msec);
|
||||
|
||||
// Additional translations for Web UI
|
||||
QString a = tr("File");
|
||||
a = tr("Edit");
|
||||
@@ -214,16 +197,6 @@ void HttpServer::handleNewConnection(QTcpSocket *socket)
|
||||
connect(connection, SIGNAL(resumeAllTorrents()), QBtSession::instance(), SLOT(resumeAllTorrents()));
|
||||
}
|
||||
|
||||
void HttpServer::onTimer() {
|
||||
std::vector<torrent_handle> torrents = QBtSession::instance()->getTorrents();
|
||||
std::vector<torrent_handle>::iterator torrentIT;
|
||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||
if (h.is_valid())
|
||||
m_eventManager->modifiedTorrent(h);
|
||||
}
|
||||
}
|
||||
|
||||
QString HttpServer::generateNonce() const {
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
md5.addData(QTime::currentTime().toString("hhmmsszzz").toLocal8Bit());
|
||||
|
||||
Reference in New Issue
Block a user