Beispiel #1
0
U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only)
{
    LLSD settings;
    int num_saved = 0;
    for (ctrl_name_table_t::iterator iter = mNameTable.begin();
            iter != mNameTable.end(); iter++)
    {
        LLControlVariable* control = iter->second;
        if (!control)
        {
            llwarns << "Tried to save invalid control: " << iter->first << llendl;
        }

        if( control && control->isPersisted() )
        {
            if (!(nondefault_only && (control->isSaveValueDefault())))
            {
                settings[iter->first]["Type"] = typeEnumToString(control->type());
                settings[iter->first]["Comment"] = control->getComment();
                settings[iter->first]["Value"] = control->getSaveValue();
                ++num_saved;
            }
            else
            {
                // Debug spam
                // llinfos << "Skipping " << control->getName() << llendl;
            }
        }
    }
    llofstream file;
    file.open(filename);
    if (file.is_open())
    {
        LLSDSerialize::toPrettyXML(settings, file);
        file.close();
        llinfos << "Saved to " << filename << llendl;
    }
    else
    {
        // This is a warning because sometime we want to use settings files which can't be written...
        llwarns << "Unable to open settings file: " << filename << llendl;
        return 0;
    }
    return num_saved;
}
Beispiel #2
0
void LLControlGroup::connectCOAVars(LLControlGroup &OtherGroup)
{
    LLControlVariable *pCOAVar = NULL;
    for (ctrl_name_table_t::iterator iter = mNameTable.begin();
            iter != mNameTable.end(); iter++)
    {
        if(iter->second->isCOA())
        {
            LLControlVariable *pParent = iter->second;
            LLControlVariable *pChild = OtherGroup.getControl(pParent->getName());
            if(!pChild)
            {
                OtherGroup.declareControl(
                    pParent->getName(),
                    pParent->type(),
                    pParent->getDefault(),
                    pParent->getComment(),
                    pParent->isPersisted(),
                    true);

                pChild = OtherGroup.getControl(pParent->getName());
            }
            if(pChild)
            {
                pParent->setCOAConnect(pChild,true);
                pChild->setCOAConnect(pParent,false);
            }
        }
        else if(iter->second->getName() == "AscentStoreSettingsPerAccount")
            pCOAVar = iter->second;
    }
    if(pCOAVar)
    {
        pCOAVar->getSignal()->connect(boost::bind(&LLControlGroup::handleCOASettingChange, this, _2));
        pCOAVar->firePropertyChanged();
    }
}
U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only)
{
	LLSD settings;
	int num_saved = 0;
	for (ctrl_name_table_t::iterator iter = mNameTable.begin();
		 iter != mNameTable.end(); iter++)
	{
		LLControlVariable* control = iter->second;
		if (!control)
		{
			LL_WARNS("Settings") << "Tried to save invalid control: " << iter->first << LL_ENDL;
		}
		else if( control->shouldSave(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;
		}
	}
	llofstream file;
	file.open(filename.c_str());
	if (file.is_open())
	{
		LLSDSerialize::toPrettyXML(settings, file);
		file.close();
		LL_INFOS("Settings") << "Saved to " << filename << LL_ENDL;
	}
	else
	{
        // This is a warning because sometime we want to use settings files which can't be written...
		LL_WARNS("Settings") << "Unable to open settings file: " << filename << LL_ENDL;
		return 0;
	}
	return num_saved;
}