Browse Source

Use qputenv/qgetenv from Qt for better cross compatibility

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
2f7b20c704
  1. 2
      src/main.cpp
  2. 2
      src/preferences/preferences.h
  3. 23
      src/qtlibtorrent/qbtsession.cpp
  4. 5
      src/searchengine/searchengine.cpp

2
src/main.cpp

@ -272,7 +272,7 @@ int main(int argc, char *argv[]){ @@ -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";
}

2
src/preferences/preferences.h

@ -197,7 +197,7 @@ public: @@ -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");

23
src/qtlibtorrent/qbtsession.cpp

@ -2083,31 +2083,16 @@ void QBtSession::setProxySettings(proxy_settings proxySettings) { @@ -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) {

5
src/searchengine/searchengine.cpp

@ -125,14 +125,13 @@ bool SearchEngine::addPythonPathToEnv() { @@ -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…
Cancel
Save