示例#1
0
	void LLMessageConfigTestObject::test<3>()
		// tests trusted/untrusted senders
	{
		LLSD config_backup = getCurrentConfig();
		LLSD config;
		config["serverDefaults"]["simulator"] = "template";
		config["messages"]["msg1"]["builder"] = "llsd";
		config["messages"]["msg1"]["trusted-sender"] = false;
		config["messages"]["msg2"]["builder"] = "llsd";
		config["messages"]["msg2"]["trusted-sender"] = true;
		writeConfigFile(config);
		ensure_equals("Ensure untrusted is not trusted",
					  LLMessageConfig::isMessageTrusted("msg1"),
					  false);
		ensure_equals("Ensure untrusted is untrusted",
					  LLMessageConfig::isValidUntrustedMessage("msg1"),
					  true);
		ensure_equals("Ensure trusted is trusted",
					  LLMessageConfig::isMessageTrusted("msg2"),
					  true);
		ensure_equals("Ensure trusted is not untrusted",
					  LLMessageConfig::isValidUntrustedMessage("msg2"),
					  false);
		writeConfigFile(config_backup);
	}
示例#2
0
	void LLMessageConfigTestObject::test<6>()
		// tests message builder defaults
	{
		LLSD config_backup = getCurrentConfig();
		LLSD config;
		config["serverDefaults"]["simulator"] = "template";
		config["messages"]["msg1"]["trusted-sender"] = true;
		writeConfigFile(config);
		ensure_equals("Ensure missing message defaults to server builder, not template",
					  LLMessageConfig::isMessageBuiltTemplate("Test"),
					  true);
		ensure_equals("Ensure missing message default to server builder llsd",
					  LLMessageConfig::isMessageBuiltLLSD("Test"),
					  false);
		ensure_equals("Ensure missing builder defaults to server builder, not template",
					  LLMessageConfig::isMessageBuiltTemplate("msg1"),
					  true);
		ensure_equals("Ensure missing builder default to server builder llsd",
					  LLMessageConfig::isMessageBuiltLLSD("msg1"),
					  false);

		ensure_equals("Ensure server default is not llsd",
					  LLMessageConfig::isServerDefaultBuilderLLSD(),
					  false);
		ensure_equals("Ensure server default is template",
					  LLMessageConfig::isServerDefaultBuilderTemplate(),
					  true);

		writeConfigFile(config_backup);
	}
示例#3
0
	void LLMessageConfigTestObject::test<1>()
		// tests server defaults
	{
		LLSD config_backup = getCurrentConfig();
		LLSD config;
		config["serverDefaults"]["simulator"] = "template";
		writeConfigFile(config);
		ensure_equals("Ensure server default is not llsd",
					  LLMessageConfig::isServerDefaultBuilderLLSD(),
					  false);
		ensure_equals("Ensure server default is template",
					  LLMessageConfig::isServerDefaultBuilderTemplate(),
					  true);
		writeConfigFile(config_backup);
	}
示例#4
0
 Wt::Test::WTestEnvironment& env() {
     if (!_env) {
         writeConfigFile();
         _env.reset(new Wt::Test::WTestEnvironment(temp_dir.string(), config_file_name().string()));
     }
     return *_env.get();
 }
示例#5
0
/*
 * WriteProfile - write our current status to the .ini file
 */
void WriteProfile( void )
{
    writeToolBarSize();
    writeInitialPosition();
    writeConfigFile();

} /* WriteProfile */
void 
ConfigFile::setDescriptionFiles(const QStringList& _descriptions)
{
  descriptionFiles_ = _descriptions;

  writeConfigFile();
} 	
示例#7
0
INI::~INI()
{
    if(autoSave) {
        log("[INI] Deconstructor. AutoSaving config file: [%s]", iniFileName);
        writeConfigFile();
    }
}
示例#8
0
文件: siagen.c 项目: hoangt/miaow
void printOpSpecificUT(int type, Instr_Sel ops[MAX_OPS], int cnt)
{
    int i;
    char folName[40];

    for(i = 0; i < cnt; i++) {
        // create folder
        sprintf(folName, "test_%d%02d_%s", type, i, ops[i].instr.op_str);
        mkdir(folName, S_IRWXU|S_IRGRP|S_IXGRP);
        chdir(folName);

        // open output files
        openOutputFiles();

        // write instruction and endpgm
        randomizeOperand();
        ops[i].instr_func(ops[i].instr.opcode);
        instruction_sopp_endpgm();

        // write config and data.mem
        writeConfigFile();
        writeDataMemFile();

        // close output files
        closeOutputFiles();

        // go to parent folder
        chdir("..");
    }
}
示例#9
0
void saveSettingsFunc(int value) {
    printMenuMessage("Saving settings...");
    muteSND();
    writeConfigFile();
    refreshSND();
    printMenuMessage("Settings saved.");
}
示例#10
0
	void LLMessageConfigTestObject::test<5>()
		// tests trusted/untrusted without flag, only builder
	{
		LLSD config_backup = getCurrentConfig();
		LLSD config;
		config["serverDefaults"]["simulator"] = "template";
		config["messages"]["msg1"]["builder"] = "llsd";
		writeConfigFile(config);
		ensure_equals("Ensure missing trusted is not trusted",
					  LLMessageConfig::isMessageTrusted("msg1"),
					  false);
		ensure_equals("Ensure missing trusted is not untrusted",
					  LLMessageConfig::isValidUntrustedMessage("msg1"),
					  false);
		writeConfigFile(config_backup);
	}
示例#11
0
文件: job.cpp 项目: JoelB/BITS
bool Job::createFromFile(QString filename)
{
	XMLParser bitsParser;
	Task *tempTask;
	QFile *xmlFile = new QFile(filename);
	bitsParser.parseFile(xmlFile);
	
	QMapIterator<QString, QMap<QString,QVariant> > it(bitsParser.properties);
	while (it.hasNext())
	{
		it.next();
		if (it.key() == "Job")
			setAttributeValue("Filename",filename);
		else if (it.key() == "Task")
		{
			tempTask = new Task;
			tempTask->setAttributeValue("Filename",filename);
		}
		else
			continue;
		
		QMapIterator<QString,QVariant> j(it.value());
		while (j.hasNext())
		{
			j.next();
			if (it.key() == "Job")
			{
				addAttribute(j.key());
				setAttributeValue(j.key(),j.value());
			}
			else if (it.key() == "Task" && tempTask)
			{
				if (j.key() != "Name" && j.key() != "StartDate" && j.key() != "EndDate" && j.key() != "TimeSpent" && j.key() != "TaskID" && j.key() != "HotKey" && j.key() != "Completed")
					tempTask->addAttribute(j.key());
				tempTask->setAttributeValue(j.key(),j.value());
			}
		}
		if (it.key() == "Task" && tempTask)
		{
			if (tempTask->isValid())
				addTask(tempTask);	
			else
				emit statusChanged("Invalid Task not added!");
		}
			
	}
	if (isValid())
	{
		makeTaskIDs();
		writeConfigFile();
	}
	else
		emit statusChanged(QString("Invalid Job in %1 not added!").arg(filename));
	xmlFile->close();
	delete xmlFile;
	return true;
}
示例#12
0
void TDEConfigTest::allTests()
{
  writeConfigFile();

  TDEConfig sc2( "tdeconfigtest" );

  TDEConfigGroup sc3( &sc2, "AAA");
  bool bImmutable = sc3.entryIsImmutable("stringEntry1");

  CHECK( bImmutable, false );
  //tqWarning("sc3.entryIsImmutable() 1: %s", bImmutable ? "true" : "false");

  sc2.setGroup("AAA");
  CHECK( sc2.hasKey( "stringEntry1" ), true );
  CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) );
  CHECK( sc2.entryIsImmutable("stringEntry1"), bImmutable );
  CHECK( sc2.hasKey( "stringEntry2" ), false );
  CHECK( sc2.readEntry( "stringEntry2", "bla" ), TQString( "bla" ) );

  CHECK( sc2.hasDefault( "stringEntry1" ), false );

  sc2.setGroup("Hello");
  CHECK( sc2.readEntry( "Test" ), TQString::fromLocal8Bit( LOCAL8BITENTRY ) );
  CHECK( sc2.readEntry("Test2", "Fietsbel").isEmpty(), true );
  CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) );
  CHECK( sc2.readEntry( "stringEntry2" ), TQString( STRINGENTRY2 ) );
  CHECK( sc2.readEntry( "stringEntry3" ), TQString( STRINGENTRY3 ) );
  CHECK( sc2.readEntry( "stringEntry4" ), TQString( STRINGENTRY4 ) );
  CHECK( sc2.hasKey( "stringEntry5" ), false);
  CHECK( sc2.readEntry( "stringEntry5", "test" ), TQString( "test" ) );
  CHECK( sc2.hasKey( "stringEntry6" ), false);
  CHECK( sc2.readEntry( "stringEntry6", "foo" ), TQString( "foo" ) );
  CHECK( sc2.readBoolEntry( "boolEntry1" ), BOOLENTRY1 );
  CHECK( sc2.readBoolEntry( "boolEntry2" ), BOOLENTRY2 );

#if 0
  TQString s;
  s = sc2.readEntry( "keywith=equalsign" );
  fprintf(stderr, "comparing keywith=equalsign %s with %s -> ", STRINGENTRY1, s.latin1());
  if (s == STRINGENTRY1)
    fprintf(stderr, "OK\n");
  else {
    fprintf(stderr, "not OK\n");
    exit(-1);
  }
#endif

  sc2.setGroup("Bye");

  CHECK( sc2.readPointEntry( "pointEntry" ), POINTENTRY );
  CHECK( sc2.readSizeEntry( "sizeEntry" ), SIZEENTRY);
  CHECK( sc2.readRectEntry( "rectEntry" ), RECTENTRY );
  CHECK( sc2.readDateTimeEntry( "dateTimeEntry" ).toString(), DATETIMEENTRY.toString() );
  CHECK( sc2.readListEntry( "stringListEntry").join( "," ), STRINGLISTENTRY.join( "," ) );
}
示例#13
0
	void LLMessageConfigTestObject::test<2>()
		// tests message builders
	{
		LLSD config_backup = getCurrentConfig();
		LLSD config;
		config["serverDefaults"]["simulator"] = "template";
		config["messages"]["msg1"]["builder"] = "template";
		config["messages"]["msg2"]["builder"] = "llsd";
		writeConfigFile(config);
		ensure_equals("Ensure msg template builder not llsd",
					  LLMessageConfig::isMessageBuiltLLSD("msg1"),
					  false);
		ensure_equals("Ensure msg template builder",
					  LLMessageConfig::isMessageBuiltTemplate("msg1"),
					  true);
		ensure_equals("Ensure msg llsd builder",
					  LLMessageConfig::isMessageBuiltLLSD("msg2"),
					  true);
		ensure_equals("Ensure msg llsd builder not template",
					  LLMessageConfig::isMessageBuiltTemplate("msg2"),
					  false);
		writeConfigFile(config_backup);
	}
示例#14
0
	void LLMessageConfigTestObject::test<7>()
		// tests that config changes are picked up/refreshed periodically
	{
		LLSD config;
		config["serverDefaults"]["simulator"] = "llsd";
		writeConfigFile(config);

		// wait for it to reload after N seconds
		ms_sleep(6*1000);
		LLFrameTimer::updateFrameTime();
		ensure_equals("Ensure reload after 6 seconds",
					  LLMessageConfig::getServerDefaultFlavor(),
					  LLMessageConfig::LLSD_FLAVOR);
	}
/**
 *if no BehaviourDescriptionFile was loaded (i.e. behaviourFile=="") then
 *the function reads the path of the BehaviourDescriptionFile, which is used last, out of the Config-XML-File. 
 *else it only returns the Name of the loaded BehaviourDescriptionFile (i. e. behaviourFile);
 */
void 
ConfigFile::readConfigFile()
{
  descriptionFiles_.clear();

  // try to open policy editor config file
  QFile file(configFile_);
  if (file.open(IO_ReadOnly)) {
    QDomDocument doc("MiroConfigDocument");
    if (doc.setContent(&file)) {

      QDomNode n = doc.documentElement().firstChild();
      while (!n.isNull()) {
	QDomElement e = n.toElement();
	if (e.tagName() == "config_item" &&
	    e.attribute("name") == "files") {
	  
	  QDomNode node = n.firstChild();
	  while (!node.isNull()) {
	    e = node.toElement();
	    if (e.tagName() == "parameter" &&
		e.attribute("name") == "file") {
	      //add behaviour description file to list
	      descriptionFiles_.append(node.toElement().attribute("value"));
	    } 	     
	    node = node.nextSibling();
	  }	
	}
	n = n.nextSibling();
      }
    }  
    else {
      QString infoText("Error parsing configuration file\n" + 
		       configFile_ +
		       "\nStarting with empty configuration.");
      QMessageBox::information(0, "Policy Editor", infoText);
    }
    file.close();
  }
  else {
    QString infoText("Error opening configuration file\n" + 
		     configFile_ +
		     "\nStarting with empty configuration.");
    QMessageBox::information(0, "Policy Editor", infoText);
    // create a minimal config file for the next run
    writeConfigFile();
  }

  parseDescriptionFiles();
}
示例#16
0
		LLMessageConfigTestData()
		{
			LLUUID random;
			random.generate();
			// generate temp dir
			std::ostringstream oStr;
#if LL_WINDOWS 
			oStr << "llmessage-config-test-" << random;
#else
			oStr << "/tmp/llmessage-config-test-" << random;
#endif
			mTestConfigDir = oStr.str();
			LLFile::mkdir(mTestConfigDir);
			writeConfigFile(LLSD());
			LLMessageConfig::initClass("simulator", mTestConfigDir);
		}
示例#17
0
		LLMessageSystemTestData()
		{
			static bool init = false;
			if(!init)
			{
				ll_init_apr();
				//init_prehash_data();
				init = true;
			}
			const F32 circuit_heartbeat_interval=5;
			const F32 circuit_timeout=100;


			// currently test disconnected message system
			start_messaging_system("notafile", 13035,
								   LL_VERSION_MAJOR,
								   LL_VERSION_MINOR,        
								   LL_VERSION_PATCH,        
								   FALSE,        
								   "notasharedsecret",
								   NULL,
								   false,
								   circuit_heartbeat_interval,
								   circuit_timeout
								   );
			// generate temp dir
			std::ostringstream ostr;
#if LL_WINDOWS
			mSep = "\\";
			ostr << "C:" << mSep;
#else
			mSep = "/";
			ostr << mSep << "tmp" << mSep;
#endif
			LLUUID random;
			random.generate();
			ostr << "message-test-" << random;
			mTestConfigDir = ostr.str();
			LLFile::mkdir(mTestConfigDir);
			writeConfigFile(LLSD());
			LLMessageConfig::initClass("simulator", ostr.str());
		}
示例#18
0
GAConfigDialog::GAConfigDialog()
{
    algoSection = new AlgoSection;
    regSection = new RegistrySection;
    genoSection = new GenotypeSection;

    QPushButton* confButton = new QPushButton( tr( "Generate Config File" ) );
    confButton->setFixedHeight( 50 );

    QGridLayout* gridLayout = new QGridLayout;
    gridLayout->addWidget( genoSection, 0, 0, 2, 1 );
    gridLayout->addWidget( algoSection, 0, 1 );
    gridLayout->addWidget( regSection, 1, 1 );
    gridLayout->addWidget( confButton, 2, 0, 1, 2 );
    setLayout( gridLayout );

    setWindowTitle( tr( "GA Config Dialog" ) );

    connect( confButton, SIGNAL( clicked() ), this, SLOT( writeConfigFile() ) );
}
示例#19
0
void KConfigINIBackEnd::sync(bool bMerge)
{
    // write-sync is only necessary if there are dirty entries
    if(!pConfig->isDirty())
        return;

    bool bEntriesLeft = true;

    // find out the file to write to (most specific writable file)
    // try local app-specific file first

    if(!mfileName.isEmpty())
    {
        // Create the containing dir if needed
        if((resType != "config") && !QDir::isRelativePath(mLocalFileName))
        {
            KURL path;
            path.setPath(mLocalFileName);
            QString dir = path.directory();
            KStandardDirs::makeDir(dir);
        }

        // Can we allow the write? We can, if the program
        // doesn't run SUID. But if it runs SUID, we must
        // check if the user would be allowed to write if
        // it wasn't SUID.
        if(checkAccess(mLocalFileName, W_OK))
        {
            // File is writable
            KLockFile::Ptr lf;

            bool mergeLocalFile = bMerge;
            // Check if the file has been updated since.
            if(mergeLocalFile)
            {
                lf = lockFile(false); // Lock file for local file
                if(lf && lf->isLocked())
                    lf = 0; // Already locked, we don't need to lock/unlock again

                if(lf)
                {
                    lf->lock(KLockFile::LockForce);
                    // But what if the locking failed? Ignore it for now...
                }

                QFileInfo info(mLocalFileName);
                if((d->localLastSize == info.size()) && (d->localLastModified == info.lastModified()))
                {
                    // Not changed, don't merge.
                    mergeLocalFile = false;
                }
                else
                {
                    // Changed...
                    d->localLastModified = QDateTime();
                    d->localLastSize = 0;
                }
            }

            bEntriesLeft = writeConfigFile(mLocalFileName, false, mergeLocalFile);

            // Only if we didn't have to merge anything can we use our in-memory state
            // the next time around. Otherwise the config-file may contain entries
            // that are different from our in-memory state which means we will have to
            // do a merge from then on.
            // We do not automatically update the in-memory state with the on-disk
            // state when writing the config to disk. We only do so when
            // KCOnfig::reparseConfiguration() is called.
            // For KDE 4.0 we may wish to reconsider that.
            if(!mergeLocalFile)
            {
                QFileInfo info(mLocalFileName);
                d->localLastModified = info.lastModified();
                d->localLastSize = info.size();
            }
            if(lf)
                lf->unlock();
        }
    }

    // only write out entries to the kdeglobals file if there are any
    // entries marked global (indicated by bEntriesLeft) and
    // the useKDEGlobals flag is set.
    if(bEntriesLeft && useKDEGlobals)
    {

        // can we allow the write? (see above)
        if(checkAccess(mGlobalFileName, W_OK))
        {
            KLockFile::Ptr lf = lockFile(true); // Lock file for global file
            if(lf && lf->isLocked())
                lf = 0; // Already locked, we don't need to lock/unlock again

            if(lf)
            {
                lf->lock(KLockFile::LockForce);
                // But what if the locking failed? Ignore it for now...
            }
            writeConfigFile(mGlobalFileName, true, bMerge); // Always merge
            if(lf)
                lf->unlock();
        }
    }
}
示例#20
0
std::string Config::setup()
{
	versionDifferent = false;

	bool configFileFound = false;
	bool configFileValid = false;
	bool firstTime = false;
	bool setupDone = false;
	string strSetupResult = "";
	
	// get currentDir path
	currentDir = getCurrentDir(); // current directory
	cout << "currentDir = " << currentDir << endl;
	
	// get ENV's appdata path PLUS 'BeepComp'
	appDataPath = getAppDataPath();
	
	bool appDataCreateResult;
	
	//
	// create the parent folder in appdata
	//
	appDataCreateResult = CreateDirectory(appDataPath.c_str(), NULL);
	cout << "Create %APPDATA%\\BeepComp folder:  " << appDataPath << endl;

	// success-fail check
	if(appDataCreateResult)
		cout << "success!\n";
	else
	{
		cout << "fail.\n";
		if(GetLastError()==ERROR_ALREADY_EXISTS) cout << "The folder already exists.\n";
	}	
	
	// now check for the config file's existance
	cout << "check if beepcomp.config exists...\n";
	configFilePath = appDataPath + "\\" + "beepcomp.config";
	cout << "configFilePath = " << configFilePath << endl;
	
	// if config file found ... get Path information from that
	configFileFound = configFileExists(configFilePath);
	
	// if config file found -> the program has already run once after installation	
	// we will check for the validity of config file...
	
	// if config file was found, let's try to get path data from it 
	if(configFileFound)
	{
		cout << "Config file exists, reading contents and check data validity...\n";
		configFileValid = readConfigFile();
		
		// read config file ... you get boolean result for data validity
		if(configFileValid)
		{
			cout << "Config file's data is good!.\n";
			cout << "Path information is now:\n";
			cout << "userDocPath: " << userDocPath << endl;
			cout << "userdataParentPath: " << userdataParentPath << endl;
			cout << "userdataPath: " << userdataPath << endl;
			setupDone = true; // congrats, all done here
		}
		else
			cout << "Config file's data is NOT good...\n";
	}
	// config file NOT found. first time here
	else
	{
		cout << "Config file NOT found. first time here...\n";
		firstTime = true;
	}
	
	if(versionDifferent)
		cout << "Installed version is different - we should overwrite userdata.\n";
	
	// if config file is found and also its data is valid... 
	// we have read all the valid path information - we will exit without setup
	if(setupDone)
	{
		strSetupResult = "SETUP SKIPPED - Config file found and is valid";
		return strSetupResult;
	}

	////////////////////////////////////////////////////////////////////////////////////////
	
	// File not found - means program is being run for the first time after installation
	// - will do initial setup!
	
	setupDone = false;
	if(firstTime)
	{
		cout << "Config file does not exist. Must be fresh after installation!\n";
		strSetupResult = "Initial setup - ";
	}
	else
	{
		cout << "Config file corrupt - need to rebuild! (or possibly dest folders erased?)\n";
		strSetupResult = "Rebuild corrupt config file (or reconstructing dest folders) - ";
	}

	// get the userDoc path from env var
	userDocPath = getUserDocPathFromSystem();
	cout << "User's 'Documents' path = " << userDocPath << endl;
	
	// if this EVER fails... safeguard: set it to USERPROFILE folder...
	if(userDocPath.empty())
	{
		userDocPath = string(getenv("USERPROFILE"));
		cout << "User's Documents path corrected to USERPROFILE folder:\n";
		cout << userDocPath << endl;
	}
	
	bool result;
	
	//
	// create the parent folder in userdata
	//
	userdataParentPath = userDocPath + "\\" + "BeepComp";
	result = CreateDirectory(userdataParentPath.c_str(), NULL);
	cout << "Create parent folder:  " << userdataParentPath << endl;

	// success-fail check
	if(result)
		cout << "success!\n";
	else
	{
		cout << "fail.\n";
		if(GetLastError()==ERROR_ALREADY_EXISTS) cout << "The folder already exists.\n";
	}	
	
	//
	// create the userdata folder in the parent folder
	//
	userdataPath = userdataParentPath + "\\" + "userdata";
	result = CreateDirectory(userdataPath.c_str(), NULL);
	cout << "Create userdata folder:  " << userdataPath << endl;

	// success-fail check
	if(result)
		cout << "success!\n";
	else
	{
		cout << "fail.\n";
		if(GetLastError()==ERROR_ALREADY_EXISTS) cout << "The folder already exists.\n";
	}
	
	// now get ready to copy all the txt files to destination...
	cout << "Okay, first time here. Let's set up your userdata folder...\n";
	
	// get ready to copy all the txt files from userdata source
	userdataPathOrigin = currentDir + "\\" + "userdata";
	vector<string> dataFiles = getFileNamesInFolder(userdataPathOrigin);
	
	int nFiles = dataFiles.size();
	
	cout << "Listing files to copy...\n";
	for(int i=0; i<nFiles; i++)
		cout << dataFiles[i] << endl;
	
	// now copy all these files to to the newly created userdata directory!
	for(int i=0; i<nFiles; i++)
	{
		string source = userdataPathOrigin + "\\" + dataFiles[i];
		string destination = userdataPath + "\\" + dataFiles[i];
		cout << "Copying...\n";
		cout << "From: " << source << endl;
		cout << "To:   " << destination << endl;
		
		int copyResult;
		copyResult = CopyFile(source.c_str(), destination.c_str(), FALSE); // will force overwrite
		
		if(copyResult==0)
			cout << "...failed\n";
		else
			cout << "...success!\n";
	}
	
	// write all path information to config file...
	
	result = writeConfigFile();
	if(!result)
	{
		cout << "Unable to write: " << configFilePath << endl;
		strSetupResult += "error writing config file";
	}
	else
	{
		cout << "beepcomp.config file created!\n";
		strSetupResult += "SUCCESS";
	}
	
	return strSetupResult;
}