|
|
@ -146,7 +146,7 @@ QBtSession::QBtSession() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); |
|
|
|
connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); |
|
|
|
// Apply user settings to Bittorrent session
|
|
|
|
// Apply user settings to Bittorrent session
|
|
|
|
QTimer::singleShot(0, this, SLOT(configureSession())); |
|
|
|
configureSession(); |
|
|
|
qDebug("* BTSession constructed"); |
|
|
|
qDebug("* BTSession constructed"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -499,14 +499,8 @@ void QBtSession::configureSession() { |
|
|
|
disableIPFilter(); |
|
|
|
disableIPFilter(); |
|
|
|
} |
|
|
|
} |
|
|
|
// Update Web UI
|
|
|
|
// Update Web UI
|
|
|
|
if (pref.isWebUiEnabled()) { |
|
|
|
// Use a QTimer because the function can be called from qBtSession constructor
|
|
|
|
const quint16 port = pref.getWebUiPort(); |
|
|
|
QTimer::singleShot(0, this, SLOT(initWebUi())); |
|
|
|
const QString username = pref.getWebUiUsername(); |
|
|
|
|
|
|
|
const QString password = pref.getWebUiPassword(); |
|
|
|
|
|
|
|
initWebUi(username, password, port); |
|
|
|
|
|
|
|
} else if(httpServer) { |
|
|
|
|
|
|
|
delete httpServer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// * Proxy settings
|
|
|
|
// * Proxy settings
|
|
|
|
proxy_settings proxySettings; |
|
|
|
proxy_settings proxySettings; |
|
|
|
if(pref.isProxyEnabled()) { |
|
|
|
if(pref.isProxyEnabled()) { |
|
|
@ -563,7 +557,13 @@ void QBtSession::configureSession() { |
|
|
|
qDebug("Session configured"); |
|
|
|
qDebug("Session configured"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool QBtSession::initWebUi(QString username, QString password, int port) { |
|
|
|
void QBtSession::initWebUi() { |
|
|
|
|
|
|
|
Preferences pref; |
|
|
|
|
|
|
|
if (pref.isWebUiEnabled()) { |
|
|
|
|
|
|
|
const quint16 port = pref.getWebUiPort(); |
|
|
|
|
|
|
|
const QString username = pref.getWebUiUsername(); |
|
|
|
|
|
|
|
const QString password = pref.getWebUiPassword(); |
|
|
|
|
|
|
|
|
|
|
|
if(httpServer) { |
|
|
|
if(httpServer) { |
|
|
|
if(httpServer->serverPort() != port) { |
|
|
|
if(httpServer->serverPort() != port) { |
|
|
|
httpServer->close(); |
|
|
|
httpServer->close(); |
|
|
@ -572,15 +572,16 @@ bool QBtSession::initWebUi(QString username, QString password, int port) { |
|
|
|
httpServer = new HttpServer(3000, this); |
|
|
|
httpServer = new HttpServer(3000, this); |
|
|
|
} |
|
|
|
} |
|
|
|
httpServer->setAuthorization(username, password); |
|
|
|
httpServer->setAuthorization(username, password); |
|
|
|
bool success = true; |
|
|
|
|
|
|
|
if(!httpServer->isListening()) { |
|
|
|
if(!httpServer->isListening()) { |
|
|
|
success = httpServer->listen(QHostAddress::Any, port); |
|
|
|
bool success = httpServer->listen(QHostAddress::Any, port); |
|
|
|
if (success) |
|
|
|
if (success) |
|
|
|
addConsoleMessage(tr("The Web UI is listening on port %1").arg(port)); |
|
|
|
addConsoleMessage(tr("The Web UI is listening on port %1").arg(port)); |
|
|
|
else |
|
|
|
else |
|
|
|
addConsoleMessage(tr("Web User Interface Error - Unable to bind Web UI to port %1").arg(port), "red"); |
|
|
|
addConsoleMessage(tr("Web User Interface Error - Unable to bind Web UI to port %1").arg(port), "red"); |
|
|
|
} |
|
|
|
} |
|
|
|
return success; |
|
|
|
} else if(httpServer) { |
|
|
|
|
|
|
|
delete httpServer; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void QBtSession::useAlternativeSpeedsLimit(bool alternative) { |
|
|
|
void QBtSession::useAlternativeSpeedsLimit(bool alternative) { |
|
|
|