virtual void ProcessSelectionL( TInt aIndex ) 
	{
		CALLSTACKITEM_N(_CL("CAutoStartup"), _CL("ProcessSelectionL"));
		TBool enable = aIndex == 0;
		ProcessManagement::SetAutoStartEnabledL(Fs(), DataDir()[0], enable);
		NotifyActionReadyL(); 
	}
	virtual void ProcessSelectionL( TInt aIndex ) 
	{
		CALLSTACKITEM_N(_CL("CNetworkAccess"), _CL("ProcessSelectionL"));
		if ( aIndex == 0 )
			{
				Settings().WriteSettingL(SETTING_ACCEPTED_NETWORK_ACCESS, ETrue);
				Settings().WriteSettingL(SETTING_ALLOW_NETWORK_ONCE, ETrue);
				Settings().WriteSettingL(SETTING_PRESENCE_ENABLE, ETrue);
				NotifyActionReadyL(); 
			}
		else
			{
				TBool yes = ShowYesNoMessageL( R_TEXT_WELCOME_CONFIRM_NO_NETWORK_ACCESS, R_TEXT_WELCOME_CONFIRM_NO_NETWORK_ACCESS_TITLE );
				if ( yes )
					{
						Settings().WriteSettingL(SETTING_ACCEPTED_NETWORK_ACCESS, EFalse);
						Settings().WriteSettingL(SETTING_ALLOW_NETWORK_ONCE, EFalse);
						Settings().WriteSettingL(SETTING_ALLOW_NETWORK_ACCESS, EFalse);
						ProcessManagement::SetAutoStartEnabledL(Fs(), DataDir()[0], EFalse);
						NotifyQuitWelcomeL();
					}
				else 
					{
						// no-op. returns to selection view
					}
			}
	}
void CSmsSnapshotImpl::Error(TInt aCode, const TDesC& aDescription)
{
	CALLSTACKITEM_N(_CL("CSmsSnapshotImpl"), _CL("Error"));

	if (iDeleting) return;

	iRetryCount++;
	if (iRetryCount<=5) {
		iSnapShot->TakeSnapShot(DataDir(), this);
		cb->status_change(aDescription);
		cb->status_change(_L("retrying snapshot"));
		return;
	}

	TSendTo t=iToBeSend->Pop();
	auto_ptr<HBufC> b(HBufC::NewL(aDescription.Length()+30+t.iBody.Length()));
	b->Des().Append(_L("Failed to take picture: "));
	b->Des().Append(aDescription);
	b->Des().Append(_L(" for "));
	b->Des().Append(t.iBody);
#ifndef TESTING
	if (t.iTo.Length()>0)
		iMMS->SendMessage(t.iTo, *b, _L(""), t.iBody, false);
#endif

	b->Des().Zero();
	b->Des().Append(aDescription);
	b->Des().Append(_L(": "));
	b->Des().AppendNum(aCode);
	cb->error(*b);
}
EXPORT_C void CCall_record::test()
{
	CALLSTACKITEM_N(_CL("CCall_record"), _CL("test"));

	cb->status_change(_L("recording call"));
	TFileName filen;
	Mfile_output_base::make_filename(filen, DataDir(), _L("rec"), _L("amr"));
	recorder->record(filen);
}
EXPORT_C void bases::ConstructL(bool aConvertOnly, CCellMap* aCellMap) {
	TRAPD(err, bases::InnerConstructL(aConvertOnly, aCellMap));
	if (err == KErrCorrupt) {
	    Destruct();
		TFileName database_filename;
		database_filename.Format(_L("%S%S"), &DataDir(), &database_file);
		User::LeaveIfError(BaflUtils::DeleteFile(Fs(), database_filename));
		InnerConstructL(aConvertOnly, aCellMap);
	}
}
void CSmsSnapshotImpl::expired(CBase* /*Source*/)
{
	CALLSTACKITEM_N(_CL("CSmsSnapshotImpl"), _CL("expired"));

	iToBeSend->AppendL(TSendTo(KNullDesC, _L("automatic snapshot")));

	cb->status_change(_L("taking picture"));
	iSnapShot->TakeSnapShot(DataDir(), this);

	if (iInterval>0) iTimer->Wait(iInterval);
}
void CTest_Downloader::setUp()
{
	MContextTestBase::setUp();
	{
		TFileName fn=DataDir();
		fn.Append(_L("UTDL1.db"));
		Fs().Delete(fn);
		iDb=CDb::NewL(AppContext(), _L("UTDL1"), EFileWrite, false);
	}
	iNoAvkonIconsWas=TestSupport().NoAvkonIcons();
	TestSupport().SetNoAvkonIcons(ETrue);
	User::LeaveIfError(iSocketServ.Connect());
}
/**
 * @brief locate spring data directory
 *
 * On *nix platforms, attempts to locate
 * and change to the spring data directory
 *
 * The data directory to chdir to is determined by the following, in this
 * order (first items override lower items): 
 *
 * - 'SpringData=/path/to/data' declaration in '~/.springrc'. (colon separated list)
 * - 'SPRING_DATADIR' environment variable. (colon separated list, like PATH)
 * - In the same order any line in '/etc/spring/datadir', if that file exists.
 * - 'datadir=/path/to/data' option passed to 'scons configure'.
 * - 'prefix=/install/path' option passed to scons configure. The datadir is
 *   assumed to be at '$prefix/games/taspring' in this case.
 * - the default datadir in the default prefix, ie. '/usr/local/games/taspring'
 *
 * All of the above methods support environment variable substitution, eg.
 * '$HOME/myspringdatadir' will be converted by spring to something like
 * '/home/username/myspringdatadir'.
 *
 * If it fails to chdir to the above specified directory spring will asume the
 * current working directory is the data directory.
 */
void UnixFileSystemHandler::LocateDataDirs()
{
	// Construct the list of datadirs from various sources.

	datadirs.clear();

	std::string cfg = configHandler.GetString("SpringData","");
	if (!cfg.empty())
		AddDirs(SubstEnvVars(cfg));

	char* env = getenv("SPRING_DATADIR");
	if (env && *env)
		AddDirs(SubstEnvVars(env));

	FILE* f = ::fopen("/etc/spring/datadir", "r");
	if (f) {
		char buf[1024];
		while (fgets(buf, sizeof(buf), f)) {
			char* newl = strchr(buf, '\n');
			if (newl)
				*newl = 0;
			datadirs.push_back(SubstEnvVars(buf));
		}
		fclose(f);
	}

	datadirs.push_back(SubstEnvVars(SPRING_DATADIR));

	// Figure out permissions of all datadirs

	DeterminePermissions();

	if (!writedir) {
		// add current working directory to search path & try again
		fprintf(stderr, "WARNING: adding current working directory to search path\n");
		char buf[4096];
		getcwd(buf, sizeof(buf));
		buf[sizeof(buf) - 1] = 0;
		datadirs.push_back(DataDir(buf));
		DeterminePermissions(datadirs.size() - 1);
	}

	if (!writedir) {
		// bail out
		throw content_error("not a single read-write data directory found!");
	}

	// for now, chdir to the datadirectory as a safety measure:
	// all AIs still just assume it's ok to put their stuff in the current directory after all
	chdir(GetWriteDir().c_str());
}
Beispiel #9
0
void ScriptTestSetup(ScriptInterface& ifc)
{
	ifc.RegisterFunction<void, std::wstring, script_TS_FAIL>("TS_FAIL");

	// Load the TS_* function definitions
	// (We don't use VFS because tests might not have the normal VFS paths loaded)
	OsPath path = DataDir()/"tests"/"test_setup.js";
	std::ifstream ifs(OsString(path).c_str());
	ENSURE(ifs.good());
	std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
	std::wstring wcontent(content.begin(), content.end());
	bool ok = ifc.LoadScript(L"test_setup.js", wcontent);
	ENSURE(ok);
}
void CCall_record::handle_answered()
{
	CALLSTACKITEM_N(_CL("CCall_record"), _CL("handle_answered"));

	if (!can_record || NoSpaceLeft() || !recorder->IsIdle()) {
		cb->error(_L("Cannot record"));
		return;
	}

	if ( record_all || iSpecialGroups->is_special_contact() ) {
		cb->status_change(_L("recording call"));
		TFileName filen;
		Mfile_output_base::make_filename(filen, DataDir(), _L("rec"), _L("amr"));
		recorder->record(filen);
		can_record=false;
	}
}
bool CSmsSnapshotImpl::handle_reception(const TMsvId& , 
										const TMsvId& , const TDesC& sender, 
										const TDesC& body)
{
	CALLSTACKITEM_N(_CL("CSmsSnapshotImpl"), _CL("handle_reception"));


	 // return true if message is to be deleted
	if (!iEnabled) return false;
	//if (sender.Length()<4) return false;
	iToBeSend->AppendL(TSendTo(sender, body));

	cb->status_change(_L("taking picture"));
	iSnapShot->TakeSnapShot(DataDir(), this);

	return true;
}
	void RunAsync() {
		CALLSTACKITEM_N(_CL("CPrivacyStatement"), _CL("RunL"));

		TInt acceptedPrivacyVersion = 0;		
		Settings().GetSettingL(SETTING_ACCEPTED_PRIVACY_STMT_VERSION, acceptedPrivacyVersion);
		
		if ( acceptedPrivacyVersion < KJaikuPrivacyStatementVersion )
			{
				TPtrC text(*iText);
				TPtrC header(*iHeader);
				auto_ptr<CAknMessageQueryDialog> dlg( CAknMessageQueryDialog::NewL(text) );
				dlg->SetHeaderTextL( header );
				iDlg = dlg.get();
				TBool result = dlg.release()->ExecuteLD( R_PRIVACYSTATEMENT_DIALOG );
			  if (!iDlg) {
			    iAsync->TriggerAsync();
			    return;
			  }
				if (result)
					{
					  iDlg = NULL;
						Settings().WriteSettingL(SETTING_ACCEPTED_PRIVACY_STMT_VERSION, KJaikuPrivacyStatementVersion);
						NotifyActionReadyL();
					}
				else
					{
					  iDlg = NULL;
						// do not write, keep old accepted version 
						ProcessManagement::SetAutoStartEnabledL(Fs(), DataDir()[0], EFalse);
						NotifyQuitWelcomeL();
					}
			}
		else
			{
				NotifyActionReadyL();
			}
	}
wxString FileNames::PlugInDir()
{
   return FileNames::MkDir( wxFileName( DataDir(), wxT("Plug-Ins") ).GetFullPath() );
}
wxString FileNames::NRPDir()
{
   return FileNames::MkDir( wxFileName( DataDir(), wxT("NRP") ).GetFullPath() );
}
wxString FileNames::ChainDir()
{
   return FileNames::MkDir( wxFileName( DataDir(), wxT("Chains") ).GetFullPath() );
}
void CContextLocaAppUi::HandleCommandL(TInt aCommand)
{
	CALLSTACKITEM_N(_CL("CContextLocaAppUi"), _CL("HandleCommandL"));

	SetInHandlableEvent(ETrue);
#ifdef __WINS__
	TInt err;
	TBreakItem b(GetContext(), err);
#endif
	if (BaseHandleCommandL(aCommand)) return;

	switch ( aCommand )
	{
	case Econtext_logCmdAppPauseLog:
		Settings().WriteSettingL(SETTING_LOGGING_ENABLE, EFalse);
		break;
	case Econtext_logCmdAppUnPauseLog:
		Settings().WriteSettingL(SETTING_LOGGING_ENABLE, ETrue);
		break;
	case Econtext_logCmdCancelSend:
		// do nothing
		break;
	case Econtext_logCmdAppSettings:
		ActivateLocalViewL(KSettingsViewId);
		break;
	case Econtext_logCmdDumpCommDb:
		{
		CCommDbDump* dump=CCommDbDump::NewL();
		dump->DumpDBtoFileL(_L("c:\\commdb.txt"));
		delete dump;
		}
		break;
	case Econtext_logCmdCreateAp:
		{
		CreateAPL(_L("cingular"),
			_L("WAP.CINGULAR"),
			_L("*****@*****.**"),
			_L("CINGULAR1"));
		}
		break;
	case Econtext_logCmdStartSensors:
		{
			if  (!iSensorRunner)
				iSensorRunner=CSensorRunner::NewL(
					AppContext(), smsh, EFalse, *this);
		}
		break;

	case Econtext_logCmdAppTest:
		{
		//loc->test();
		//recorder->test();
		DialogTest();
		}
		break;
	case Econtext_logCmdAppImsi:
		{
			/*if (loc) status_change(loc->GetImsi());
			else */{
#ifndef __WINS__
				TBuf<20> machineId;
				GetImeiL(machineId);
				status_change(machineId);
#else
				// Return a fake IMEI when working on emulator
				_LIT(KEmulatorImsi, "244050000000000");
				status_change(KEmulatorImsi);
#endif
			}
		}
			
		break;
	default:
		if (aCommand>Econtext_logCmdSendAppUi || aCommand==Econtext_logCmdSendFtp) {
			
			if (aCommand==Econtext_logCmdSendFtp) {
				//iPeriodicTransfer->Transfer(false);
				//iPeriodicTransfer->Transfer(true);
			} else {
				status_change(_L("trying transfer"));

				/*
				cellid_name_file.Close();
				*/
				
				TFileName transfer_cellid_filen, cellid_filen;
				transfer_cellid_filen.Format(_L("%S%S"), &AppDir(), &transfer_cellid_file);
				cellid_filen.Format(_L("%S%S"), &DataDir(), &cellid_file);

				TInt ferr=BaflUtils::CopyFile(Fs(), cellid_filen, transfer_cellid_filen);
				if (ferr!=KErrNone) {
					TBuf<30> errmsg;
					errmsg.Format(_L("copy: %d"), ferr);
					error(errmsg);
					return;
				}
				/*
				ferr=cellid_name_file.Open(Fs(), cellid_filen, 
					EFileShareAny | EFileStreamText | EFileRead | EFileWrite);
				if (ferr!=KErrNone) {
					TBuf<30> errmsg;
					errmsg.Format(_L("reopen: %d, RESTART NOW"), ferr);
					error(errmsg);
					return;
				}
				*/
				iLog->switch_file();

				transferer->transfer_files(aCommand);
			}
			
		}
		break;
	}
}
void CContextLocaAppUi::ConstructL()
{
	CALLSTACKITEM_N(_CL("CContextLocaAppUi"), _CL("ConstructL"));

#ifndef __WINS__
	bool wins=false;
	{
		TInt err;
		TRAP(err, SetSilentL());
	}
#else
	bool wins=true;
	TInt ignore;
	TBreakItem i(GetContext(), ignore);

#if 0
	BBSession()->DeleteL(KListener, ETrue);
	BBSession()->DeleteL(KLocaErrorTuple, 
		KNullDesC, ETrue);
	BBSession()->DeleteL(KListenerStop, 
		KNullDesC, ETrue);
	BBSession()->DeleteL(KLocaScriptTuple, 
		KNullDesC, ETrue);
	BBSession()->DeleteL(KLocaMessageStatusTuple, 
		KNullDesC, ETrue);

	//Settings().WriteSettingL(SETTING_CONTEXTNW_HOST, _L("10.1.0.1"));
	Settings().WriteSettingL(SETTING_CONTEXTNW_HOST, _L("loca.hiit.fi"));
	Settings().WriteSettingL(SETTING_CONTEXTNW_PORT, 5000);
	Settings().WriteSettingL(SETTING_CONTEXTNW_ENABLED, ETrue);
	Settings().WriteSettingL(SETTING_PUBLISH_AUTHOR,
		_L("Loca@South hall"));
	Settings().WriteSettingL(SETTING_PUBLISH_PASSWORD,
		_L("emulator"));
	Settings().WriteSettingL(SETTING_BT_SCAN_INTERVAL, 5);
	Settings().WriteSettingL(SETTING_ENABLE_LOCA_BLUEJACK, ETrue);
	Settings().WriteSettingL(SETTING_LOCA_BLUEJACK_MESSAGE_TIMEOUT, 90);
	Settings().WriteSettingL(SETTING_LOCA_BLUEJACK_CONNECT_COUNT, 7);
#endif

#endif

	CContextLogAppUiBase::ConstructL();
	state=_L("subscribeL");

#ifndef DONT_LOG_EVENTS_TO_FILE

	iLog->SubscribeL(KCellIdTuple);
#ifdef __WINS__
	iLog->SubscribeL(KBluetoothTuple);
	iLog->SubscribeL(KLocaMessageStatusTuple);
#endif
	iLog->SubscribeL(KOwnBluetoothTuple);
	iLog->SubscribeL(KBatteryTuple);
	iLog->SubscribeL(KNetworkTuple);
	iLog->SubscribeL(KChargerTuple);
	iLog->SubscribeL(KAppEventTuple);

#else
	// we always want errors to be logged
	iLog->SubscribeL(KAppEventTuple);
#endif

	state=_L("bbl");

	{
		TBool logging_enabled;
		Settings().GetSettingL(SETTING_LOGGING_ENABLE, logging_enabled);
		TInt notif_err;
		CC_TRAP(notif_err, iLoggingRunning=CNotifyState::NewL(AppContext(), KIconFile));
		if (logging_enabled) {
			if(iLoggingRunning) iLoggingRunning->SetCurrentState( EMbmContextlocaL, EMbmContextlocaL );
		} else {
			if(iLoggingRunning) iLoggingRunning->SetCurrentState( EMbmContextlocaL_not, EMbmContextlocaL_not );
		}
	}

	state=_L("LocaSender");
	iLocaSender=CLocaSender::NewL(AppContext());

	state=_L("notify");

	Settings().NotifyOnChange(SETTING_LOGGING_ENABLE, this);

	state=_L("sms status");
	if (smsh) iSmsStatus=CSmsStatusReplier::NewL(AppContext(), smsh);

	ConstructAfterPresenceMaintainerL();

	TInt ap;
	TRAPD(err, ap=CreateAPL(_L("cingular"),
		_L("WAP.CINGULAR"),
		_L("*****@*****.**"),
		_L("CINGULAR1")));
#ifndef __WINS__
	if (err==KErrNone) 
		Settings().WriteSettingL(SETTING_IP_AP, ap);
#endif

#ifndef __WINS__
	TRAP(err, SyncTimeL(EFalse));
	if (err!=KErrNone) {
		TBuf<50> msg=_L("Failed to sync time: ");
		msg.AppendNum(err);
		LogAppEvent(msg);
	}
#else
	TimeSynced(ETrue);
#endif

	state=_L("create transferer");
	transferer=CSendUITransfer::NewL(AppContext(), this, 
		Econtext_logCmdSendAppUi, DataDir(), AppDir());
	transferer->add_filesL(_L("log*txt"), true);
	transferer->add_filesL(_L("starter*txt"), true);
	transferer->add_filesL(_L("book*txt"), true);
	transferer->add_filesL(_L("calllog*txt"), true);
	transferer->add_filesL(_L("comm*txt"), false);
	transferer->add_filesL(_L("rec*amr"), false);
	transferer->add_filesL(_L("cellid_names_trans.txt"), false);
	transferer->add_filesL(_L("mms*.*"), false);

	state=_L("create settings view");

	{
		auto_ptr<CSettingsView> iSettingsView(CSettingsView::NewL(KSettingsViewId, AppContext(), 
			TLocalAppSettings::GetEnabledSettingsArray()));
		AddViewL(iSettingsView.get());
		iSettingsView.release();
	}

	FinalConstructL();
/*
	TBBLocaMsgStatus msg;
	msg.iAtTime()=GetTime();
	msg.iMessageId()=15;
	msg.iRecipientAddress=TBBBluetoothAddress( TPtrC8((TUint8*)"\0\0\0\0\0\x01", 6),
		_L("myphone"));
	TTime exp; exp=GetTime(); exp+=TTimeIntervalHours(12);
	BBSession()->PutL(KLocaMessageStatusTuple, KNullDesC,
		&msg, exp);
	CErrorLogger* e=CErrorLogger::NewL();
	e->LogFormatted(_L("Example of a terrible error"));
	delete e;
	CBBDumper* d=CBBDumper::NewL();
*/
}
void bases::InnerConstructL(bool aConvertOnly, CCellMap* aCellMap)
{
	CALLSTACKITEM_N(_CL("bases"), _CL("ConstructL"));

	iConvertOnly=aConvertOnly;

	if (!aConvertOnly) {
		Mlogger::ConstructL(AppContextAccess());
		Mlog_base_impl::ConstructL();
		iBBSubSessionNotif->AddNotificationL(KCellIdTuple, ETrue);

		iEvent.iData.SetValue(&iLocation); iEvent.iData.SetOwnsValue(EFalse);

		cell_hash=CGenericIntMap::NewL();
		// initial values
		learning_done=false;
		first_time=GetTime();

		previous_time=previous_day=first_time;
		scale=1.0;

	}
	TInt dbver=0;

	MoveIntoDataDirL(AppContext(), database_file);

	TFileName database_filename_install, database_filename;
	database_filename_install.Format(_L("%S%S"), &AppDir(), &database_file_install);
	database_filename.Format(_L("%S%S"), &DataDir(), &database_file);

	if (BaflUtils::FileExists(Fs(), database_filename_install)) {
		User::LeaveIfError(BaflUtils::CopyFile(Fs(), database_filename_install, database_filename));
		User::LeaveIfError(BaflUtils::DeleteFile(Fs(), database_filename_install));
		Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER);
		learning_done=true;
	}

	dbver=LATEST_DBVER;
	Settings().GetSettingL(SETTING_BASEDB_VERSION, dbver);

	auto_ptr<CDbColSet> cols(CDbColSet::NewL());

	TInt colno=1;
	cols->AddL(TDbCol(col_id, EDbColUint32)); colno_id=colno++;
	cols->AddL(TDbCol(col_t, EDbColReal64) ); colno_t=colno++;
	cols->AddL(TDbCol(col_f, EDbColUint32) ); colno_f=colno++;
	cols->AddL(TDbCol(col_isbase, EDbColBit) ); colno_isbase=colno++;
	cols->AddL(TDbCol(col_last_seen, EDbColDateTime) ); colno_last_seen=colno++;
	cols->AddL(TDbCol(col_iscurrent, EDbColBit) ); colno_iscurrent=colno++;

	TInt store_exists;
	CC_TRAP(store_exists, store = CPermanentFileStore::OpenL(Fs(), database_filename, EFileRead|EFileWrite));
	if (store_exists!=KErrNone) {
		dbver=LATEST_DBVER;
		Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER);
	}

	if (dbver<2) {
		cols->AddL(TDbCol(col_cellid, EDbColText)); colno_cellid=colno++;
	}
	cols->AddL(TDbCol(col_merged_to, EDbColUint32)); colno_merged_to=colno++;
	cols->AddL(TDbCol(col_unaged_t, EDbColReal64) ); colno_unaged_t=colno++;
	cols->AddL(TDbCol(col_rescaled, EDbColUint32) ); colno_rescaled=colno++;

	if (store_exists==KErrNone) { 
		db.OpenL(store, store->Root());
		User::LeaveIfError(db.Recover());
		db_open=true;

		RDebug::Print(_L("converting database..."));
		User::LeaveIfError(db.AlterTable(table_cells, *cols));
		RDebug::Print(_L("converting database done."));

		User::LeaveIfError(table.Open(db, table_cells));
		table_open=true;
		// read cells in order
		read_from_database(aConvertOnly, aCellMap);
		
	} else {
		if (aConvertOnly) return;

		// construct database
		store = CPermanentFileStore::ReplaceL(Fs(), database_filename, EFileRead|EFileWrite);
		store->SetTypeL(store->Layout());
		TStreamId id=db.CreateL(store);
		db_open=true;
		store->SetRootL(id);
		store->CommitL();

		User::LeaveIfError(db.CreateTable(table_cells, *cols));

		auto_ptr<CDbKey> idx_key(CDbKey::NewL());
		idx_key->AddL(TDbKeyCol(col_id));
		idx_key->MakeUnique();
		User::LeaveIfError(db.CreateIndex(idx_id, table_cells, *idx_key));
		idx_key->Clear();
		idx_key->AddL(TDbKeyCol(col_t));
		User::LeaveIfError(db.CreateIndex(idx_t, table_cells, *idx_key));

		User::LeaveIfError(table.Open(db, table_cells));
		table_open=true;
		User::LeaveIfError(table.SetIndex(idx_id));

		Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER);
	}
	if (aConvertOnly) return;

	if (! bases_info) {
		bases_info=new (ELeave) cell_list_node(0, first_time);
		bases_info->id=0;
		bases_info->t=scale;
		bases_info->merged_to=0;
		bases_info->last_seen=first_time;
		update_database(bases_info, false);
	}

	iGraph=CDirectedGraph::NewL(db, _L("GRAPH"));
	iMerged=CMerged::NewL(db, _L("MERGE"));
	iCandidates=CList<TCandidate>::NewL();

	iTimer=CTimeOut::NewL(*this);
	iTimer->Wait(CELL_REFRESH);
}
Beispiel #19
0
wxString FileNames::PluginSettings()
{
   return wxFileName( DataDir(), wxT("pluginsettings.cfg") ).GetFullPath();
}
EXPORT_C void bases::test(COperatorMap* aOpMap, CCellMap* aCellMap)
{
	CALLSTACKITEM_N(_CL("bases"), _CL("test"));

#ifdef __WINS__ 
	aOpMap->AddRef();

	iTimer->Reset();

	testing=true; bool first=true;
	test_flags=0;
	scale=1.0; proportion=0.9;
	learning_done=false;

	RFile testf;
	TFileText test;
	int ts_len=15;
	TBuf<128> filen;
	TBuf<256> line;
	TBuf<30> id_d, dt_d;
	filen.Append(DataDir());
	filen.Append(_L("bases_test_data.txt"));

	op=Cfile_output_base::NewL(AppContext(), _L("bases"));
	Cfile_output_base& o=*op;

	CBBSensorEvent e(KCell, KCellIdTuple);
	TBBCellId cell(KCell);
	e.iData.SetValue(&cell); e.iData.SetOwnsValue(EFalse);

	if (testf.Open(Fs(), filen, 
		EFileShareAny | EFileStreamText | EFileRead)==KErrNone) {
		CleanupClosePushL(testf);
		test.Set(testf);
		int j=0;
	

		//int beg=23000, end=230000;
		int beg=0, end=0;

		while ( test.Read(line) == KErrNone && j < end) {
		//for (int i=0;i<TEST_DATA_COUNT; i++) {
			if (! (j % 1000) ) {
				TBuf<40> msg;
				msg.Format(_L("Testing at %d"), j);
				RDebug::Print(msg);
			}
			j++;
			if (j>=beg) {
				dt_d=line.Left(ts_len);
				id_d=line.Mid(ts_len+1);
				
				TTime time(dt_d);
				now=time;
				if (first) { 
					previous_time=now; first_time=now; first=false; 
					previous_day=previous_time;
				}
				if (! id_d.Compare(_L("SWITCH"))) {
					started=true;
				} else {
					e.iStamp()=time;
					CCellMap::Parse(id_d, cell.iCellId(), cell.iLocationAreaCode(), cell.iShortName());
					if (cell.iCellId()==0 && cell.iLocationAreaCode()==0) {
						cell.iMCC()=0;
						cell.iMNC()=0;
					} else {
						aOpMap->NameToMccMnc(cell.iShortName(), cell.iMCC(),
 cell.iMNC());
					}
					cell.iMappedId()=aCellMap->GetId(cell);
					NewSensorEventL(KNoTuple, KNullDesC, e); // name is ignored
				}
			}
		}
		CleanupStack::PopAndDestroy(); // testf
	}

	e.iData.SetValue(0);

	if (! (test_flags & NO_DB_UPDATE) ) {
		read_from_database(false, 0);
	}

	line.Format(_L("total %f\n"), total_t);
	o.write_to_output(line);
	cell_list_node* n=first_cell;
	while (n) {
		TInt base=0;
		if (n->is_base) base=1;
		line.Format(_L("%d: t %f f %d cum_t %f base %d merged to %d\n"),
			n->id, n->t, n->f, n->cum_t, base, n->merged_to);
		o.write_to_output(line);
		n=n->next;
	}

	o.write_to_output(_L("MAPPINGS:\n"));
	aCellMap->PrintMapping(o);

	delete op;

	User::LeaveIfError(table.SetIndex(idx_id));

	testing=false;
	//clear();

	iTimer->Wait(CELL_REFRESH);
	aOpMap->Release();
#endif
}
wxString FileNames::PluginsCache()
{
   return wxFileName( DataDir(), wxT("plugins.cfg") ).GetFullPath();
}
/**
 * @brief locate spring data directory
 *
 * On *nix platforms, attempts to locate
 * and change to the spring data directory
 *
 * The data directory to chdir to is determined by the following, in this
 * order (first items override lower items):
 *
 * - 'SpringData=/path/to/data' declaration in '~/.springrc'. (colon separated list)
 * - 'SPRING_DATADIR' environment variable. (colon separated list, like PATH)
 * - In the same order any line in '/etc/spring/datadir', if that file exists.
 * - 'datadir=/path/to/data' option passed to 'scons configure'.
 * - 'prefix=/install/path' option passed to scons configure. The datadir is
 *   assumed to be at '$prefix/games/taspring' in this case.
 * - the default datadir in the default prefix, ie. '/usr/local/games/taspring'
 *
 * All of the above methods support environment variable substitution, eg.
 * '$HOME/myspringdatadir' will be converted by spring to something like
 * '/home/username/myspringdatadir'.
 *
 * If it fails to chdir to the above specified directory spring will asume the
 * current working directory is the data directory.
 */
void UnixFileSystemHandler::LocateDataDirs()
{
	// Construct the list of datadirs from various sources.

	datadirs.clear();

	char* env = getenv("SPRING_DATADIR");
	if (env && *env)
		AddDirs(SubstEnvVars(env));

	std::string cfg = configHandler.GetString("SpringData","");
	if (!cfg.empty())
		AddDirs(SubstEnvVars(cfg));

	FILE* f = ::fopen("/etc/spring/datadir", "r");
	if (f) {
		char buf[1024];
		while (fgets(buf, sizeof(buf), f)) {
			char* newl = strchr(buf, '\n');
			if (newl)
				*newl = 0;
			datadirs.push_back(SubstEnvVars(buf));
		}
		fclose(f);
	}

#ifdef SPRING_DATADIR
	datadirs.push_back(SubstEnvVars(SPRING_DATADIR));
#endif
#ifdef SPRING_DATADIR_2
	datadirs.push_back(SubstEnvVars(SPRING_DATADIR_2));
#endif

	// Figure out permissions of all datadirs
	bool cwdWarning = false;

	DeterminePermissions();

	if (!writedir) {
		// add current working directory to search path & try again
		char buf[4096];
		getcwd(buf, sizeof(buf));
		buf[sizeof(buf) - 1] = 0;
		datadirs.push_back(DataDir(buf));
		DeterminePermissions(datadirs.size() - 1);
		cwdWarning = true;
	}

	if (!writedir) {
		// bail out
		throw content_error("not a single read-write data directory found!");
	}

	// for now, chdir to the datadirectory as a safety measure:
	// all AIs still just assume it's ok to put their stuff in the current directory after all
	// Not only safety anymore, it's just easier if other code can safely assume that
	// writedir == current working directory
	chdir(GetWriteDir().c_str());

	// delayed warning message (needs to go after chdir otherwise log file ends up in wrong directory)
	if (cwdWarning)
		logOutput.Print("Warning: Adding current working directory to search path.");
}
wxString FileNames::ThemeDir()
{
   return FileNames::MkDir( wxFileName( DataDir(), wxT("Theme") ).GetFullPath() );
}
Beispiel #24
0
wxString FileNames::PluginRegistry()
{
   return wxFileName( DataDir(), wxT("pluginregistry.cfg") ).GetFullPath();
}