Use qEnvironmentVariable* instead of qgetenv when appropriate

Now that we use Qt5, we should do that. It is slightly more efficient
and declares the intent.
(Modified using clazy)
This commit is contained in:
Olivier Goffart 2017-09-29 10:31:41 +02:00
parent 84d8624e03
commit a9761a8976
6 changed files with 9 additions and 9 deletions

View file

@ -120,7 +120,7 @@ QByteArray parseChecksumHeaderType(const QByteArray &header)
bool uploadChecksumEnabled() bool uploadChecksumEnabled()
{ {
static bool enabled = qgetenv("OWNCLOUD_DISABLE_CHECKSUM_UPLOAD").isEmpty(); static bool enabled = qEnvironmentVariableIsEmpty("OWNCLOUD_DISABLE_CHECKSUM_UPLOAD");
return enabled; return enabled;
} }

View file

@ -579,7 +579,7 @@ bool Utility::isConflictFile(const char *name)
bool Utility::shouldUploadConflictFiles() bool Utility::shouldUploadConflictFiles()
{ {
static bool uploadConflictFiles = qgetenv("OWNCLOUD_UPLOAD_CONFLICT_FILES").toInt() != 0; static bool uploadConflictFiles = qEnvironmentVariableIntValue("OWNCLOUD_UPLOAD_CONFLICT_FILES") != 0;
return uploadConflictFiles; return uploadConflictFiles;
} }

View file

@ -43,7 +43,7 @@ public:
UserAgentWebPage(QObject *parent) UserAgentWebPage(QObject *parent)
: QWebPage(parent) : QWebPage(parent)
{ {
if (!qgetenv("OWNCLOUD_SHIBBOLETH_DEBUG").isEmpty()) { if (!qEnvironmentVariableIsEmpty("OWNCLOUD_SHIBBOLETH_DEBUG")) {
settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
} }
} }
@ -83,7 +83,7 @@ ShibbolethWebView::ShibbolethWebView(AccountPtr account, QWidget *parent)
setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI())); setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));
// Debug view to display the cipher suite // Debug view to display the cipher suite
if (!qgetenv("OWNCLOUD_SHIBBOLETH_DEBUG").isEmpty()) { if (!qEnvironmentVariableIsEmpty("OWNCLOUD_SHIBBOLETH_DEBUG")) {
// open an additional window to display some cipher debug info // open an additional window to display some cipher debug info
QWebPage *debugPage = new UserAgentWebPage(this); QWebPage *debugPage = new UserAgentWebPage(this);
debugPage->mainFrame()->load(QUrl("https://cc.dcsec.uni-hannover.de/")); debugPage->mainFrame()->load(QUrl("https://cc.dcsec.uni-hannover.de/"));

View file

@ -88,7 +88,7 @@ int main(int argc, char **argv)
// check a environment variable for core dumps // check a environment variable for core dumps
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
if (!qgetenv("OWNCLOUD_CORE_DUMP").isEmpty()) { if (!qEnvironmentVariableIsEmpty("OWNCLOUD_CORE_DUMP")) {
struct rlimit core_limit; struct rlimit core_limit;
core_limit.rlim_cur = RLIM_INFINITY; core_limit.rlim_cur = RLIM_INFINITY;
core_limit.rlim_max = RLIM_INFINITY; core_limit.rlim_max = RLIM_INFINITY;

View file

@ -114,13 +114,13 @@ PropagateItemJob::~PropagateItemJob()
static qint64 getMinBlacklistTime() static qint64 getMinBlacklistTime()
{ {
return qMax(qgetenv("OWNCLOUD_BLACKLIST_TIME_MIN").toInt(), return qMax(qEnvironmentVariableIntValue("OWNCLOUD_BLACKLIST_TIME_MIN"),
25); // 25 seconds 25); // 25 seconds
} }
static qint64 getMaxBlacklistTime() static qint64 getMaxBlacklistTime()
{ {
int v = qgetenv("OWNCLOUD_BLACKLIST_TIME_MAX").toInt(); int v = qEnvironmentVariableIntValue("OWNCLOUD_BLACKLIST_TIME_MAX");
if (v > 0) if (v > 0)
return v; return v;
return 24 * 60 * 60; // 1 day return 24 * 60 * 60; // 1 day

View file

@ -1031,7 +1031,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
_progressInfo->startEstimateUpdates(); _progressInfo->startEstimateUpdates();
// post update phase script: allow to tweak stuff by a custom script in debug mode. // post update phase script: allow to tweak stuff by a custom script in debug mode.
if (!qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT").isEmpty()) { if (!qEnvironmentVariableIsEmpty("OWNCLOUD_POST_UPDATE_SCRIPT")) {
#ifndef NDEBUG #ifndef NDEBUG
QString script = qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT"); QString script = qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT");
@ -1464,7 +1464,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
RemotePermissions SyncEngine::getPermissions(const QString &file) const RemotePermissions SyncEngine::getPermissions(const QString &file) const
{ {
static bool isTest = qgetenv("OWNCLOUD_TEST_PERMISSIONS").toInt(); static bool isTest = qEnvironmentVariableIntValue("OWNCLOUD_TEST_PERMISSIONS");
if (isTest) { if (isTest) {
QRegExp rx("_PERM_([^_]*)_[^/]*$"); QRegExp rx("_PERM_([^_]*)_[^/]*$");
if (rx.indexIn(file) != -1) { if (rx.indexIn(file) != -1) {