From 16530b2334b87e6f01ebdcc17624cf2a9b75e639 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 23 Mar 2024 20:41:22 +0100 Subject: [PATCH] Moved avatar URL to fully private settings --- .../io/highfidelity/hifiinterface/PermissionChecker.java | 2 +- interface/src/CrashRecoveryHandler.cpp | 5 ++++- interface/src/avatar/MyAvatar.cpp | 2 +- interface/src/scripting/SettingsScriptingInterface.cpp | 8 +++++++- libraries/shared/src/SettingHandle.cpp | 2 ++ libraries/shared/src/SettingHandle.h | 9 +++++++++ tools/nitpick/AppDataHighFidelity/Interface.json | 2 +- 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java index ef9876c71a..0703fabf02 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java @@ -109,7 +109,7 @@ public class PermissionChecker extends Activity { JSONObject obj = new JSONObject(); try { obj.put("firstRun",false); - obj.put("Avatar/fullAvatarURL", avatarPaths[which]); + obj.put(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/Avatar/fullAvatarURL", avatarPaths[which]); File directory = new File(pathForJson); if(!directory.exists()) directory.mkdirs(); diff --git a/interface/src/CrashRecoveryHandler.cpp b/interface/src/CrashRecoveryHandler.cpp index 1f6cbef9ba..97e03f003d 100644 --- a/interface/src/CrashRecoveryHandler.cpp +++ b/interface/src/CrashRecoveryHandler.cpp @@ -258,10 +258,11 @@ void CrashRecoveryHandler::handleCrash(CrashRecoveryHandler::Action action) { // Display name and avatar settings.beginGroup(AVATAR_GROUP); displayName = settings.value(DISPLAY_NAME_KEY).toString(); - fullAvatarURL = settings.value(FULL_AVATAR_URL_KEY).toUrl(); fullAvatarModelName = settings.value(FULL_AVATAR_MODEL_NAME_KEY).toString(); settings.endGroup(); + fullAvatarURL = settings.value(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/" + AVATAR_GROUP + "/" + FULL_AVATAR_URL_KEY).toUrl(); + // Tutorial complete tutorialComplete = settings.value(TUTORIAL_COMPLETE_FLAG_KEY).toBool(); } @@ -284,6 +285,8 @@ void CrashRecoveryHandler::handleCrash(CrashRecoveryHandler::Action action) { settings.setValue(FULL_AVATAR_MODEL_NAME_KEY, fullAvatarModelName); settings.endGroup(); + settings.setValue(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/" + AVATAR_GROUP + "/" + FULL_AVATAR_URL_KEY, fullAvatarURL); + // Tutorial complete settings.setValue(TUTORIAL_COMPLETE_FLAG_KEY, tutorialComplete); } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index dc8963689a..21ac211e78 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -227,7 +227,7 @@ MyAvatar::MyAvatar(QThread* thread) : _yawSpeedSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "yawSpeed", _yawSpeed), _hmdYawSpeedSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "hmdYawSpeed", _hmdYawSpeed), _pitchSpeedSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "pitchSpeed", _pitchSpeed), - _fullAvatarURLSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "fullAvatarURL", + _fullAvatarURLSetting(QStringList() << SETTINGS_FULL_PRIVATE_GROUP_NAME << AVATAR_SETTINGS_GROUP_NAME << "fullAvatarURL", AvatarData::defaultFullAvatarModelUrl()), _fullAvatarModelNameSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "fullAvatarModelName", _fullAvatarModelName), _animGraphURLSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "animGraphURL", QUrl("")), diff --git a/interface/src/scripting/SettingsScriptingInterface.cpp b/interface/src/scripting/SettingsScriptingInterface.cpp index b7ef172f19..cf3737cd9c 100644 --- a/interface/src/scripting/SettingsScriptingInterface.cpp +++ b/interface/src/scripting/SettingsScriptingInterface.cpp @@ -25,6 +25,9 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting) { if (!value.isValid()) { value = ""; } + if (_restrictPrivateValues || setting.startsWith(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/")) { + value = ""; + } return value; } @@ -33,6 +36,9 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar if (!value.isValid()) { value = ""; } + if (_restrictPrivateValues || setting.startsWith(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/")) { + value = ""; + } return value; } @@ -40,7 +46,7 @@ void SettingsScriptingInterface::setValue(const QString& setting, const QVariant if (getValue(setting) == value) { return; } - if (setting.startsWith("private/")) { + if (setting.startsWith("private/") || setting.startsWith(SETTINGS_FULL_PRIVATE_GROUP_NAME + "/")) { if (_restrictPrivateValues) { qWarning() << "SettingsScriptingInterface::setValue -- restricted write: " << setting << value; return; diff --git a/libraries/shared/src/SettingHandle.cpp b/libraries/shared/src/SettingHandle.cpp index 88785e5700..2353f30933 100644 --- a/libraries/shared/src/SettingHandle.cpp +++ b/libraries/shared/src/SettingHandle.cpp @@ -18,6 +18,8 @@ Q_LOGGING_CATEGORY(settings_handle, "settings.handle") +const QString SETTINGS_FULL_PRIVATE_GROUP_NAME = "fullPrivate"; + const QString Settings::firstRun { "firstRun" }; diff --git a/libraries/shared/src/SettingHandle.h b/libraries/shared/src/SettingHandle.h index 2390063555..f8ba5f66ed 100644 --- a/libraries/shared/src/SettingHandle.h +++ b/libraries/shared/src/SettingHandle.h @@ -31,6 +31,15 @@ Q_DECLARE_LOGGING_CATEGORY(settings_handle) +/** + * @brief Name of the fully private settings group + * + * Settings in this group will be protected from reading and writing from script engines. + * + */ + +extern const QString SETTINGS_FULL_PRIVATE_GROUP_NAME; + /** * @brief QSettings analog * diff --git a/tools/nitpick/AppDataHighFidelity/Interface.json b/tools/nitpick/AppDataHighFidelity/Interface.json index a9d27d8309..bf3519fcb6 100644 --- a/tools/nitpick/AppDataHighFidelity/Interface.json +++ b/tools/nitpick/AppDataHighFidelity/Interface.json @@ -43,7 +43,7 @@ "Avatar/dominantHand": "right", "Avatar/flyingHMD": false, "Avatar/fullAvatarModelName": "Default", - "Avatar/fullAvatarURL": "", + "fullPrivate/Avatar/fullAvatarURL": "", "Avatar/headPitch": 0, "Avatar/pitchSpeed": 75, "Avatar/scale": 1,