mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +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
|
||||
// Set environment variable
|
||||
if(putenv((char*)"QBITTORRENT="VERSION)) {
|
||||
if (qputenv("QBITTORRENT", QByteArray(VERSION))) {
|
||||
std::cerr << "Couldn't set environment variable...\n";
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ public:
|
||||
return save_path;
|
||||
|
||||
// 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())
|
||||
config_path = QDir::home().absoluteFilePath(".config");
|
||||
|
||||
|
@ -2083,31 +2083,16 @@ void QBtSession::setProxySettings(proxy_settings proxySettings) {
|
||||
break;
|
||||
default:
|
||||
qDebug("Disabling HTTP communications proxy");
|
||||
#ifdef Q_WS_WIN
|
||||
putenv("http_proxy=");
|
||||
putenv("sock_proxy=");
|
||||
#else
|
||||
unsetenv("http_proxy");
|
||||
unsetenv("sock_proxy");
|
||||
#endif
|
||||
qputenv("http_proxy", QByteArray());
|
||||
qputenv("sock_proxy", QByteArray());
|
||||
return;
|
||||
}
|
||||
// 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));
|
||||
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
|
||||
setenv("http_proxy", proxy_str.toLocal8Bit().constData(), 1);
|
||||
#endif
|
||||
qputenv("http_proxy", proxy_str.toLocal8Bit());
|
||||
}
|
||||
|
||||
void QBtSession::recursiveTorrentDownload(const QTorrentHandle &h) {
|
||||
|
@ -125,14 +125,13 @@ bool SearchEngine::addPythonPathToEnv() {
|
||||
QString python_path = Preferences::getPythonPath();
|
||||
if(!python_path.isEmpty()) {
|
||||
// Add it to PATH envvar
|
||||
QString path_envar = QString::fromLocal8Bit(getenv("PATH"));
|
||||
QString path_envar = QString::fromLocal8Bit(qgetenv("PATH").constData());
|
||||
if(path_envar.isNull()) {
|
||||
path_envar = "";
|
||||
}
|
||||
path_envar = python_path+";"+path_envar;
|
||||
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
||||
QString envar = "PATH="+path_envar;
|
||||
putenv(envar.toLocal8Bit().data());
|
||||
qputenv("PATH", path_envar.toLocal8Bit());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user