mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-03 02:14:16 +00:00
Use qputenv/qgetenv from Qt for better cross compatibility
This commit is contained in:
parent
aae85b4498
commit
2f7b20c704
@ -272,7 +272,7 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Set environment variable
|
// Set environment variable
|
||||||
if(putenv((char*)"QBITTORRENT="VERSION)) {
|
if (qputenv("QBITTORRENT", QByteArray(VERSION))) {
|
||||||
std::cerr << "Couldn't set environment variable...\n";
|
std::cerr << "Couldn't set environment variable...\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public:
|
|||||||
return save_path;
|
return save_path;
|
||||||
|
|
||||||
// Default save path on Linux
|
// Default save path on Linux
|
||||||
QString config_path = QString::fromLocal8Bit(getenv("XDG_CONFIG_HOME"));
|
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
||||||
if (config_path.isEmpty())
|
if (config_path.isEmpty())
|
||||||
config_path = QDir::home().absoluteFilePath(".config");
|
config_path = QDir::home().absoluteFilePath(".config");
|
||||||
|
|
||||||
|
@ -2083,31 +2083,16 @@ void QBtSession::setProxySettings(proxy_settings proxySettings) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug("Disabling HTTP communications proxy");
|
qDebug("Disabling HTTP communications proxy");
|
||||||
#ifdef Q_WS_WIN
|
qputenv("http_proxy", QByteArray());
|
||||||
putenv("http_proxy=");
|
qputenv("sock_proxy", QByteArray());
|
||||||
putenv("sock_proxy=");
|
|
||||||
#else
|
|
||||||
unsetenv("http_proxy");
|
|
||||||
unsetenv("sock_proxy");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// We need this for urllib in search engine plugins
|
// We need this for urllib in search engine plugins
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
QString type_str;
|
|
||||||
if(proxySettings.type == proxy_settings::socks5 || proxySettings.type == proxy_settings::socks5_pw)
|
|
||||||
type_str = "sock_proxy";
|
|
||||||
else
|
|
||||||
type_str = "http_proxy";
|
|
||||||
QString tmp = type_str+"="+proxy_str;
|
|
||||||
putenv(tmp.toLocal8Bit().constData());
|
|
||||||
#else
|
|
||||||
qDebug("HTTP communications proxy string: %s", qPrintable(proxy_str));
|
qDebug("HTTP communications proxy string: %s", qPrintable(proxy_str));
|
||||||
if(proxySettings.type == proxy_settings::socks5 || proxySettings.type == proxy_settings::socks5_pw)
|
if(proxySettings.type == proxy_settings::socks5 || proxySettings.type == proxy_settings::socks5_pw)
|
||||||
setenv("sock_proxy", proxy_str.toLocal8Bit().constData(), 1);
|
qputenv("sock_proxy", proxy_str.toLocal8Bit());
|
||||||
else
|
else
|
||||||
setenv("http_proxy", proxy_str.toLocal8Bit().constData(), 1);
|
qputenv("http_proxy", proxy_str.toLocal8Bit());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::recursiveTorrentDownload(const QTorrentHandle &h) {
|
void QBtSession::recursiveTorrentDownload(const QTorrentHandle &h) {
|
||||||
|
@ -125,14 +125,13 @@ bool SearchEngine::addPythonPathToEnv() {
|
|||||||
QString python_path = Preferences::getPythonPath();
|
QString python_path = Preferences::getPythonPath();
|
||||||
if(!python_path.isEmpty()) {
|
if(!python_path.isEmpty()) {
|
||||||
// Add it to PATH envvar
|
// Add it to PATH envvar
|
||||||
QString path_envar = QString::fromLocal8Bit(getenv("PATH"));
|
QString path_envar = QString::fromLocal8Bit(qgetenv("PATH").constData());
|
||||||
if(path_envar.isNull()) {
|
if(path_envar.isNull()) {
|
||||||
path_envar = "";
|
path_envar = "";
|
||||||
}
|
}
|
||||||
path_envar = python_path+";"+path_envar;
|
path_envar = python_path+";"+path_envar;
|
||||||
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
||||||
QString envar = "PATH="+path_envar;
|
qputenv("PATH", path_envar.toLocal8Bit());
|
||||||
putenv(envar.toLocal8Bit().data());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user