First draft of settings backup. Lacks selective restore, any form of notification or error messages yet. FIRE-1723

master
ziree 2013-01-07 21:37:25 +01:00
parent be62b64dab
commit dbe377dd65
13 changed files with 1153 additions and 9 deletions

View File

@ -133,12 +133,16 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
LLControlVariable::LLControlVariable(const std::string& name, eControlType type,
LLSD initial, const std::string& comment,
eSanityType sanityType,LLSD sanityValues,const std::string& sanityComment,
bool persist, bool hidefromsettingseditor
// <FS:Zi> Backup Settings
// bool persist, bool hidefromsettingseditor
bool persist, bool can_backup, bool hidefromsettingseditor
// </FS:Zi>
)
: mName(name),
mComment(comment),
mType(type),
mPersist(persist),
mCanBackup(can_backup), // <FS:Zi> Backup Settings
mHideFromSettingsEditor(hidefromsettingseditor),
mSanityType(sanityType),
mSanityComment(sanityComment)
@ -274,6 +278,13 @@ void LLControlVariable::setPersist(bool state)
mPersist = state;
}
// <FS:Zi> Backup Settings
void LLControlVariable::setBackupable(bool state)
{
mCanBackup = state;
}
// </FS:Zi>
void LLControlVariable::setHiddenFromSettingsEditor(bool hide)
{
mHideFromSettingsEditor = hide;
@ -427,7 +438,10 @@ std::string LLControlGroup::sanityTypeEnumToString(eSanityType sanitytypeenum)
return mSanityTypeString[sanitytypeenum];
}
BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL hidefromsettingseditor)
// <FS:Zi> Backup Settings
//BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL hidefromsettingseditor)
BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL can_backup, BOOL hidefromsettingseditor)
// </FS:Zi>
{
LLControlVariable* existing_control = getControl(name);
if (existing_control)
@ -450,7 +464,10 @@ BOOL LLControlGroup::declareControl(const std::string& name, eControlType type,
}
// if not, create the control and add it to the name table
LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, sanity_type, sanity_value, sanity_comment, persist, hidefromsettingseditor);
// <FS:Zi> Backup Settings
// LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, sanity_type, sanity_value, sanity_comment, persist, hidefromsettingseditor);
LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, sanity_type, sanity_value, sanity_comment, persist, can_backup, hidefromsettingseditor);
// </FS:Zi>
mNameTable[name] = control;
return TRUE;
}
@ -885,6 +902,7 @@ U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only
settings[iter->first]["Type"] = typeEnumToString(control->type());
settings[iter->first]["Comment"] = control->getComment();
settings[iter->first]["Value"] = control->getSaveValue();
settings[iter->first]["Backup"] = control->isBackupable(); // <FS:Zi> Backup Settings
++num_saved;
}
else
@ -937,6 +955,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
{
bool persist = true;
bool can_backup = true; // <FS:Zi> Backup Settings
std::string const & name = itr->first;
LLSD const & control_map = itr->second;
@ -944,7 +963,14 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
{
persist = control_map["Persist"].asInteger();
}
// <FS:Zi> Backup Settings
if(control_map.has("Backup"))
{
can_backup = control_map["Backup"].asInteger();
}
// </FS:Zi>
// Sometimes we want to use the settings system to provide cheap persistence, but we
// don't want the settings themselves to be easily manipulated in the UI because
// doing so can cause support problems. So we have this option:
@ -972,6 +998,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
existing_control->setPersist(persist);
existing_control->setHiddenFromSettingsEditor(hidefromsettingseditor);
existing_control->setComment(control_map["Comment"].asString());
existing_control->setBackupable(can_backup); // <FS:Zi> Backup Settings
}
else
{
@ -997,6 +1024,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
control_map["SanityValue"],
control_map["SanityComment"].asString(),
persist,
can_backup, // <FS:Zi> Backup Settings
hidefromsettingseditor
);
}

View File

@ -120,6 +120,7 @@ private:
eSanityType mSanityType;
std::string mSanityComment;
bool mPersist;
bool mCanBackup; // <FS:Zi> Backup Settings
bool mHideFromSettingsEditor;
std::vector<LLSD> mValues;
std::vector<LLSD> mSanityValues;
@ -134,7 +135,10 @@ public:
eSanityType sanityType,
LLSD sanityValues,
const std::string& sanityComment,
bool persist = true, bool hidefromsettingseditor = false
// <FS:Zi> Backup Settings
// bool persist = true, bool hidefromsettingseditor = false
bool persist = true, bool can_backup = true, bool hidefromsettingseditor = false
// </FS:Zi>
);
virtual ~LLControlVariable();
@ -159,6 +163,7 @@ public:
bool isSane();
bool isSaveValueDefault();
bool isPersisted() { return mPersist; }
bool isBackupable() { return mCanBackup; } // <FS:Zi> Backup Settings
bool isHiddenFromSettingsEditor() { return mHideFromSettingsEditor; }
LLSD get() const { return getValue(); }
LLSD getValue() const { return mValues.back(); }
@ -169,6 +174,7 @@ public:
void setValue(const LLSD& value, bool saved_value = TRUE);
void setDefaultValue(const LLSD& value);
void setPersist(bool state);
void setBackupable(bool state); // <FS:Zi> Backup Settings
void setHiddenFromSettingsEditor(bool hide);
void setComment(const std::string& comment);
@ -237,7 +243,10 @@ public:
};
void applyToAll(ApplyFunctor* func);
BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL hidefromsettingseditor = FALSE);
// <FS:Zi> Backup Settings
// BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL hidefromsettingseditor = FALSE);
BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, eSanityType sanity_type, LLSD sanity_value, const std::string& sanity_comment, BOOL persist, BOOL can_backup = TRUE, BOOL hidefromsettingseditor = FALSE);
// </FS:Zi>
BOOL declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE);
BOOL declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE);
@ -397,7 +406,10 @@ private:
init_value = convert_to_llsd(default_value);
if(type < TYPE_COUNT)
{
group.declareControl(name, type, init_value, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), FALSE);
// <FS:Zi> Backup Settings
// group.declareControl(name, type, init_value, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), FALSE);
group.declareControl(name, type, init_value, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), TRUE, FALSE);
// </FS_Zi>
return true;
}
return false;

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,22 @@
<file name="Warnings"
file_name="ignorable_dialogs.xml"
required="true"/>
<!-- <FS:Zi> Settings Backup -->
<file name="BackupGlobal"
file_name="backup_settings.xml"
required="false"/>
<file name="BackupPerAccount"
file_name="backup_settings_per_account.xml"
required="false"/>
<file name="Colors"
file_name="colors.xml"
required="false"/>
<file name="BackupColors"
file_name="backup_colors.xml"
required="false"/>
<file name="BackupWarnings"
file_name="backup_ignorable_dialogs.xml"/>
<!-- </FS:Zi> -->
</group>
<group name="User"
path_index="1">

View File

@ -100,6 +100,8 @@
<string>String</string>
<key>Value</key>
<string>00000</string>
<key>Backup</key>
<integer>0</integer>
</map>
<key>FSMutedAvatarResponse</key>
<map>
@ -177,6 +179,8 @@
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
<key>Backup</key>
<integer>0</integer>
</map>
<key>LastInventoryInboxActivity</key>
<map>

View File

@ -686,6 +686,7 @@ LLAppViewer::LLAppViewer() :
mPeriodicSlowFrame(LLCachedControl<bool>(gSavedSettings,"Periodic Slow Frame", FALSE)),
mFastTimerLogThread(NULL),
mUpdater(new LLUpdaterService()),
mSaveSettingsOnExit(true), // <FS:Zi> Backup Settings
mSettingsLocationList(NULL)
{
if(NULL != sInstance)
@ -1764,6 +1765,10 @@ bool LLAppViewer::cleanup()
llinfos << "Cleaning Up" << llendflush;
// <FS:Zi> Backup Settings
if(mSaveSettingsOnExit)
{
// </FS:Zi>
// FIRE-4871: Save per-account settings earlier -- TS
std::string per_account_settings_file = gSavedSettings.getString("PerAccountSettingsFile");
if (per_account_settings_file.empty())
@ -1785,6 +1790,13 @@ bool LLAppViewer::cleanup()
}
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
// /FIRE-4871
// <FS:Zi> Backup Settings
}
else
{
llinfos << "Not saving settings, to prevent settings restore failure." << llendl;
}
// </FS:Zi>
// shut down mesh streamer
gMeshRepo.shutdown();
@ -1979,9 +1991,12 @@ bool LLAppViewer::cleanup()
// Must do this after all panels have been deleted because panels that have persistent rects
// save their rects on delete.
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
if(mSaveSettingsOnExit) // <FS:Zi> Backup Settings
{
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
LLUIColorTable::instance().saveUserSettings();
} // <FS:Zi> Backup Settings
//<Firestorm Skin Cleanup>
std::string skinSaved = gSavedSettings.getString("SkinCurrent");
@ -1996,6 +2011,11 @@ bool LLAppViewer::cleanup()
//</Firestorm Skip Cleanup>
// <FS:Zi> Backup Settings
if(mSaveSettingsOnExit)
{
std::string per_account_settings_file = gSavedSettings.getString("PerAccountSettingsFile");
// </FS:Zi>
// PerAccountSettingsFile should be empty if no user has been logged on.
// *FIX:Mani This should get really saved in a "logoff" mode.
// FIRE-4871: use the same file we picked out earlier -- TS
@ -2016,15 +2036,24 @@ bool LLAppViewer::cleanup()
llinfos << "Second time: Saved per-account settings to " <<
per_account_settings_file << llendflush;
}
// <FS:Zi> Backup Settings
}
else
{
llinfos << "Not saving settings, to prevent settings restore failure." << llendl;
}
// </FS:Zi>
// We need to save all crash settings, even if they're defaults [see LLCrashLogger::loadCrashBehaviorSetting()]
gCrashSettings.saveToFile(gSavedSettings.getString("CrashSettingsFile"),FALSE);
//std::string warnings_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Warnings"));
std::string warnings_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("User", "Warnings"));
if(mSaveSettingsOnExit) // <FS:Zi> Backup Settings
gWarningSettings.saveToFile(warnings_settings_filename, TRUE);
// Save URL history file
if(mSaveSettingsOnExit) // <FS:Zi> Backup Settings
LLURLHistory::saveFile("url_history.xml");
// save mute list. gMuteList used to also be deleted here too.

View File

@ -312,6 +312,11 @@ public:
void launchUpdater();
//---------------------------------------------
// <FS:Zi> Backup Settings
void setSaveSettingsOnExit(bool state) {mSaveSettingsOnExit = state; };
bool mSaveSettingsOnExit;
// </FS:Zi>
};
// consts from viewer.h

View File

@ -125,6 +125,15 @@
#include "llviewernetwork.h" // <FS:AW opensim search support>
// <FS:Zi> Backup Settings
#include "llline.h"
#include "llspellcheck.h"
#include "lltoolbarview.h"
#include "llwaterparammanager.h"
#include "llwldaycycle.h"
#include "llwlparammanager.h"
// </FS:Zi>
const F32 MAX_USER_FAR_CLIP = 512.f;
const F32 MIN_USER_FAR_CLIP = 64.f;
//<FS:HG> FIRE-6340, FIRE-6567 - Setting Bandwidth issues
@ -480,6 +489,12 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this));
// <FS:Zi> Backup settings
mCommitCallbackRegistrar.add("Pref.SetBackupSettingsPath", boost::bind(&LLFloaterPreference::onClickSetBackupSettingsPath, this));
mCommitCallbackRegistrar.add("Pref.BackupSettings", boost::bind(&LLFloaterPreference::onClickBackupSettings, this));
mCommitCallbackRegistrar.add("Pref.RestoreSettings", boost::bind(&LLFloaterPreference::onClickRestoreSettings, this));
// </FS:Zi>
gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2));
@ -490,6 +505,34 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
gSavedSettings.getControl("FSPublishRadarTag")->getCommitSignal()->connect(boost::bind(&handlePublishRadarTagOptionChanged, _2));
LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
// <FS:Zi> Backup Settings
// make a list of global files to copy
mGlobalFiles.push_back("bin_conf.dat"); // login credentials and accounts
mGlobalFiles.push_back("colors.xml");
mGlobalFiles.push_back("ignorable_dialogs.xml");
mGlobalFiles.push_back("grids.user.xml");
mGlobalFiles.push_back("settings_autocorrect.xml");
// make a list of per account files to copy
mPerAccountFiles.push_back("asset_blacklist.xml");
mPerAccountFiles.push_back("filters.xml");
mPerAccountFiles.push_back("landmarks_sorting.xml");
mPerAccountFiles.push_back("medialist.xml");
mPerAccountFiles.push_back("muted_groups.xml");
mPerAccountFiles.push_back("toolbars.xml");
mPerAccountFiles.push_back("volume_settings.xml"); // voice chat volumes
mPerAccountFiles.push_back("teleport_history.txt");
// make a list of folders to copy (flat file, non recursive)
mGlobalFolders.push_back("beams"); // custom selection beams
mGlobalFolders.push_back("beamsColors"); // custom selection beam colors
mGlobalFolders.push_back("dictionaries"); // user defined words/ignores
mGlobalFolders.push_back("windlight"); // base windlight settings folder
mGlobalFolders.push_back("windlight/days"); // windlight day cycles
mGlobalFolders.push_back("windlight/skies"); // windlight sky presets
mGlobalFolders.push_back("windlight/water"); // windlight water presets
// </FS:Zi>
}
void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type )
@ -635,6 +678,12 @@ BOOL LLFloaterPreference::postBuild()
// <FS:Ansariel> Show email address in preferences (FIRE-1071)
getChild<LLCheckBoxCtrl>("send_im_to_email")->setLabelArg("[EMAIL]", getString("LoginToChange"));
// <FS:Zi> Backup Settings
// Apparently, line editors don't update with their settings controls, so do that manually here
std::string dir_name=gSavedSettings.getString("SettingsBackupPath");
getChild<LLLineEditor>("settings_backup_path")->setValue(dir_name);
// </FS:Zi>
return TRUE;
}
@ -2943,6 +2992,269 @@ void LLPanelPreferenceSkins::refreshSkinThemeList()
}
// [/SL:KB]
// <FS:Zi> Backup Settings
// copied from llxfer_file.cpp - Hopefully this will be part of LLFile some day -Zi
S32 copy_prefs_file(const std::string& from, const std::string& to)
{
llwarns << "copying " << from << " to " << to << llendl;
S32 rv = 0;
LLFILE* in = LLFile::fopen(from, "rb"); /*Flawfinder: ignore*/
LLFILE* out = LLFile::fopen(to, "wb"); /*Flawfinder: ignore*/
if(in && out)
{
S32 read = 0;
const S32 COPY_BUFFER_SIZE = 16384;
U8 buffer[COPY_BUFFER_SIZE];
while(((read = fread(buffer, 1, sizeof(buffer), in)) > 0)
&& (fwrite(buffer, 1, read, out) == (U32)read)); /* Flawfinder : ignore */
if(ferror(in) || ferror(out)) rv = -2;
}
else
{
rv = -1;
}
if(in) fclose(in);
if(out) fclose(out);
return rv;
}
void LLFloaterPreference::onClickSetBackupSettingsPath()
{
std::string dir_name=gSavedSettings.getString("SettingsBackupPath");
LLDirPicker& picker=LLDirPicker::instance();
if(!picker.getDir(&dir_name))
{
// canceled
return;
}
dir_name=picker.getDirName();
gSavedSettings.setString("SettingsBackupPath",dir_name);
getChild<LLLineEditor>("settings_backup_path")->setValue(dir_name);
}
void LLFloaterPreference::onClickBackupSettings()
{
// get settings backup path
std::string dir_name=gSavedSettings.getString("SettingsBackupPath");
// If we don't have a path yet, ask the user
if(dir_name.empty())
onClickSetBackupSettingsPath();
// If we still don't have a path, do nothing
dir_name=gSavedSettings.getString("SettingsBackupPath");
if(dir_name.empty())
return;
// get path and file names to the relevant settings files
std::string userlower=gDirUtilp->getBaseFileName(gDirUtilp->getLindenUserDir(),false);
std::string backup_per_account_folder=dir_name+gDirUtilp->getDirDelimiter()+userlower;
std::string backup_global_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,
LLAppViewer::instance()->getSettingsFilename("Default","BackupGlobal"));
std::string backup_per_account_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,backup_per_account_folder,
LLAppViewer::instance()->getSettingsFilename("Default","BackupPerAccount"));
std::string per_account_name=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,
LLAppViewer::instance()->getSettingsFilename("Default","PerAccount"));
// define a couple of control groups to store the settings to back up
LLControlGroup backup_global_controls("BackupGlobal");
LLControlGroup backup_per_account_controls("BackupPerAccount");
// functor that will go over all settings in a control group and copy the ones that are
// meant to be backed up
struct f : public LLControlGroup::ApplyFunctor
{
LLControlGroup* group; // our control group that will hold the backup controls
f(LLControlGroup* g) : group(g) {} // constructor, initializing group variable
virtual void apply(const std::string& name, LLControlVariable* control)
{
if(!control->isPersisted() && !control->isBackupable())
{
llwarns << "Settings control " << control->getName() << ": non persistant controls don't need to be set not backupable." << llendl;
return;
}
// only backup settings that are not default, are persistent an are marked as "safe" to back up
if(!control->isDefault() && control->isPersisted() && control->isBackupable())
{
llwarns << control->getName() << llendl;
// copy the control to our backup group
(*group).declareControl(
control->getName(),
control->type(),
control->getValue(),
control->getComment(),
SANITY_TYPE_NONE,
LLSD(),
std::string(),
TRUE); // need to set persisitent flag, or it won't be saved
}
}
} func_global(&backup_global_controls), func_per_account(&backup_per_account_controls);
// run backup on global controls
gSavedSettings.applyToAll(&func_global);
// make sure to write color preferences before copying them
LLUIColorTable::instance().saveUserSettings();
// set it to save defaults, too (FALSE), because our declaration automatically
// makes the value default
backup_global_controls.saveToFile(backup_global_name,FALSE);
for(S32 index=0;index<mGlobalFiles.size();index++)
{
copy_prefs_file(
gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,mGlobalFiles[index]),
gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,mGlobalFiles[index]));
}
// Only back up per-account settings when the path is available, meaning, the user
// has logged in
if(!per_account_name.empty())
{
// create per-user folder if it doesn't exist yet
LLFile::mkdir(backup_per_account_folder.c_str());
// check if the path is actually a folder
if(LLFile::isdir(backup_per_account_folder.c_str()))
{
// run backup on per-account controls
gSavedPerAccountSettings.applyToAll(&func_per_account);
// save defaults here as well (FALSE)
backup_per_account_controls.saveToFile(backup_per_account_name,FALSE);
for(S32 index=0;index<mPerAccountFiles.size();index++)
{
copy_prefs_file(
gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,mPerAccountFiles[index]),
gDirUtilp->getExpandedFilename(LL_PATH_NONE,backup_per_account_folder,mPerAccountFiles[index]));
}
}
else
llwarns << backup_per_account_folder << " is not a folder. Per account settings save aborted." << llendl;
}
// copy global folders and their contents
for(S32 index=0;index<mGlobalFolders.size();index++)
{
std::string file_name;
std::string folder_name=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,mGlobalFolders[index])+gDirUtilp->getDirDelimiter();
std::string backup_folder_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,mGlobalFolders[index])+gDirUtilp->getDirDelimiter();
llwarns << "found folder: " << folder_name << llendl;
// create folder if it's not there already
LLFile::mkdir(backup_folder_name.c_str());
while(gDirUtilp->getNextFileInDir(folder_name,"*",file_name))
{
llwarns << "found entry: " << folder_name+file_name << llendl;
// only copy files, not subfolders
if(LLFile::isfile(folder_name+file_name.c_str()))
{
copy_prefs_file(folder_name+file_name,backup_folder_name+file_name);
}
}
}
}
void LLFloaterPreference::onClickRestoreSettings()
{
// close the window so the restored settings can't be destroyed by the user
onBtnOK();
std::string dir_name=gSavedSettings.getString("SettingsBackupPath");
if(dir_name.empty())
onClickSetBackupSettingsPath();
dir_name=gSavedSettings.getString("SettingsBackupPath");
if(dir_name.empty())
return;
// get path and file names to the relevant settings files
std::string userlower=gDirUtilp->getBaseFileName(gDirUtilp->getLindenUserDir(),false);
std::string backup_per_account_folder=dir_name+gDirUtilp->getDirDelimiter()+userlower;
std::string global_name=gSavedSettings.getString("ClientSettingsFile");
std::string backup_global_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,
LLAppViewer::instance()->getSettingsFilename("Default","BackupGlobal"));
std::string per_account_name=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,
LLAppViewer::instance()->getSettingsFilename("Default","PerAccount"));
std::string backup_per_account_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,backup_per_account_folder,
LLAppViewer::instance()->getSettingsFilename("Default","BackupPerAccount"));
std::string backup_colors_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,
LLAppViewer::instance()->getSettingsFilename("Default","BackupColors"));
std::string warnings_name=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
LLAppViewer::instance()->getSettingsFilename("Default","Warnings"));
std::string backup_warnings_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,
LLAppViewer::instance()->getSettingsFilename("Default","BackupWarnings"));
// start clean
gSavedSettings.resetToDefaults();
// run restore on global controls
gSavedSettings.loadFromFile(backup_global_name);
gSavedSettings.saveToFile(global_name,TRUE);
for(S32 index=0;index<mGlobalFiles.size();index++)
{
copy_prefs_file(
gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,mGlobalFiles[index]),
gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,mGlobalFiles[index]));
}
// Only restore per-account settings when the path is available, meaning, the user
// has logged in
if(!backup_per_account_name.empty())
{
// run restore on per-account controls
gSavedPerAccountSettings.loadFromFile(backup_per_account_name);
gSavedPerAccountSettings.saveToFile(per_account_name,TRUE);
for(S32 index=0;index<mPerAccountFiles.size();index++)
{
copy_prefs_file(
gDirUtilp->getExpandedFilename(LL_PATH_NONE,backup_per_account_folder,mPerAccountFiles[index]),
gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,mPerAccountFiles[index]));
}
}
// toolbars get overwritten when LLToolbarView is destroyed, so make sure
// the toolbars are updated here already
gToolBarView->clearToolbars();
gToolBarView->loadToolbars(FALSE);
// restore global folders and their contents
for(S32 index=0;index<mGlobalFolders.size();index++)
{
std::string file_name;
std::string folder_name=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,mGlobalFolders[index])+gDirUtilp->getDirDelimiter();
std::string backup_folder_name=gDirUtilp->getExpandedFilename(LL_PATH_NONE,dir_name,mGlobalFolders[index])+gDirUtilp->getDirDelimiter();
// create folder if it's not there already
LLFile::mkdir(folder_name.c_str());
while(gDirUtilp->getNextFileInDir(folder_name,"*",file_name))
{
llwarns << "found entry: " << backup_folder_name+file_name << llendl;
// only restore files, not subfolders
if(LLFile::isfile(backup_folder_name+file_name.c_str()))
{
copy_prefs_file(backup_folder_name+file_name,folder_name+file_name);
}
}
}
// Make sure the viewer will not save any settings on exit, so our copied files will survive
LLAppViewer::instance()->setSaveSettingsOnExit(FALSE);
// And quit the viewer so all gets saved immediately
LLApp::instance()->setQuitting();
}
// </FS:Zi>
#ifdef HAS_OPENSIM_SUPPORT// <FS:AW optional opensim support>
//<FS:AW opensim preferences>
static LLRegisterPanelClassWrapper<LLPanelPreferenceOpensim> t_pref_opensim("panel_preference_opensim");

View File

@ -197,6 +197,12 @@ public:
void buildPopupLists();
static void refreshSkin(void* data);
// <FS:Zi> Backup settings
void onClickSetBackupSettingsPath();
void onClickBackupSettings();
void onClickRestoreSettings();
// </FS:Zi>
private:
static std::string sSkin;
bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user.
@ -209,6 +215,13 @@ private:
std::string mDirectoryVisibility;
LLAvatarData mAvatarProperties;
// <FS:Zi> Backup settings
protected:
std::vector<std::string> mGlobalFiles; // list of global settings files to copy
std::vector<std::string> mGlobalFolders; // list of global folders to copy
std::vector<std::string> mPerAccountFiles; // list of per account settings files to copy
// </FS:Zi>
};
class LLPanelPreference : public LLPanel

View File

@ -173,5 +173,12 @@
layout="topleft"
help_topic="preferences_opensim_tab"
name="opensim" />
<panel
class="panel_preference_backup"
filename="panel_preferences_backup.xml"
label="Backup"
layout="topleft"
help_topic="preferences_backup_tab"
name="backup" />
</tab_container>
</floater>

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<panel
border="true"
follows="all"
height="440"
layout="topleft"
left="1"
top="1"
width="540"
label="Backup"
name="backup">
<text
name="backup_path_label"
layout="topleft"
follows="left|top"
top="20"
left="30"
width="80"
height="20">
Backup Path:
</text>
<line_editor
name="settings_backup_path"
control_name="SettingsBackupPath"
layout="topleft"
follows="left|right|top"
left_pad="8"
right="-120"
height="20"/>
<button
layout="topleft"
left_pad="10"
follows="right|top"
height="20"
label="Set"
name="set_backup_settings_path"
width="80" >
<button.commit_callback
function="Pref.SetBackupSettingsPath" />
</button>
<button
layout="topleft"
top_pad="20"
follows="left|top"
height="20"
label="Backup Settings"
left="30"
name="backup_settings"
width="120" >
<button.commit_callback
function="Pref.BackupSettings" />
</button>
<button
layout="topleft"
left_pad="14"
follows="left|top"
height="20"
label="Restore Settings"
name="restore_settings"
width="120" >
<button.commit_callback
function="Pref.RestoreSettings" />
</button>
</panel>

View File

@ -180,5 +180,12 @@
layout="topleft"
help_topic="preferences_opensim_tab"
name="opensim" />
<panel
class="panel_preference_backup"
filename="panel_preferences_backup.xml"
label="Backup"
layout="topleft"
help_topic="preferences_backup_tab"
name="backup" />
</tab_container>
</floater>

View File

@ -9,7 +9,7 @@
help_topic="preferences"
save_rect="true"
single_instance="true"
title="PREFERENCES"
title="Preferences"
width="658">
<floater.string name="LoginToChange">
@ -174,5 +174,12 @@
layout="topleft"
help_topic="preferences_opensim_tab"
name="opensim" />
<panel
class="panel_preference_backup"
filename="panel_preferences_backup.xml"
label="Backup"
layout="topleft"
help_topic="preferences_backup_tab"
name="backup" />
</tab_container>
</floater>