// -----------------------------------------------------------------------------
// CWPInternetAPDB::CreateandOpenL
// -----------------------------------------------------------------------------
//    
void CSCOMOAdapterDb::CreateandOpenL(TParse& name)
    {

    TInt err;

#ifdef SYMBIAN_SECURE_DBMS
    iDatabase.Create(iRdbSession, name.FullName(), KDBMSSecureID);
#else
    if( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, KEmptyDbSizeEstimate ) )
        {
        User::Leave( KErrDiskFull );
        }
    iDatabase.Create(iFsSession, name.FullName());
#endif	

    CreateTableL(iDatabase);
    iDatabase.Close();
#ifdef SYMBIAN_SECURE_DBMS

    err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID);

#else
    err = iDatabase.Open(iFsSession, DBFileName);
#endif

    //Debug
    if (err != KErrNone)
        {

        User::LeaveIfError(err);
        }

    }
示例#2
0
LOCAL_C void ScanDirL(RFs& aFs, const TDesC& aDir)
	{
	User::After(1000000);

	TParse parse;
	parse.Set(_L("t_*.exe"), &aDir, NULL);
	TPtrC spec(parse.FullName());

	test.Start(parse.DriveAndPath());
	TFindFile find(aFs);
	CDir* dir;
	
	if (!find.FindWildByPath(parse.FullName(), NULL, dir))
		{
		CleanupStack::PushL(dir);

		for(int i = 0; i < dir->Count(); i++)
			{
			parse.Set((*dir)[i].iName, &spec, NULL);

			if (i == 0)
				test.Start(parse.FullName());
			else
				test.Next(parse.FullName());

			LaunchAndWaitL(parse.FullName());
			}

		CleanupStack::PopAndDestroy(); // dir
		}
	test.End();
	}
示例#3
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-3350
@SYMTestCaseDesc	    Direct file store verification test
@SYMTestPriority 	    High
@SYMTestActions  	    Open a corrupted direct store file
@SYMTestExpectedResults the function called leaves with KErrNotSupported
@SYMDEF                 DEF100757
*/
LOCAL_C void DirectFileL()
	{
	Test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-3350 Creating Direct File Store "));
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KTestDirectFileName, NULL);
	
	// create a direct file store
	TheStore=CDirectFileStore::ReplaceLC(TheFs,parse.FullName(),EFileWrite);
	TheStore->SetTypeL(TheStore->Layout());
	TInt8 val=100;
	TStreamId id=TheSink.CreateL(*TheStore);
	TheSink<<val;
	TheSink.Close();
	TheStore->SetRootL(id);
	TheStore->CommitL();
	CleanupStack::PopAndDestroy(TheStore);

	// corrupt the store file
	RFile file;

	User::LeaveIfError(file.Open(TheFs,parse.FullName(),EFileWrite));
	CleanupClosePushL(file);
	User::LeaveIfError(file.Write(KTestJunkData,sizeof(TCheckedUid)));
	CleanupStack::PopAndDestroy(&file);

	// the CDirectFileStore::OpenLC should leave if passed the corrupted store file name
	TheStore = NULL;
	TRAPD(r, \
			{\
			TheStore=CDirectFileStore::OpenLC(TheFs,parse.FullName(),EFileRead);\
			CleanupStack::PopAndDestroy(TheStore); \
			}\
		);
// -----------------------------------------------------------------------------
// CSecModUIModel::AddResourceFileL()
// -----------------------------------------------------------------------------
//
void CSecModUIModel::AddResourceFileL()
  {
  LOG_ENTERFN("CSecModUIModel::AddResourceFileL()");
    // Resource file loading
  RFs& fs = iEikEnv->FsSession();

  TFileName fileName;

  TParse parse;
  // secmodui.rsc
    parse.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, NULL);

  fileName = parse.FullName();

  BaflUtils::NearestLanguageFile( fs, fileName );
  iResourceFileOffset = iEikEnv->AddResourceFileL( fileName );

  // CertManUI.rsc
  parse.Set(KResourceFile2, &KDC_RESOURCE_FILES_DIR, NULL);
    fileName = parse.FullName();
    BaflUtils::NearestLanguageFile( fs, fileName );
    iResourceFileOffset2 = iEikEnv->AddResourceFileL( fileName );

  // CTSecDlg.rsc
  parse.Set(KResourceFile3, &KDC_RESOURCE_FILES_DIR, NULL);
    fileName = parse.FullName();
    BaflUtils::NearestLanguageFile( fs, fileName );
    iResourceFileOffset3 = iEikEnv->AddResourceFileL( fileName );

  LOG_LEAVEFN("CSecModUIModel::AddResourceFileL()");
  }
示例#5
0
void ThreadTestL(TInt aThread)
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse testIniFile;
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
	
	TIniData data;
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(fs,testIniFile.FullName(),KTestUid);
	data.LoadL(*dict);
	CleanupStack::PopAndDestroy(); // dict

	TParse threadTestPath;
	threadTestPath.Set(drive.Name(), &KThreadTestPath, NULL);
	
	TFileName name;
	name.Format(threadTestPath.FullName(),aThread);
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
	data.SaveL(*dict);
	dict->CommitL();
	CleanupStack::PopAndDestroy();
	TReal x=0.501;
	for (TInt ii=0;ii<1000;++ii)
		x=4.0*x*(1.0-x);
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
	data.LoadL(*dict);
	CleanupStack::PopAndDestroy();	// dict
	fs.Delete(name);
	CleanupStack::PopAndDestroy();	// fs
	}
// ----------------------------------------------------------------------------
// Symbian 2nd phase constructor can leave.
// ----------------------------------------------------------------------------
//
void CWrtHarvester::ConstructL()
    {
    User::LeaveIfError( iApaSession.Connect() );
    iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
    iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
    
    User::LeaveIfError( iFs.Connect() );
    iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs );
    
    iWidgetUsbListener->Start();
    SetMSMode(0);
    
    TFileName resourceFileName;  
    TParse parse;    
    Dll::FileName (resourceFileName);           
    parse.Set(KResourceFileName, &resourceFileName, NULL); 
    resourceFileName = parse.FullName(); 
          
    CCoeEnv* coeEnv = CCoeEnv::Static(); 
    BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceFileName); 
       
    if ( !BaflUtils::FileExists( coeEnv->FsSession(), resourceFileName ) )
        { 
        // Use resource file on the Z drive instead  
        parse.Set( KResourceDir, &KDC_RESOURCE_FILES_DIR, NULL ); 
        resourceFileName = parse.FullName();  
        BaflUtils::NearestLanguageFile( coeEnv->FsSession(),resourceFileName );            
        } 
    iResourceFileOffset = coeEnv->AddResourceFileL(resourceFileName);
    }
示例#7
0
void CStateDownload::ScanDirectory(RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aFilesArray)
	{
	TParse parse;
	parse.Set(aWild, &aDir, NULL);
	TPtrC spec(parse.FullName());
	 
	TFindFile FindFile(aFs);
	CDir* dir;
	 
	if (FindFile.FindWildByPath(parse.FullName(), NULL, dir) == KErrNone)
		{
	    CleanupStack::PushL(dir);
	 
	    TInt count=dir->Count();
	    for(TInt i = 0; i < count; i++)
	    	{
	        parse.Set((*dir)[i].iName, &spec, NULL);
	        TEntry entry;
	        if(aFs.Entry(parse.FullName(),entry) == KErrNone)
	        	{
	        	if(!entry.IsDir())
	        		{
	        		//InsertIsqL raises a KErrAlreadyExists (-11) when inserting a duplicate
	        		TRAPD(err,aFilesArray->InsertIsqL(parse.FullName())); 
	        		}
	        	}
	        }
	    CleanupStack::PopAndDestroy(dir);
	    }
	}
示例#8
0
TBool CFileSelectDialog::OkToExitL(TInt aButton)
	{
	TInt selected=ListBox()->CurrentItemIndex();
	_LOGDATA(_L("Selected: %d"),selected);
	if (aButton==EAknSoftkeyCancel){return ETrue;}
	if (iCurrentPath.Compare(_L(""))==0)
		{
		_LOG(_L("(iCurrentPath.Compare(_L(""))==0)"));
		_LOG(iCurrentPath);
		iCurrentPath.Append(iArray->MdcaPoint(selected));
		iCurrentPath.Append(_L("\\"));
		if (BaflUtils::PathExists(iFs,iCurrentPath)){Update();Show();return EFalse;}
		//Update();
		}
	else if ((selected>1&&iType==EFolder)||(selected>0&&iType==EFile))
		{
		_LOG(_L("((selected>1)&&(iCurrentPath.Compare(_L(""))!=0))"));
		_LOG(iCurrentPath);
		TBuf<255> temp(iArray->MdcaPoint(selected));
		TChar c1='[',c2=']';
		if (temp[0]==c1&&temp[temp.Length()-1]==c2) {temp.Copy(temp.Left(temp.Length()-1));temp.Copy(temp.Right(temp.Length()-1));}
		_LOGDATA(_L("Temp: %S"),&temp);
		iCurrentPath.Append(temp);
		iCurrentPath.Append(_L("\\"));
		_LOGDATA(_L("CurrPath after append: %S"),&iCurrentPath);
		CEikonEnv::Static()->InfoMsg(iCurrentPath);
		User::After(500000);
		if (BaflUtils::PathExists(iFs,iCurrentPath)){Update();Show();return EFalse;}
		else if (BaflUtils::FileExists(iFs,iCurrentPath.Left(iCurrentPath.Length()-1)))
			{
			iResult.Copy(iCurrentPath.Left(iCurrentPath.Length()-1));
			return ETrue;
			}
		}
	else if (selected==0)
		{
		_LOG(_L("(selected==0&&(iCurrentPath.Compare(_L(""))!=0))"));
		_LOG(iCurrentPath);
		TParse p;
		iFs.Parse(iCurrentPath, p);
		_LOG(_L("Will pop now"))
		TInt err=p.PopDir();
		if (err!=KErrNone||iCurrentPath.Compare(p.FullName())==0){iCurrentPath.Copy(_L(""));}
		else {iCurrentPath.Copy(p.FullName());}
		//if (iCurrentPath.Compare(_L(""))!=0)
		Update();Show();return EFalse;
		}
	else if (selected==1&&iType==EFolder&&(iCurrentPath.Compare(_L(""))!=0))
		{
		_LOG(_L("Will update result"));
		iResult.Copy(iCurrentPath);
		return ETrue;
		}
	Update();Show();return EFalse;
	}
示例#9
0
void CWsShellLogon::ConstructL(RFs &)
	{
	CActiveScheduler::Add(this);
	TPtrC shellCmd;

	_LIT(KWSERVIniFileVarShellCmd,"SHELLCMD");
	WsIniFile->FindVar(KWSERVIniFileVarShellCmd,shellCmd);
	_LIT(KWSERVShellName,"SHELL");
	TPtrC startUp(KWSERVShellName);
	_LIT(KWSERVIniFileVarStartUp,"STARTUP");
	WsIniFile->FindVar(KWSERVIniFileVarStartUp,startUp);


	TParse fileName;
	_LIT(KWSERVArmShellLocationPattern,"Z:\\sys\\bin\\.EXE");
	User::LeaveIfError(fileName.SetNoWild(startUp,&KWSERVArmShellLocationPattern,NULL));
#if defined(__WINS__)
	TInt err=iShellProcess.Create(fileName.FullName(),shellCmd);
	if (err == KErrNone)
		{
		Request();
		iShellProcess.Resume();
		}
	else
		{
		// Try loading the matching DLL name instead?
		_LIT(KWSERVShellExtension,"Z:.DLL");
		User::LeaveIfError(fileName.Set(KWSERVShellExtension,&startUp,NULL));
		User::LeaveIfError(iLib.Load(fileName.FullName()));
		ShellEntryPoint libFunc=(ShellEntryPoint)iLib.Lookup(1);
		if (!libFunc)
			User::Leave(KErrGeneral);
		TBuf<256> name;
		TInt num=0;
		TInt ret=KErrNone;
		do
			{
			_LIT(KWSERVWinsShellInstanceName,"Shell%d");
			name.Format(KWSERVWinsShellInstanceName,num++);
			ret=iShellThread.Create(name,libFunc,KDefaultStackSize,&shellCmd,&iLib,NULL,KHeapSize,KMaxHeapSize,EOwnerProcess);
			} while(ret==KErrAlreadyExists);
		User::LeaveIfError(ret);
		Request();
		iShellThread.Resume();
		}
#else // not __WINS__
	User::LeaveIfError(iShell.Create(fileName.FullName(),shellCmd));
	Request();
	iShell.Resume();
#endif	
	return;

	}
示例#10
0
void static ClearSessionDirectory()
//
// Delete the contents of F32-TST
//
{
    TParse sessionPath;
    TInt r=TheFs.Parse(_L("\\F32-TST\\"),_L(""),sessionPath);
    test_KErrNone(r);
    RecursiveRmDir(sessionPath.FullName());
    r=TheFs.MkDir(sessionPath.FullName());
    test_KErrNone(r);
}
示例#11
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1191
@SYMTestCaseDesc	    Lock out of dictionary files test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for opening of same dictionary file.Tests for file in use error
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void ContentionTestL()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1191 Contention tests "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse testIniFile;
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
	
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
	TIniData data;
	data.SaveL(*dict);
	CleanupStack::PopAndDestroy(); // dict

	test.Next(_L("Lock-out test"));
	CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
	TUint tick=User::TickCount();
	TRAPD(r,CDictionaryFileStore::OpenL(TheFs,testIniFile.FullName(),KTestUid));
	tick=User::TickCount()-tick;
	test (r==KErrInUse);
	test.Printf(_L("Lock-out discovered: %d ticks\r\n"),tick);
	CleanupStack::PopAndDestroy();

	test.Next(_L("Creating threads"));
	RThread threads[KNumThreads];
	TRequestStatus status[KNumThreads];
	TInt ii;
	for (ii=0;ii<KNumThreads;++ii)
		{
		TName name;
		name.Format(_L("Test_%d"),ii);
		test (threads[ii].Create(name,ThreadTest,KThreadStack,KThreadHeap,KThreadHeapMax,(TAny*)ii,EOwnerThread)==KErrNone);
		threads[ii].SetPriority(EPriorityLess);
		threads[ii].Logon(status[ii]);
		test (status[ii]==KRequestPending);
		}

	for (ii=0;ii<KNumThreads;++ii)
		threads[ii].Resume();

	test.Next(_L("Waiting for completion"));
	for (ii=0;ii<KNumThreads;++ii)
		User::WaitForAnyRequest();
	TInt success=0;
	for (ii=0;ii<KNumThreads;++ii)
		{
		test (status[ii]!=KRequestPending);
		if (status[ii].Int()==KErrNone)
			++success;
		}
	test.Printf(_L("Thread success: %d of %d\r\n"),success,KNumThreads);
	test.End();
	}
示例#12
0
TInt DoIt()
	{
	TInt r;

	r=Source.Open(Fs,SourceName.FullName(),EFileRead);
	if(r!=KErrNone)
		return r;

	r = Destination.Replace(Fs,DestinationName.FullName(),EFileWrite);
	if(r!=KErrNone)
		return r;

	TUint8* buffer;
	const TInt KBufferSize = 0x10000;

	buffer = (TUint8*)User::Alloc(KBufferSize);
	if(!buffer)
		return KErrNoMemory;

	TPtr8 p(buffer,KBufferSize,KBufferSize);
	TInt n = 0;
	while (r==KErrNone)
		{
		r = Source.Read(p);
		if(r!=KErrNone || p.Size()==0)
			break;
		if (n==0)
			{
			// first block contains header
			if ((TUint)p.Size() < sizeof(E32ImageHeader))
				{
				r = KErrCorrupt;
				break;
				}
			E32ImageHeader* h = (E32ImageHeader*)buffer;
			r = SetCap(h);
			}
		if (r==KErrNone)
			r = Destination.Write(p);
		++n;
		}

	delete buffer;

	Source.Close();
	Destination.Close();

	return r;
	}
示例#13
0
// -----------------------------------------------------------------------------
// CbsUtils::FindAndOpenDefaultResourceFileLC
// Searches and opens the DLL default resource file.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CbsUtils::FindAndOpenDefaultResourceFileLC(
    RFs& aFs,
    RResourceFile& aResFile )
{
    // default resource file path

    _LIT(KDirAndFile,"z:CbsServer.rsc");

    TParse* fp = new(ELeave) TParse();
    fp->Set(KDirAndFile, &KDC_RESOURCE_FILES_DIR, NULL);

    static const TInt KDefResFileSignature = 4;

    // Find the resource file
    TFileName fileName( fp->FullName() );
    BaflUtils::NearestLanguageFile( aFs, fileName );

    // Open the resource file
    aResFile.OpenL( aFs, fileName );
    // Push close operation in tbe cleanup stack
    CleanupClosePushL( aResFile );

    aResFile.ConfirmSignatureL( KDefResFileSignature );

    delete fp;
}
示例#14
0
// -----------------------------------------------------------------------------
// CbsUtils::ExistsL
// Returns ETrue, if the file aFile exists.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TBool CbsUtils::ExistsL(
    const RFs& aFs,
    const TDesC& aFile )
{
    TParse filename;
    aFs.Parse( aFile, filename );

    TBool returnCode( EFalse );
    TUint attributes;

    TInt result( aFs.Att( filename.FullName(), attributes ) );
    if ( result == KErrNone )
    {
        returnCode = ETrue;
    }
    else if ( result == KErrNotFound )
    {
        returnCode = EFalse;
    }
    else
    {
        User::Leave( result );
    }
    return returnCode;
}
示例#15
0
void CSmsSendRecvTest::TestAddBifL(const TDesC& aBifName)
{
    iSmsTest.Printf(_L("\tAdd BIF: %S\n"), &aBifName);

    RFs& fs = iSmsTest.FileSession();
    TInt err = fs.MkDir(KBifDir);

    if (err != KErrAlreadyExists)
        User::LeaveIfError(err);

    TParse fileOut;
    err = iSmsTest.ResolveFile(KSmsComponent, aBifName, fileOut);

    if (err)
    {
        iSmsTest.Printf(_L("Test BIF %S not found! Continuing without this test\n"), &aBifName);
        return;
    }

    CFileMan* fileMan = CFileMan::NewL(fs);
    CleanupStack::PushL(fileMan);

    err = fileMan->Copy(fileOut.FullName(), KBifDir);

    if (err != KErrAlreadyExists)
        User::LeaveIfError(err);

    CleanupStack::PopAndDestroy(fileMan);

    User::After(KBifWait);
}
示例#16
0
LOCAL_C void doInternalizeL(const TDesC& aName)
{
    TParse	filestorename;

    fsSession.Parse(aName,filestorename);
    // construct file store object - specifying the file
    // containing the store.
    CFileStore* store = CDirectFileStore::OpenLC(fsSession,filestorename.FullName(),EFileRead);

    // Construct a CCompound object
    // from the root stream created earlier.
    CCompound* thecompound = CCompound::NewL(*store,store->Root());

    // Show contents of the CCompound object (and its
    // components)
    _LIT(KTxtRestoredContent,"... Restored CCompound content.");
    doShow(KTxtRestoredContent,*thecompound);

    // destroy the store object (this also closes the file
    // containing the store)
    CleanupStack::PopAndDestroy();

    // Now destroy the CCompound object
    delete thecompound;
}
示例#17
0
/**
Test CDictionaryFileStore construction, forcing a leave error at each
possible stage of the process.

@SYMTestCaseID          SYSLIB-STORE-CT-1190
@SYMTestCaseDesc	    Tests for CDictionaryFileStore construction under low memory conditions.
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for construction under low memory conditions.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void TestOOML()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1190 Construction under low memory conditions "));

	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse dicFilePath;
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
	
	TheFs.Delete(dicFilePath.FullName()); // delete the file
	TInt failRate=0;

	for (failRate=1;;failRate++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,failRate);
		__UHEAP_MARK;
		TRAPD(ret, AddEntryL());
		__UHEAP_MARKEND;
		if (ret==KErrNone)
			break;
		test (ret==KErrNoMemory);
		__UHEAP_RESET;
		test (!CheckEntryL());
		}
	__UHEAP_RESET;
	test (CheckEntryL());
	test.Printf(_L("  #allocs for update: %d\n"),failRate-1);
	//
	// tidy up
	}
示例#18
0
void CNSmlDSSettings::CreateHiddenProfilesL()
	{
	TFileName fileName;
	Dll::FileName( fileName );
	TParse parse;

	parse.Set( KNSmlDSProfilesRsc, &fileName, NULL );
	fileName = parse.FullName();

	RResourceFile resourceFile; 
	BaflUtils::NearestLanguageFile( iFsSession, fileName );

	TRAPD(leavecode,resourceFile.OpenL( iFsSession,fileName));
	if(leavecode != 0)
		{
		return;
		}
	CleanupClosePushL(resourceFile);
	
	HBufC8* profileRes = resourceFile.AllocReadLC( NSML_DS_PROFILES );
	TResourceReader reader;
	reader.SetBuffer( profileRes );

	CNSmlDSResourceProfiles* profileResReader = CNSmlDSResourceProfiles::NewLC( reader, this );
	profileResReader->SaveProfilesL(iResourceProfileArray);
	CleanupStack::PopAndDestroy(3); // profileResReader, profileRes, resourceFile
	}
示例#19
0
TInt E32Main()
	{
	TInt r;

	 // Turn off lazy dll unloading
	RLoader l;
	if ((r=l.Connect())!=KErrNone)
		return r;
	r = l.CancelLazyDllUnload();
	l.Close();
	if (r!=KErrNone)
		return r;
	
	r = ParseCommandLine();
	if(r!=KErrNone)
		return r;
	r = Fs.Connect();
	if(r!=KErrNone)
		return r;
	r = Fs.MkDirAll(DestinationName.FullName());
	if(r==KErrNone || r==KErrAlreadyExists)
		r = DoIt();
	Fs.Close();
	return r;
	}
示例#20
0
HBufC8* CTestConfig::ReadFileL(const TDesC& aFile) const
	{
	//Returns a HBufC8 with the contents of aFile
	RFile file;
	const TInt err = file.Open(iFs, aFile, EFileShareAny | EFileRead);

	if (err != KErrNone)
		{
		TParse fileOut;
		User::LeaveIfError(ResolveFile(iFs, *iComponent, aFile, fileOut));
		User::LeaveIfError(file.Open(iFs, fileOut.FullName(), EFileShareAny | EFileRead));
		}

	CleanupClosePushL(file);

	TInt size = 0;
	User::LeaveIfError(file.Size(size));

	HBufC8* contents = HBufC8::NewLC(size + 4);
	TPtr8 contentsPtr(contents->Des());
	User::LeaveIfError(file.Read(0, contentsPtr));

	CleanupStack::Pop(contents);
	CleanupStack::PopAndDestroy(&file);
	return contents;
	}
void CSupLoginServiceProvider::ConstructL()
{
	__LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() begins");

	// Form full path to credentials settings file
	RFs &fs = CCoeEnv::Static()->FsSession();

	TFileName privatePath;
	fs.PrivatePath(privatePath);
	TParse parser;
	TFileName processFileName(RProcess().FileName());
	User::LeaveIfError(parser.Set(KLoginProviderSettingsFilename, &privatePath, &processFileName));
	iSettingsFile = parser.FullName();

	// Read credentials from settings file
	ReadDataFromFileL();

	if (iMemberID && iUsername && iPassword)
		iLogged = ETrue;

	// Discover and retrieve description of the web service
	CSenXmlServiceDescription* serviceDesc = CSenXmlServiceDescription::NewLC( KServiceEndpointMemberId, KNullDesC8 );

	serviceDesc->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID);

	// Create connection to web service
	iConnection = CSenServiceConnection::NewL(*this, *serviceDesc);

	CleanupStack::PopAndDestroy(); // serviceDesc

	__LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() ends");
}
// ---------------------------------------------------------
// CNSmlDsProvisioningAdapter::GetTitleL
// ---------------------------------------------------------
void CNSmlDsProvisioningAdapter::GetTitleL()
	{
	if( iTitle == 0 )
		{
		RFs	fs;
		User::LeaveIfError( fs.Connect() );
		CleanupClosePushL( fs );

		TFileName fileName;
		TParse parse;
		parse.Set( KNSmlDsPovisioningDirAndResource, &KDC_RESOURCE_FILES_DIR, NULL );
		fileName = parse.FullName();

		RResourceFile resourceFile;
		BaflUtils::NearestLanguageFile( fs, fileName );
		resourceFile.OpenL( fs, fileName );
		CleanupClosePushL( resourceFile );

		HBufC8* dataBuffer = resourceFile.AllocReadLC( R_SYNC_PROVISIONING_TITLE );
			
		TResourceReader reader;
		reader.SetBuffer( dataBuffer ); 
		iTitle = reader.ReadHBufC16L(); 
		CleanupStack::PopAndDestroy( 3 ); //fs, resourcefile, databuffer
		}
	}
示例#23
0
HBufC* CScriptFile::ReadFileLC(const TDesC& aScript) const
	{
	HBufC8* file = NULL;

	TRAPD(err, file = ReadFileL(aScript));

	if (err)
		{
		TParse fileOut;
		err = iTestUtils.ResolveFile(*iComponent, aScript, fileOut);

		if (err)
			{
			iTestUtils.Test().Printf(_L("Cannot read file %S. Error=%d"), &aScript, err);
			User::Leave(err);
			}

		file = ReadFileL(fileOut.FullName());
		}

	CleanupStack::PushL(file);

	HBufC* buf = HBufC::NewL(file->Length());
	buf->Des().Copy(*file);
	CleanupStack::PopAndDestroy(file);
	CleanupStack::PushL(buf);
	return buf;
	}
示例#24
0
void CMsvIndexContext::CreateStoreDeleteFile()
#endif
	{
	
#if (!defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
	TDriveNumber aDriveNum = (TDriveNumber)(TInt) Config().iDrive;
#endif

	RFs& fs = iServer.FileSession();
	
	TInt err = fs.SetSessionToPrivate(aDriveNum);	
	if(err == KErrNone)
		{
		RFile storeDeletedFile;
		#if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
			TParse parse;
			TPtrC drive(TDriveUnit(aDriveNum).Name());
			parse.Set(KStoreDeletedFile, &drive, NULL);
			TFileName fileName = parse.FullName();
		#else
			TFileName fileName(KStoreDeletedFile);
		#endif		// #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
		
		err = storeDeletedFile.Replace(fs, fileName, EFileShareExclusive);
		if(err == KErrNone)
			{
			_LIT8(KMsvIndexStoreDeleted,"StoreDeleted");
			storeDeletedFile.Write(KMsvIndexStoreDeleted);
			}
		storeDeletedFile.Close();
		}
	}
示例#25
0
LOCAL_C void doDeferredLoadingL(const TDesC& aName)
	{
	TParse	filestorename;
	fsSession.Parse(aName,filestorename);
				// construct file store object - specifying the file
				// containing the store.
	CFileStore* store = CPermanentFileStore::OpenLC(fsSession,filestorename.FullName(),EFileRead);
	
				// Construct an object of type CCompound.
				// The loading of its components is deferred 
				// until needed.
	CCompound* thecompound = CCompound::NewLC(*store,store->Root());
	
				// Display component A.
				// The component is loaded in from the 
				// stream if not already loaded.
	_LIT(KTxtFirstDisplay," (first display)");
	thecompound->DisplayAL(KTxtFirstDisplay);

				// Re-Display component A
				// The component should now be in memory.
	_LIT(KTxtSecondDisplay," (second display)");
	thecompound->DisplayAL(KTxtSecondDisplay);

	console->Printf(KTxtNewLine);

				// Destroy:
				// 1. the CCompound object
				// 2. the store object (this also closes 
				//    the file containing the store)
				// Remove both from the cleanup stack
	CleanupStack::PopAndDestroy(2);
	}
示例#26
0
//The function constructs a full path in aDestPath argument (from aDriveNumber and aPrivatePath arguments).
//aDestPath must point to a big enough place (ideally TFileName object).
static void ConstructDestPath(TDriveNumber aDriveNumber, const TDesC& aPrivatePath, TDes& aDestPath)
	{
	TDriveName destDriveName = TDriveUnit(aDriveNumber).Name();
	TParse parse;
	parse.Set(aPrivatePath, &destDriveName, 0);
	aDestPath.Copy(parse.FullName());
	}
TInt CTestUtils::OpenMainLogL()
	{
	_LIT(KDisplayLogFile,"Log File %S\n");
	TParse loglocation;
	TFileName logfile;
	TInt err=ResolveLogFile(KNullDesC, loglocation);
	if(err!=KErrNone) 
		{
		TChar driveChar=RFs::GetSystemDriveChar();
 		TBuf<2> systemDrive;
 		systemDrive.Append(driveChar);
 		systemDrive.Append(KDriveDelimiter);
 		TPath pathName(systemDrive) ;
		pathName.Append(KMsvTestFileDefaultOutputBase);		
		iFs.MkDirAll(pathName);
		err=ResolveLogFile(KNullDesC, loglocation);
		}
	User::LeaveIfError(err);
	logfile.Copy(loglocation.FullName());
	logfile.Delete(logfile.Length()-1,1);
	AppendVariantName(logfile);
	iRTest.Printf(KDisplayLogFile, &logfile);
	iFs.MkDirAll(logfile);

	iLogBuf=HBufC::NewL(KMaxLogLineLength);
	iLogBuf8=HBufC8::NewL(KMaxLogLineLength);
	return(iFile.Replace(iFs,logfile,EFileWrite|EFileShareAny));
	}
TInt CTestUtils::AppendMainLogL()
	{
	_LIT(KDisplayLogFile,"Log File %S\n");
	TParse loglocation;
	TFileName logfile;
	TInt err=ResolveLogFile(KNullDesC, loglocation);
	if(err!=KErrNone) 
		{
		iFs.MkDirAll(KMsvTestFileDefaultOutputBase);
		err=ResolveLogFile(KNullDesC, loglocation);
		}
	User::LeaveIfError(err);
	logfile.Copy(loglocation.FullName());
	logfile.Delete(logfile.Length()-1,1);
	AppendVariantName(logfile);
	iRTest.Printf(KDisplayLogFile, &logfile);
	iFs.MkDirAll(logfile);

	iLogBuf=HBufC::NewL(KMaxLogLineLength);
	iLogBuf8=HBufC8::NewL(KMaxLogLineLength);
	TInt pos=0;
	TInt ret=KErrNone;
	ret=iFile.Open(iFs,logfile,EFileWrite|EFileShareAny);
	if (ret==KErrNotFound)
		ret=iFile.Create(iFs,logfile,EFileWrite|EFileShareAny);
	if (ret==KErrNone)
		return(iFile.Seek(ESeekEnd,pos));
	else
		return(ret);
	}
// -----------------------------------------------------------------------------
// CAknsWallpaperPlugin::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAknsWallpaperPlugin::ConstructL()
    {
    TParse parse;
    parse.Set(KResourceFileName, &KDC_RESOURCE_FILES_DIR, &KDriveZ);
    TFileName resourceFileName;
    resourceFileName.Append(parse.FullName());
    iConeResLoader.OpenL(resourceFileName);
    }
void CTestUTCParse::WriteStoreL()
	{
	//create the entry_structure file
	TParse parsedFileName;
	TFileName name(KTestMessageDir);
	iTestUtils->ResolveLogFile(name, parsedFileName);
	iTestUtils->FindChildrenL(KMsvRootIndexEntryIdValue, parsedFileName.FullName(), ETrue, EFalse);	
	}