зеркало из https://github.com/nextcloud/desktop.git
Respect skipUpdate policy from global config files and windows policy.
This commit is contained in:
Родитель
bcf73cfc40
Коммит
958253bb2b
|
@ -2,7 +2,7 @@ set( APPLICATION_NAME "ownCloud" )
|
|||
#set( APPLICATION_SHORTNAME ${APPLICATION_NAME} )
|
||||
set( APPLICATION_EXECUTABLE "owncloud" )
|
||||
set( APPLICATION_DOMAIN "owncloud.com" )
|
||||
set( APPLICATION_VENDOR "ownCloud, Inc" )
|
||||
set( APPLICATION_VENDOR "ownCloud" )
|
||||
set( APPLICATION_UPDATE_URL "https://updates.owncloud.com/client/" CACHE string "URL for updater" )
|
||||
|
||||
set( THEME_CLASS "ownCloudTheme" )
|
||||
|
|
|
@ -67,7 +67,7 @@ Name "@CPACK_NSIS_PACKAGE_NAME@"
|
|||
BrandingText "${APPLICATION_NAME} ${VERSION} -- ${BUILD_TIME}"
|
||||
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
|
||||
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
InstallDirRegKey HKCU "Software\${APPLICATION_NAME}" ""
|
||||
InstallDirRegKey HKCU "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" ""
|
||||
InstType Standard
|
||||
InstType Full
|
||||
InstType Minimal
|
||||
|
@ -277,21 +277,21 @@ FunctionEnd
|
|||
##############################################################################
|
||||
|
||||
Function PageReinstall
|
||||
ReadRegStr $R0 HKLM "Software\${APPLICATION_NAME}" ""
|
||||
ReadRegStr $R0 HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" ""
|
||||
StrCmp $R0 "" 0 +2
|
||||
Abort
|
||||
|
||||
;Detect version
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMajor"
|
||||
IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
|
||||
minor_check:
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMinor"
|
||||
IntCmp $R0 ${VER_MINOR} rev_check new_version older_version
|
||||
rev_check:
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionRevision"
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionRevision"
|
||||
IntCmp $R0 ${VER_PATCH} build_check new_version older_version
|
||||
build_check:
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
|
||||
ReadRegDWORD $R0 HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionBuild"
|
||||
IntCmp $R0 ${VER_BUILD} same_version new_version older_version
|
||||
|
||||
new_version:
|
||||
|
@ -487,11 +487,11 @@ Section -post
|
|||
SetDetailsPrint listonly
|
||||
|
||||
;Version numbers used to detect existing installation version for comparisson.
|
||||
WriteRegStr HKLM "Software\${APPLICATION_NAME}" "" $INSTDIR
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionRevision" "${VER_PATCH}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionBuild" "${VER_BUILD}"
|
||||
WriteRegStr HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "" $INSTDIR
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionRevision" "${VER_PATCH}"
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionBuild" "${VER_BUILD}"
|
||||
|
||||
;Add or Remove Programs entry.
|
||||
WriteRegExpandStr ${MEMENTO_REGISTRY_ROOT} "${MEMENTO_REGISTRY_KEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
|
||||
|
@ -563,12 +563,12 @@ Section Uninstall
|
|||
owncloud_installed:
|
||||
|
||||
;Delete registry keys.
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionRevision"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_NAME}" ""
|
||||
DeleteRegKey HKLM "Software\${APPLICATION_NAME}"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionBuild"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMajor"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionMinor"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "VersionRevision"
|
||||
DeleteRegValue HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" ""
|
||||
DeleteRegKey HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}"
|
||||
|
||||
DeleteRegKey HKCR "${APPLICATION_NAME}"
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#cmakedefine THEME_INCLUDE @THEME_INCLUDE@
|
||||
|
||||
#cmakedefine APPLICATION_NAME "@APPLICATION_NAME@"
|
||||
#cmakedefine APPLICATION_VENDOR "@APPLICATION_VENDOR@"
|
||||
#cmakedefine APPLICATION_REV_DOMAIN "@APPLICATION_REV_DOMAIN@"
|
||||
#cmakedefine APPLICATION_SHORTNAME "@APPLICATION_SHORTNAME@"
|
||||
#cmakedefine APPLICATION_EXECUTABLE "@APPLICATION_EXECUTABLE@"
|
||||
#cmakedefine APPLICATION_UPDATE_URL "@APPLICATION_UPDATE_URL@"
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
#include "mirall/clientproxy.h"
|
||||
|
||||
#include "updater/updater.h"
|
||||
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
@ -88,6 +89,9 @@ Application::Application(int &argc, char **argv) :
|
|||
_logFlush(false),
|
||||
_userTriggeredConnect(false)
|
||||
{
|
||||
// TODO: Can't set this without breaking current config pathes
|
||||
// setOrganizationName(QLatin1String(APPLICATION_VENDOR));
|
||||
setOrganizationDomain(QLatin1String(APPLICATION_REV_DOMAIN));
|
||||
setApplicationName( _theme->appNameGUI() );
|
||||
setWindowIcon( _theme->applicationIcon() );
|
||||
|
||||
|
@ -139,7 +143,9 @@ Application::Application(int &argc, char **argv) :
|
|||
// startup procedure.
|
||||
QTimer::singleShot( 0, this, SLOT( slotCheckConnection() ));
|
||||
|
||||
if( !cfg.skipUpdateCheck() ) {
|
||||
if( cfg.skipUpdateCheck() ) {
|
||||
qDebug() << Q_FUNC_INFO << "Skipping update check";
|
||||
} else {
|
||||
QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,26 @@ void MirallConfigFile::restoreGeometryHeader(QHeaderView *header)
|
|||
header->restoreState(getValue(geometryC, header->objectName()).toByteArray());
|
||||
}
|
||||
|
||||
QVariant MirallConfigFile::getPolicySetting(const QString &setting, const QVariant& defaultValue) const
|
||||
{
|
||||
if (Utility::isWindows()) {
|
||||
// check for policies first and return immediately if a value is found.
|
||||
QSettings userPolicy(QString::fromLatin1("HKEY_CURRENT_USER\\Software\\Policies\\%1\\%2")
|
||||
.arg(APPLICATION_VENDOR).arg(APPLICATION_NAME),
|
||||
QSettings::NativeFormat);
|
||||
if(userPolicy.contains(setting)) {
|
||||
return userPolicy.value(setting);
|
||||
}
|
||||
|
||||
QSettings machinePolicy(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\Policies\\%1\\%2")
|
||||
.arg(APPLICATION_VENDOR).arg(APPLICATION_NAME),
|
||||
QSettings::NativeFormat);
|
||||
if(machinePolicy.contains(setting)) {
|
||||
return machinePolicy.value(setting);
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
QString MirallConfigFile::configPath() const
|
||||
{
|
||||
|
@ -324,12 +344,13 @@ bool MirallConfigFile::skipUpdateCheck( const QString& connection ) const
|
|||
QString con( connection );
|
||||
if( connection.isEmpty() ) con = defaultConnection();
|
||||
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup( con );
|
||||
QVariant fallback = getValue(QLatin1String(skipUpdateCheckC), con, false);
|
||||
fallback = getValue(QLatin1String(skipUpdateCheckC), QString(), fallback);
|
||||
|
||||
bool skipIt = settings.value( QLatin1String(skipUpdateCheckC), false ).toBool();
|
||||
|
||||
return skipIt;
|
||||
qDebug() << Q_FUNC_INFO << fallback;
|
||||
QVariant value = getPolicySetting(QLatin1String(skipUpdateCheckC), fallback);
|
||||
qDebug() << Q_FUNC_INFO << value;
|
||||
return value.toBool();
|
||||
}
|
||||
|
||||
void MirallConfigFile::setSkipUpdateCheck( bool skip, const QString& connection )
|
||||
|
@ -382,11 +403,35 @@ void MirallConfigFile::setProxyType(int proxyType,
|
|||
QVariant MirallConfigFile::getValue(const QString& param, const QString& group,
|
||||
const QVariant& defaultValue) const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
if (!group.isEmpty())
|
||||
settings.beginGroup(group);
|
||||
QVariant systemSetting;
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (Utility::isMac()) {
|
||||
QSettings systemSettings(QSettings::NativeFormat, QSettings::SystemScope, QCoreApplication::organizationName());
|
||||
if (!group.isEmpty()) {
|
||||
systemSettings.beginGroup(group);
|
||||
}
|
||||
systemSetting = systemSettings.value(param, defaultValue);
|
||||
} else if (Utility::isUnix()) {
|
||||
QSettings systemSettings(QString( SYSCONFDIR "/%1/%1.conf").arg(Theme::instance()->appName()), QSettings::NativeFormat);
|
||||
if (!group.isEmpty()) {
|
||||
systemSettings.beginGroup(group);
|
||||
}
|
||||
systemSetting = systemSettings.value(param, defaultValue);
|
||||
} else { // Windows
|
||||
QSettings systemSettings(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\%1\\%2")
|
||||
.arg(APPLICATION_VENDOR).arg(APPLICATION_NAME),
|
||||
QSettings::NativeFormat);
|
||||
if (!group.isEmpty()) {
|
||||
systemSettings.beginGroup(group);
|
||||
}
|
||||
systemSetting = systemSettings.value(param, defaultValue);
|
||||
qDebug() << Q_FUNC_INFO << "Windows, read" << systemSetting << "from registry!";
|
||||
}
|
||||
|
||||
return settings.value(param, defaultValue);
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
if (!group.isEmpty()) settings.beginGroup(group);
|
||||
|
||||
return settings.value(param, systemSetting);
|
||||
}
|
||||
|
||||
void MirallConfigFile::setValue(const QString& key, const QVariant &value)
|
||||
|
|
|
@ -108,7 +108,9 @@ public:
|
|||
|
||||
void saveGeometryHeader(QHeaderView *header);
|
||||
void restoreGeometryHeader(QHeaderView *header);
|
||||
|
||||
protected:
|
||||
QVariant getPolicySetting(const QString& policy, const QVariant& defaultValue = QVariant()) const;
|
||||
void storeData(const QString& group, const QString& key, const QVariant& value);
|
||||
QVariant retrieveData(const QString& group, const QString& key) const;
|
||||
void removeData(const QString& group, const QString& key);
|
||||
|
|
|
@ -482,5 +482,4 @@ bool Utility::isLinux()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mirall
|
||||
|
|
Загрузка…
Ссылка в новой задаче