2008-05-17 17:23:37 +04:00
|
|
|
/*
|
2009-04-05 22:48:45 +04:00
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
|
|
|
* Contact : chris@qbittorrent.org
|
2008-05-17 17:23:37 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-06-07 12:32:41 +04:00
|
|
|
#include <libtorrent/version.hpp>
|
2008-05-17 17:23:37 +04:00
|
|
|
#include "eventmanager.h"
|
2010-10-09 18:06:35 +04:00
|
|
|
#include "qbtsession.h"
|
2010-03-18 22:25:16 +03:00
|
|
|
#include "scannedfoldersmodel.h"
|
2009-11-23 13:37:55 +03:00
|
|
|
#include "misc.h"
|
2009-11-26 11:10:23 +03:00
|
|
|
#include "preferences.h"
|
2010-01-03 01:20:37 +03:00
|
|
|
//#include "proplistdelegate.h"
|
2009-11-24 11:53:14 +03:00
|
|
|
#include "torrentpersistentdata.h"
|
2008-05-17 17:23:37 +04:00
|
|
|
#include <QDebug>
|
2010-09-25 16:42:19 +04:00
|
|
|
#include <QTranslator>
|
2011-06-05 20:08:30 +04:00
|
|
|
#ifndef QT_NO_OPENSSL
|
|
|
|
#include <QSslCertificate>
|
|
|
|
#include <QSslKey>
|
|
|
|
#endif
|
2008-05-17 17:23:37 +04:00
|
|
|
|
2010-11-23 00:55:32 +03:00
|
|
|
using namespace libtorrent;
|
|
|
|
|
2010-11-14 00:15:52 +03:00
|
|
|
EventManager::EventManager(QObject *parent)
|
|
|
|
: QObject(parent)
|
2008-05-17 17:23:37 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-25 17:33:37 +03:00
|
|
|
QList<QVariantMap> EventManager::getEventList() const {
|
2009-11-19 21:28:30 +03:00
|
|
|
return event_list.values();
|
2008-05-17 17:23:37 +04:00
|
|
|
}
|
|
|
|
|
2009-11-24 14:14:02 +03:00
|
|
|
QList<QVariantMap> EventManager::getPropTrackersInfo(QString hash) const {
|
|
|
|
QList<QVariantMap> trackersInfo;
|
2010-11-14 00:15:52 +03:00
|
|
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
2009-11-24 14:14:02 +03:00
|
|
|
if(h.is_valid()) {
|
2010-11-14 00:15:52 +03:00
|
|
|
QHash<QString, TrackerInfos> trackers_data = QBtSession::instance()->getTrackersInfo(hash);
|
2009-11-24 14:14:02 +03:00
|
|
|
std::vector<announce_entry> vect_trackers = h.trackers();
|
|
|
|
std::vector<announce_entry>::iterator it;
|
|
|
|
for(it = vect_trackers.begin(); it != vect_trackers.end(); it++) {
|
|
|
|
QVariantMap tracker;
|
|
|
|
QString tracker_url = misc::toQString(it->url);
|
|
|
|
tracker["url"] = tracker_url;
|
|
|
|
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
|
|
|
QString error_message = data.last_message.trimmed();
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2009-11-24 14:14:02 +03:00
|
|
|
if(it->verified) {
|
|
|
|
tracker["status"] = tr("Working");
|
|
|
|
} else {
|
|
|
|
if(it->updating && it->fails == 0) {
|
|
|
|
tracker["status"] = tr("Updating...");
|
|
|
|
} else {
|
|
|
|
if(it->fails > 0) {
|
|
|
|
tracker["status"] = tr("Not working");
|
|
|
|
} else {
|
|
|
|
tracker["status"] = tr("Not contacted yet");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if(data.verified) {
|
|
|
|
tracker["status"] = tr("Working");
|
|
|
|
} else {
|
|
|
|
if(data.fail_count > 0)
|
|
|
|
tracker["status"] = tr("Not working");
|
|
|
|
else
|
|
|
|
tracker["status"] = tr("Not contacted yet");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
tracker["num_peers"] = QString::number(trackers_data.value(tracker_url, TrackerInfos(tracker_url)).num_peers);
|
|
|
|
tracker["msg"] = error_message;
|
|
|
|
trackersInfo << tracker;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return trackersInfo;
|
|
|
|
}
|
|
|
|
|
2009-11-24 16:10:17 +03:00
|
|
|
QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
|
|
|
QList<QVariantMap> files;
|
2010-11-14 00:15:52 +03:00
|
|
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
2009-12-05 17:24:45 +03:00
|
|
|
if(!h.is_valid() || !h.has_metadata()) return files;
|
2009-11-24 16:10:17 +03:00
|
|
|
std::vector<int> priorities = h.file_priorities();
|
2009-11-24 22:47:23 +03:00
|
|
|
std::vector<size_type> fp;
|
2009-11-24 16:10:17 +03:00
|
|
|
h.file_progress(fp);
|
2011-04-17 14:29:44 +04:00
|
|
|
for(int i=0; i<h.num_files(); ++i) {
|
2009-11-24 16:10:17 +03:00
|
|
|
QVariantMap file;
|
2011-04-17 14:29:44 +04:00
|
|
|
file["name"] = h.filename_at(i);
|
|
|
|
libtorrent::size_type size = h.filesize_at(i);
|
|
|
|
file["size"] = misc::friendlyUnit((double)size);
|
|
|
|
if(size > 0)
|
|
|
|
file["progress"] = fp[i]/(double)size;
|
2009-11-29 17:34:39 +03:00
|
|
|
else
|
|
|
|
file["progress"] = 1.; // Empty file...
|
2009-11-24 18:38:47 +03:00
|
|
|
file["priority"] = priorities[i];
|
2010-05-24 23:37:56 +04:00
|
|
|
if(i == 0)
|
|
|
|
file["is_seed"] = h.is_seed();
|
2009-11-24 16:10:17 +03:00
|
|
|
files << file;
|
|
|
|
}
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2011-09-29 21:47:51 +04:00
|
|
|
void EventManager::setGlobalPreferences(QVariantMap m) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// UI
|
2010-11-16 23:34:31 +03:00
|
|
|
Preferences pref;
|
2010-09-25 16:42:19 +04:00
|
|
|
if(m.contains("locale")) {
|
|
|
|
QString locale = m["locale"].toString();
|
2010-11-16 23:34:31 +03:00
|
|
|
if(pref.getLocale() != locale) {
|
2010-09-25 16:42:19 +04:00
|
|
|
QTranslator *translator = new QTranslator;
|
|
|
|
if(translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
|
|
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
|
|
|
}else{
|
|
|
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
|
|
|
}
|
|
|
|
qApp->installTranslator(translator);
|
|
|
|
|
2011-09-29 21:47:51 +04:00
|
|
|
pref.setLocale(locale);
|
|
|
|
emit localeChanged(locale);
|
|
|
|
}
|
2010-09-25 16:42:19 +04:00
|
|
|
}
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Downloads
|
|
|
|
if(m.contains("save_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setSavePath(m["save_path"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("temp_path_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setTempPathEnabled(m["temp_path_enabled"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("temp_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setTempPath(m["temp_path"].toString());
|
2010-03-22 21:50:04 +03:00
|
|
|
if(m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
|
2010-06-05 22:59:05 +04:00
|
|
|
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
|
|
|
|
QList<bool> download_at_path;
|
|
|
|
foreach(QVariant var, download_at_path_tmp) {
|
|
|
|
download_at_path << var.toBool();
|
|
|
|
}
|
2010-11-16 23:34:31 +03:00
|
|
|
QStringList old_folders = pref.getScanDirs();
|
2010-03-18 22:25:16 +03:00
|
|
|
QStringList new_folders = m["scan_dirs"].toStringList();
|
2010-03-22 21:50:04 +03:00
|
|
|
if(download_at_path.size() == new_folders.size()) {
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setScanDirs(new_folders);
|
|
|
|
pref.setDownloadInScanDirs(download_at_path);
|
2010-03-22 21:50:04 +03:00
|
|
|
foreach(const QString &old_folder, old_folders) {
|
|
|
|
// Update deleted folders
|
|
|
|
if(!new_folders.contains(old_folder)) {
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->getScanFoldersModel()->removePath(old_folder);
|
2010-03-22 21:50:04 +03:00
|
|
|
}
|
2010-03-18 22:25:16 +03:00
|
|
|
}
|
2010-03-22 21:50:04 +03:00
|
|
|
int i = 0;
|
|
|
|
foreach(const QString &new_folder, new_folders) {
|
2010-06-29 12:44:56 +04:00
|
|
|
qDebug("New watched folder: %s", qPrintable(new_folder));
|
2010-03-22 21:50:04 +03:00
|
|
|
// Update new folders
|
|
|
|
if(!old_folders.contains(new_folder)) {
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
2010-03-22 21:50:04 +03:00
|
|
|
}
|
|
|
|
++i;
|
2010-03-18 22:25:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-31 16:47:57 +03:00
|
|
|
if(m.contains("export_dir"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setExportDir(m["export_dir"].toString());
|
2010-08-19 23:10:46 +04:00
|
|
|
if(m.contains("mail_notification_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
|
2010-08-19 23:10:46 +04:00
|
|
|
if(m.contains("mail_notification_email"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationEmail(m["mail_notification_email"].toString());
|
2010-08-19 23:10:46 +04:00
|
|
|
if(m.contains("mail_notification_smtp"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationSMTP(m["mail_notification_smtp"].toString());
|
2011-06-05 20:08:30 +04:00
|
|
|
if(m.contains("mail_notification_ssl_enabled"))
|
|
|
|
pref.setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool());
|
|
|
|
if(m.contains("mail_notification_auth_enabled"))
|
|
|
|
pref.setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool());
|
|
|
|
if(m.contains("mail_notification_username"))
|
|
|
|
pref.setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
|
|
|
|
if(m.contains("mail_notification_password"))
|
|
|
|
pref.setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
|
2010-08-20 18:02:40 +04:00
|
|
|
if(m.contains("autorun_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setAutoRunEnabled(m["autorun_enabled"].toBool());
|
2010-08-20 18:02:40 +04:00
|
|
|
if(m.contains("autorun_program"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setAutoRunProgram(m["autorun_program"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("preallocate_all"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.preAllocateAllFiles(m["preallocate_all"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("queueing_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setQueueingSystemEnabled(m["queueing_enabled"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_active_downloads"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveDownloads(m["max_active_downloads"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_active_torrents"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveTorrents(m["max_active_torrents"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_active_uploads"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveUploads(m["max_active_uploads"].toInt());
|
2011-09-18 20:34:29 +04:00
|
|
|
if(m.contains("dont_count_slow_torrents"))
|
|
|
|
pref.setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("incomplete_files_ext"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
#endif
|
|
|
|
// Connection
|
|
|
|
if(m.contains("listen_port"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setSessionPort(m["listen_port"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("upnp"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setUPnPEnabled(m["upnp"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("dl_limit"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setGlobalDownloadLimit(m["dl_limit"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("up_limit"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setGlobalUploadLimit(m["up_limit"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_connec"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxConnecs(m["max_connec"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_connec_per_torrent"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("max_uploads_per_torrent"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
|
2011-06-05 20:08:30 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR >= 16
|
|
|
|
if(m.contains("enable_utp"))
|
|
|
|
pref.setuTPEnabled(m["enable_utp"].toBool());
|
|
|
|
if(m.contains("limit_utp_rate"))
|
|
|
|
pref.setuTPRateLimited(m["limit_utp_rate"].toBool());
|
|
|
|
#endif
|
|
|
|
if(m.contains("limit_tcp_overhead"))
|
|
|
|
pref.includeOverheadInLimits(m["limit_tcp_overhead"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Bittorrent
|
|
|
|
if(m.contains("dht"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setDHTEnabled(m["dht"].toBool());
|
2010-03-22 23:34:12 +03:00
|
|
|
if(m.contains("dhtSameAsBT"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setDHTPortSameAsBT(m["dhtSameAsBT"].toBool());
|
2010-03-22 23:34:12 +03:00
|
|
|
if(m.contains("dht_port"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setDHTPort(m["dht_port"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("pex"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setPeXEnabled(m["pex"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
|
|
|
if(m.contains("lsd"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setLSDEnabled(m["lsd"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("encryption"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setEncryptionSetting(m["encryption"].toInt());
|
2011-09-20 21:15:47 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR >= 16
|
|
|
|
if(m.contains("anonymous_mode"))
|
|
|
|
pref.enableAnonymousMode(m["anonymous_mode"].toBool());
|
|
|
|
#endif
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Proxy
|
|
|
|
if(m.contains("proxy_type"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyType(m["proxy_type"].toInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("proxy_ip"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyIp(m["proxy_ip"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("proxy_port"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyPort(m["proxy_port"].toUInt());
|
2011-05-01 16:00:23 +04:00
|
|
|
if(m.contains("proxy_peer_connections"))
|
|
|
|
pref.setProxyPeerConnections(m["proxy_peer_connections"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("proxy_auth_enabled"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("proxy_username"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyUsername(m["proxy_username"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("proxy_password"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyPassword(m["proxy_password"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// IP Filter
|
|
|
|
if(m.contains("ip_filter_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setFilteringEnabled(m["ip_filter_enabled"].toBool());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("ip_filter_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setFilter(m["ip_filter_path"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Web UI
|
|
|
|
if(m.contains("web_ui_port"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiPort(m["web_ui_port"].toUInt());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("web_ui_username"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiUsername(m["web_ui_username"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(m.contains("web_ui_password"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiPassword(m["web_ui_password"].toString());
|
2011-06-05 20:08:30 +04:00
|
|
|
if(m.contains("bypass_local_auth"))
|
|
|
|
pref.setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
|
|
|
|
if(m.contains("use_https"))
|
|
|
|
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
|
|
|
|
#ifndef QT_NO_OPENSSL
|
|
|
|
if(m.contains("ssl_key")) {
|
|
|
|
QByteArray raw_key = m["ssl_key"].toString().toAscii();
|
|
|
|
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
|
|
|
pref.setWebUiHttpsKey(raw_key);
|
|
|
|
}
|
|
|
|
if(m.contains("ssl_cert")) {
|
|
|
|
QByteArray raw_cert = m["ssl_cert"].toString().toAscii();
|
|
|
|
if (!QSslCertificate(raw_cert).isNull())
|
|
|
|
pref.setWebUiHttpsCertificate(raw_cert);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Dyndns
|
|
|
|
if(m.contains("dyndns_enabled"))
|
|
|
|
pref.setDynDNSEnabled(m["dyndns_enabled"].toBool());
|
|
|
|
if(m.contains("dyndns_service"))
|
|
|
|
pref.setDynDNSService(m["dyndns_service"].toInt());
|
|
|
|
if(m.contains("dyndns_username"))
|
|
|
|
pref.setDynDNSUsername(m["dyndns_username"].toString());
|
|
|
|
if(m.contains("dyndns_password"))
|
|
|
|
pref.setDynDNSPassword(m["dyndns_password"].toString());
|
|
|
|
if(m.contains("dyndns_domain"))
|
|
|
|
pref.setDynDomainName(m["dyndns_domain"].toString());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Reload preferences
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->configureSession();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
}
|
|
|
|
|
2009-11-26 11:10:23 +03:00
|
|
|
QVariantMap EventManager::getGlobalPreferences() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
const Preferences pref;
|
2009-11-26 11:10:23 +03:00
|
|
|
QVariantMap data;
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// UI
|
2010-11-16 23:34:31 +03:00
|
|
|
data["locale"] = pref.getLocale();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Downloads
|
2010-11-16 23:34:31 +03:00
|
|
|
data["save_path"] = pref.getSavePath();
|
|
|
|
data["temp_path_enabled"] = pref.isTempPathEnabled();
|
|
|
|
data["temp_path"] = pref.getTempPath();
|
|
|
|
data["scan_dirs"] = pref.getScanDirs();
|
2010-06-05 22:59:05 +04:00
|
|
|
QVariantList var_list;
|
2010-11-16 23:34:31 +03:00
|
|
|
foreach(bool b, pref.getDownloadInScanDirs()) {
|
2010-06-05 22:59:05 +04:00
|
|
|
var_list << b;
|
|
|
|
}
|
|
|
|
data["download_in_scan_dirs"] = var_list;
|
2010-11-16 23:34:31 +03:00
|
|
|
data["export_dir_enabled"] = pref.isTorrentExportEnabled();
|
|
|
|
data["export_dir"] = pref.getExportDir();
|
|
|
|
data["mail_notification_enabled"] = pref.isMailNotificationEnabled();
|
|
|
|
data["mail_notification_email"] = pref.getMailNotificationEmail();
|
|
|
|
data["mail_notification_smtp"] = pref.getMailNotificationSMTP();
|
2011-06-05 20:08:30 +04:00
|
|
|
data["mail_notification_ssl_enabled"] = pref.getMailNotificationSMTPSSL();
|
|
|
|
data["mail_notification_auth_enabled"] = pref.getMailNotificationSMTPAuth();
|
|
|
|
data["mail_notification_username"] = pref.getMailNotificationSMTPUsername();
|
|
|
|
data["mail_notification_password"] = pref.getMailNotificationSMTPPassword();
|
2010-11-16 23:34:31 +03:00
|
|
|
data["autorun_enabled"] = pref.isAutoRunEnabled();
|
|
|
|
data["autorun_program"] = pref.getAutoRunProgram();
|
|
|
|
data["preallocate_all"] = pref.preAllocateAllFiles();
|
|
|
|
data["queueing_enabled"] = pref.isQueueingSystemEnabled();
|
|
|
|
data["max_active_downloads"] = pref.getMaxActiveDownloads();
|
|
|
|
data["max_active_torrents"] = pref.getMaxActiveTorrents();
|
|
|
|
data["max_active_uploads"] = pref.getMaxActiveUploads();
|
2011-09-18 20:34:29 +04:00
|
|
|
data["dont_count_slow_torrents"] = pref.ignoreSlowTorrentsForQueueing();
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2010-11-16 23:34:31 +03:00
|
|
|
data["incomplete_files_ext"] = pref.useIncompleteFilesExtension();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
#endif
|
|
|
|
// Connection
|
2010-11-16 23:34:31 +03:00
|
|
|
data["listen_port"] = pref.getSessionPort();
|
|
|
|
data["upnp"] = pref.isUPnPEnabled();
|
|
|
|
data["dl_limit"] = pref.getGlobalDownloadLimit();
|
|
|
|
data["up_limit"] = pref.getGlobalUploadLimit();
|
|
|
|
data["max_connec"] = pref.getMaxConnecs();
|
|
|
|
data["max_connec_per_torrent"] = pref.getMaxConnecsPerTorrent();
|
|
|
|
data["max_uploads_per_torrent"] = pref.getMaxUploadsPerTorrent();
|
2011-06-05 20:08:30 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR >= 16
|
|
|
|
data["enable_utp"] = pref.isuTPEnabled();
|
|
|
|
data["limit_utp_rate"] = pref.isuTPRateLimited();
|
|
|
|
#endif
|
|
|
|
data["limit_tcp_overhead"] = pref.includeOverheadInLimits();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Bittorrent
|
2010-11-16 23:34:31 +03:00
|
|
|
data["dht"] = pref.isDHTEnabled();
|
|
|
|
data["dhtSameAsBT"] = pref.isDHTPortSameAsBT();
|
|
|
|
data["dht_port"] = pref.getDHTPort();
|
|
|
|
data["pex"] = pref.isPeXEnabled();
|
|
|
|
data["lsd"] = pref.isLSDEnabled();
|
|
|
|
data["encryption"] = pref.getEncryptionSetting();
|
2011-09-20 21:15:47 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR >= 16
|
|
|
|
data["anonymous_mode"] = pref.isAnonymousModeEnabled();
|
|
|
|
#endif
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Proxy
|
2010-11-18 23:05:56 +03:00
|
|
|
data["proxy_type"] = pref.getProxyType();
|
|
|
|
data["proxy_ip"] = pref.getProxyIp();
|
|
|
|
data["proxy_port"] = pref.getProxyPort();
|
2011-05-01 16:00:23 +04:00
|
|
|
data["proxy_peer_connections"] = pref.proxyPeerConnections();
|
2010-11-18 23:05:56 +03:00
|
|
|
data["proxy_auth_enabled"] = pref.isProxyAuthEnabled();
|
|
|
|
data["proxy_username"] = pref.getProxyUsername();
|
|
|
|
data["proxy_password"] = pref.getProxyPassword();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// IP Filter
|
2010-11-16 23:34:31 +03:00
|
|
|
data["ip_filter_enabled"] = pref.isFilteringEnabled();
|
|
|
|
data["ip_filter_path"] = pref.getFilter();
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
// Web UI
|
2010-11-16 23:34:31 +03:00
|
|
|
data["web_ui_port"] = pref.getWebUiPort();
|
|
|
|
data["web_ui_username"] = pref.getWebUiUsername();
|
|
|
|
data["web_ui_password"] = pref.getWebUiPassword();
|
2011-06-05 20:08:30 +04:00
|
|
|
data["bypass_local_auth"] = !pref.isWebUiLocalAuthEnabled();
|
|
|
|
data["use_https"] = pref.isWebUiHttpsEnabled();
|
|
|
|
data["ssl_key"] = QString::fromAscii(pref.getWebUiHttpsKey());
|
|
|
|
data["ssl_cert"] = QString::fromAscii(pref.getWebUiHttpsCertificate());
|
|
|
|
// DynDns
|
|
|
|
data["dyndns_enabled"] = pref.isDynDNSEnabled();
|
|
|
|
data["dyndns_service"] = pref.getDynDNSService();
|
|
|
|
data["dyndns_username"] = pref.getDynDNSUsername();
|
|
|
|
data["dyndns_password"] = pref.getDynDNSPassword();
|
|
|
|
data["dyndns_domain"] = pref.getDynDomainName();
|
2009-11-26 11:10:23 +03:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:53:14 +03:00
|
|
|
QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
|
|
|
QVariantMap data;
|
2010-11-14 00:15:52 +03:00
|
|
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
2009-12-05 17:24:45 +03:00
|
|
|
if(h.is_valid() && h.has_metadata()) {
|
2009-11-24 11:53:14 +03:00
|
|
|
// Save path
|
2010-02-14 18:30:10 +03:00
|
|
|
QString p = TorrentPersistentData::getSavePath(hash);
|
|
|
|
if(p.isEmpty()) p = h.save_path();
|
|
|
|
data["save_path"] = p;
|
2009-11-24 11:53:14 +03:00
|
|
|
// Creation date
|
|
|
|
data["creation_date"] = h.creation_date();
|
2010-12-21 20:56:25 +03:00
|
|
|
// Piece size
|
|
|
|
data["piece_size"] = misc::friendlyUnit(h.piece_length());
|
2009-11-24 11:53:14 +03:00
|
|
|
// Comment
|
|
|
|
data["comment"] = h.comment();
|
2010-03-07 00:11:47 +03:00
|
|
|
data["total_wasted"] = QVariant(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
|
|
|
|
data["total_uploaded"] = QVariant(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
|
|
|
|
data["total_downloaded"] = QVariant(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")");
|
2009-11-24 11:53:14 +03:00
|
|
|
if(h.upload_limit() <= 0)
|
|
|
|
data["up_limit"] = QString::fromUtf8("∞");
|
|
|
|
else
|
2010-03-07 00:11:47 +03:00
|
|
|
data["up_limit"] = QVariant(misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)"));
|
2009-11-24 11:53:14 +03:00
|
|
|
if(h.download_limit() <= 0)
|
|
|
|
data["dl_limit"] = QString::fromUtf8("∞");
|
|
|
|
else
|
2010-03-07 00:11:47 +03:00
|
|
|
data["dl_limit"] = QVariant(misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)"));
|
2009-11-24 11:53:14 +03:00
|
|
|
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
|
|
|
|
if(h.is_seed()) {
|
|
|
|
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
|
|
|
}
|
|
|
|
data["time_elapsed"] = elapsed_txt;
|
2010-03-07 00:11:47 +03:00
|
|
|
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
2009-11-24 11:53:14 +03:00
|
|
|
// Update ratio info
|
2011-01-25 20:01:09 +03:00
|
|
|
qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(ratio > 100.)
|
|
|
|
data["share_ratio"] = QString::fromUtf8("∞");
|
|
|
|
else
|
|
|
|
data["share_ratio"] = QString(QByteArray::number(ratio, 'f', 1));
|
2009-11-24 11:53:14 +03:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2010-11-24 23:31:14 +03:00
|
|
|
void EventManager::addedTorrent(const QTorrentHandle& h)
|
2008-05-17 17:23:37 +04:00
|
|
|
{
|
2009-11-19 21:28:30 +03:00
|
|
|
modifiedTorrent(h);
|
2008-12-25 16:48:23 +03:00
|
|
|
}
|
2008-09-27 23:55:56 +04:00
|
|
|
|
2008-09-28 15:30:24 +04:00
|
|
|
void EventManager::deletedTorrent(QString hash)
|
|
|
|
{
|
2009-11-19 21:28:30 +03:00
|
|
|
event_list.remove(hash);
|
2008-09-27 23:55:56 +04:00
|
|
|
}
|
|
|
|
|
2010-11-24 23:31:14 +03:00
|
|
|
void EventManager::modifiedTorrent(const QTorrentHandle& h)
|
2008-09-28 15:30:24 +04:00
|
|
|
{
|
2009-11-19 21:28:30 +03:00
|
|
|
QString hash = h.hash();
|
|
|
|
QVariantMap event;
|
2009-11-23 13:37:55 +03:00
|
|
|
event["eta"] = QVariant(QString::fromUtf8("∞"));
|
2009-11-19 21:28:30 +03:00
|
|
|
if(h.is_paused()) {
|
2010-05-24 18:19:25 +04:00
|
|
|
if(h.has_error()) {
|
|
|
|
event["state"] = QVariant("error");
|
|
|
|
} else {
|
|
|
|
if(h.is_seed())
|
|
|
|
event["state"] = QVariant("pausedUP");
|
|
|
|
else
|
|
|
|
event["state"] = QVariant("pausedDL");
|
|
|
|
}
|
2009-11-19 21:28:30 +03:00
|
|
|
} else {
|
2010-11-14 00:15:52 +03:00
|
|
|
if(QBtSession::instance()->isQueueingEnabled() && h.is_queued()) {
|
2009-11-23 12:16:32 +03:00
|
|
|
if(h.is_seed())
|
|
|
|
event["state"] = QVariant("queuedUP");
|
|
|
|
else
|
|
|
|
event["state"] = QVariant("queuedDL");
|
2008-11-02 14:43:20 +03:00
|
|
|
} else {
|
2009-11-19 21:28:30 +03:00
|
|
|
switch(h.state())
|
|
|
|
{
|
2009-11-23 12:16:32 +03:00
|
|
|
case torrent_status::finished:
|
|
|
|
case torrent_status::seeding:
|
2009-11-23 13:37:55 +03:00
|
|
|
if(h.upload_payload_rate() > 0) {
|
2009-12-01 00:30:14 +03:00
|
|
|
event["state"] = QVariant("uploading");
|
2009-11-23 13:37:55 +03:00
|
|
|
} else {
|
2009-11-23 12:16:32 +03:00
|
|
|
event["state"] = QVariant("stalledUP");
|
2009-11-23 13:37:55 +03:00
|
|
|
}
|
2009-11-19 21:28:30 +03:00
|
|
|
break;
|
2009-11-23 12:16:32 +03:00
|
|
|
case torrent_status::allocating:
|
2009-11-19 21:28:30 +03:00
|
|
|
case torrent_status::checking_files:
|
|
|
|
case torrent_status::queued_for_checking:
|
|
|
|
case torrent_status::checking_resume_data:
|
2009-11-23 13:37:55 +03:00
|
|
|
if(h.is_seed()) {
|
2009-11-23 12:16:32 +03:00
|
|
|
event["state"] = QVariant("checkingUP");
|
2009-11-23 13:37:55 +03:00
|
|
|
} else {
|
2009-11-23 12:16:32 +03:00
|
|
|
event["state"] = QVariant("checkingDL");
|
2009-11-23 13:37:55 +03:00
|
|
|
}
|
2009-11-19 21:28:30 +03:00
|
|
|
break;
|
2009-11-23 12:16:32 +03:00
|
|
|
case torrent_status::downloading:
|
|
|
|
case torrent_status::downloading_metadata:
|
2009-11-19 21:28:30 +03:00
|
|
|
if(h.download_payload_rate() > 0)
|
|
|
|
event["state"] = QVariant("downloading");
|
|
|
|
else
|
2009-11-23 12:16:32 +03:00
|
|
|
event["state"] = QVariant("stalledDL");
|
2010-11-14 00:15:52 +03:00
|
|
|
event["eta"] = misc::userFriendlyDuration(QBtSession::instance()->getETA(hash));
|
2009-11-19 21:28:30 +03:00
|
|
|
break;
|
2011-06-05 20:08:30 +04:00
|
|
|
default:
|
2009-11-19 21:28:30 +03:00
|
|
|
qDebug("No status, should not happen!!! status is %d", h.state());
|
|
|
|
event["state"] = QVariant();
|
|
|
|
}
|
2008-11-02 14:43:20 +03:00
|
|
|
}
|
2009-11-19 21:28:30 +03:00
|
|
|
}
|
|
|
|
event["name"] = QVariant(h.name());
|
2009-11-23 13:37:55 +03:00
|
|
|
event["size"] = QVariant(misc::friendlyUnit(h.actual_size()));
|
2009-12-29 23:09:46 +03:00
|
|
|
event["progress"] = QVariant((double)h.progress());
|
2009-11-23 13:37:55 +03:00
|
|
|
event["dlspeed"] = QVariant(tr("%1/s", "e.g. 120 KiB/s").arg(misc::friendlyUnit(h.download_payload_rate())));
|
2010-11-14 00:15:52 +03:00
|
|
|
if(QBtSession::instance()->isQueueingEnabled()) {
|
2009-11-23 16:35:46 +03:00
|
|
|
if(h.queue_position() >= 0)
|
|
|
|
event["priority"] = QVariant(QString::number(h.queue_position()));
|
|
|
|
else
|
|
|
|
event["priority"] = "*";
|
2009-11-23 12:16:32 +03:00
|
|
|
} else {
|
2009-11-23 16:35:46 +03:00
|
|
|
event["priority"] = "*";
|
2009-11-19 21:28:30 +03:00
|
|
|
}
|
2009-11-23 13:37:55 +03:00
|
|
|
event["upspeed"] = QVariant(tr("%1/s", "e.g. 120 KiB/s").arg(misc::friendlyUnit(h.upload_payload_rate())));
|
|
|
|
QString seeds = QString::number(h.num_seeds());
|
|
|
|
if(h.num_complete() > 0)
|
|
|
|
seeds += " ("+QString::number(h.num_complete())+")";
|
|
|
|
event["num_seeds"] = QVariant(seeds);
|
|
|
|
QString leechs = QString::number(h.num_peers()-h.num_seeds());
|
|
|
|
if(h.num_incomplete() > 0)
|
|
|
|
leechs += " ("+QString::number(h.num_incomplete())+")";
|
|
|
|
event["num_leechs"] = QVariant(leechs);
|
2009-11-19 21:28:30 +03:00
|
|
|
event["seed"] = QVariant(h.is_seed());
|
2011-01-25 20:01:09 +03:00
|
|
|
qreal ratio = QBtSession::instance()->getRealRatio(hash);
|
2009-11-27 18:59:49 +03:00
|
|
|
if(ratio > 100.)
|
2009-12-01 00:30:14 +03:00
|
|
|
event["ratio"] = QString::fromUtf8("∞");
|
2009-11-27 18:59:49 +03:00
|
|
|
else
|
|
|
|
event["ratio"] = QVariant(QString::number(ratio, 'f', 1));
|
2009-11-19 21:28:30 +03:00
|
|
|
event["hash"] = QVariant(hash);
|
|
|
|
event_list[hash] = event;
|
2008-05-17 17:23:37 +04:00
|
|
|
}
|