// GET param: // - rid (int): last response id void WebApplication::action_sync_maindata() { CHECK_URI(0); print(btjson::getSyncMainData(request().gets["rid"].toInt(), session()->syncMainDataLastResponse, session()->syncMainDataLastAcceptedResponse), Http::CONTENT_TYPE_JSON); }
// GET param: // - hash (string): torrent hash // - rid (int): last response id void WebApplication::action_sync_torrent_peers() { CHECK_URI(0); print(btjson::getSyncTorrentPeersData(request().gets["rid"].toInt(), request().gets["hash"], session()->syncTorrentPeersLastResponse, session()->syncTorrentPeersLastAcceptedResponse), Http::CONTENT_TYPE_JSON); }
void WebApplication::action_command_shutdown() { qDebug() << "Shutdown request from Web UI"; CHECK_URI(0); // Special case handling for shutdown, we // need to reply to the Web UI before // actually shutting down. QTimer::singleShot(100, qApp, SLOT(quit())); }
// GET params: // - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive // - category (string): torrent category for filtering by it (empty string means "uncategorized"; no "category" param presented means "any category") // - sort (string): name of column for sorting by its value // - reverse (bool): enable reverse sorting // - limit (int): set limit number of torrents returned (if greater than 0, otherwise - unlimited) // - offset (int): set offset (if less than 0 - offset from end) void WebApplication::action_query_torrents() { CHECK_URI(0); const QStringMap& gets = request().gets; print(btjson::getTorrents( gets["filter"], gets["category"], gets["sort"], gets["reverse"] == "true", gets["limit"].toInt(), gets["offset"].toInt() ), Http::CONTENT_TYPE_JSON); }
void WebApplication::action_command_download() { CHECK_URI(0); CHECK_PARAMETERS("urls"); QString urls = request().posts["urls"]; QStringList list = urls.split('\n'); foreach (QString url, list) { url = url.trimmed(); if (!url.isEmpty()) { if (url.startsWith("bc://bt/", Qt::CaseInsensitive)) { qDebug("Converting bc link to magnet link"); url = Utils::Misc::bcLinkToMagnet(url); } BitTorrent::Session::instance()->addTorrent(url); } }
void WebApplication::action_command_download() { CHECK_URI(0); QString urls = request().posts["urls"]; QStringList list = urls.split('\n'); QString savepath = request().posts["savepath"]; QString category = request().posts["category"]; QString cookie = request().posts["cookie"]; QList<QNetworkCookie> cookies; if (!cookie.isEmpty()) { QStringList cookiesStr = cookie.split("; "); foreach (QString cookieStr, cookiesStr) { cookieStr = cookieStr.trimmed(); int index = cookieStr.indexOf('='); if (index > 1) { QByteArray name = cookieStr.left(index).toLatin1(); QByteArray value = cookieStr.right(cookieStr.length() - index - 1).toLatin1(); QNetworkCookie c(name, value); cookies << c; } }
void WebApplication::action_version_qbittorrent() { CHECK_URI(0); print(QString(VERSION), Http::CONTENT_TYPE_TXT); }
void WebApplication::action_version_api_min() { CHECK_URI(0); print(QString::number(API_VERSION_MIN), Http::CONTENT_TYPE_TXT); }
void WebApplication::action_query_propertiesFiles() { CHECK_URI(1); print(btjson::getFilesForTorrent(args_.front()), Http::CONTENT_TYPE_JSON); }
void WebApplication::action_query_transferInfo() { CHECK_URI(0); print(btjson::getTransferInfo(), Http::CONTENT_TYPE_JSON); }
void WebApplication::action_query_preferences() { CHECK_URI(0); print(prefjson::getPreferences(), Http::CONTENT_TYPE_JSON); }
void WebApplication::action_public_logout() { CHECK_URI(0); sessionEnd(); }