Exemplo n.º 1
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1131
@SYMTestCaseDesc	    Writing and reading back a long stream test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt to write long data to a stream and read back and test for the integrity of the data.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testBugL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1131 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CDirectFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	file->SetTypeL(file->Layout());
	CSecureStore* secure=NULL;

		secure=CSecureStore::NewLC(*file,*thePBEKey);

	test.Next(_L("Writing long stream"));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(*secure);
	TInt ii;
	for (ii=0;ii<400;++ii)
		out<<_L("a goodly length of data");
	out.CommitL();
	CleanupStack::PopAndDestroy();
	file->SetRootL(out.CreateLC(*secure));
	out<<_L("spam")<<id;
	out.CommitL();
	CleanupStack::PopAndDestroy(2, secure);
	file->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Opening host file"));
	file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead);
	secure=CSecureStore::NewLC(*file,*thePBEKey);
//
	TBuf<30> buf;
	test.Next(_L("Reading"));
	RStoreReadStream in;
	in.OpenLC(*secure,file->Root());
	in>>buf>>id;
	CleanupStack::PopAndDestroy();
	test(buf==_L("spam"));
	in.OpenLC(*secure,id);
	for (ii=0;ii<400;++ii)
		{
		in>>buf;
		test (buf==_L("a goodly length of data"));
		}
	CleanupStack::PopAndDestroy(3);
	}
void CAknFileSettingPage::ConstructL(void)
{
    BaseConstructL();
    //listbox icons
    CAknIconArray* icons=new(ELeave)CAknIconArray(2);
    CleanupStack::PushL(icons);
    icons->ConstructFromResourceL(R_CLOCKAPP_EXTRA_SETTING_ICONS);
    FileControl()->ItemDrawer()->ColumnData()->SetIconArray(icons);
    CleanupStack::Pop(); //icons
    //listbox items
    iFiles=new(ELeave)CDesCArrayFlat(32);
    CTextListBoxModel* model=FileControl()->Model();
    model->SetItemTextArray(iFiles); //old text array deleted by owner
    model->SetOwnershipType(ELbmOwnsItemArray); //transfer ownership
    TParse parse;
    parse.SetNoWild(iFileValue,NULL,NULL);
    TPtrC name=parse.NameAndExt(),path=parse.DriveAndPath();
    TDesC* pos=&name;
    if(!BaflUtils::PathExists(iFs,path))
    {
        pos=NULL;
        iFileValue.Zero();
    }
    ReadFilesL(pos);
}
void CAddObexAttachmentAsEntryState::StartL(TRequestStatus& aStatus)
    {
    // Add an attachment as a child entry

    CBaseMtm& clientMtm = iClientTest.ObexTestUtils().GetCurrentObexClientMtm();

	CMsvEntry& entry = clientMtm.Entry();
	CMsvStore* store = entry.EditStoreL();
	CleanupStack::PushL(store);
	
	CAsyncWaiter* waiter = CAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
	CleanupStack::PushL(attachment);
	TParse fileNameParser;
	User::LeaveIfError(fileNameParser.Set(iFileName, NULL, NULL));
	attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
	store->AttachmentManagerL().AddAttachmentL(iFileName, attachment, waiter->iStatus);
	CleanupStack::Pop(attachment);
	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());
	CleanupStack::PopAndDestroy(waiter);
	
	store->CommitL();
	CleanupStack::PopAndDestroy(store);

    TRequestStatus* status = &aStatus;
	User::RequestComplete(status, KErrNone);
    }
Exemplo n.º 4
0
EXPORT_C
#if defined (_DEBUG)
/**
Function to create log file
@param aFileName The descriptor that holds the name of the log file to be created.
@param aShowDate If set to 1, the date of creation of the log file is recorded.
@param aShowTime If set to 1, the time of creation of the log file is recorded.
*/
void THttpLogger::CreateFlogger(const TDesC& aFileName, TInt aShowDate, TInt aShowTime)
//
//	Create log file in directory KLogsdir\KWapLogsDirName - Note: ingore Drive and Path of aFilename
	{
	if(!iLogger)
		{
		iLogger = new RFileLogger;
		}

	if(iLogger)
		{
		TInt error = iLogger->Connect();
		if(error == KErrNone)
			{
			TParse p;
			p.Set(aFileName, NULL, NULL);
			iLogger->CreateLog(KHttpLogsDirName, p.NameAndExt(), EFileLoggingModeOverwrite);
			iLogger->SetDateAndTime(aShowDate, aShowTime);
			iLogger->Write(KTestHeader);
			}
		else
			User::InfoPrint(_L("Flogger connect failed"));
		}
	else
		User::InfoPrint(_L("Flogger create failed"));
	}
void CMtfTestActionAddAttachmentAsLink::RunTestL()
	{
	CMsvStore* paramStore = ObtainParameterReferenceL<CMsvStore>(TestCase(),ActionParameters().Parameter(0));
	HBufC* paramFilePath   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1));
	HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(2));
	
	
	CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
	CleanupStack::PushL(attachment);
	
	attachment->SetMimeTypeL(*paramMimeType);
	
	TParse fileNameParser;
	User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL));
	attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
	
	MMsvAttachmentManager& manager = paramStore->AttachmentManagerL();
	
	manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus);
	CleanupStack::Pop(attachment); // ownership passed to manager

	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());
	CleanupStack::PopAndDestroy(waiter);
	
	TMsvAttachmentId attachmentId = attachment->Id();
	
	paramStore->CommitL();
	
	StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3));	
	}
Exemplo n.º 6
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1128
@SYMTestCaseDesc	    Tests for writing to a store
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for writing to a root store and empty store.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1128 Replacing host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	file->SetTypeL(file->Layout());
//
	test.Next(_L("Writing root store"));
	RStoreWriteStream stream;
	TStreamId embed=stream.CreateL(*file);
	CEmbeddedStore* store=CEmbeddedStore::NewLC(stream);

	CSecureStore* secure=CSecureStore::NewLC(*store, *thePBEKey);

	store->SetRootL(testWriteL(*secure));
	CleanupStack::PopAndDestroy(secure);
	store->CommitL();
	CleanupStack::PopAndDestroy();

	__UHEAP_MARK;
	TStreamId root=stream.CreateLC(*file);
	REncryptStream encrypt;
	encrypt.AttachLC(stream,*thePBEKey);

	encrypt<<_L8(" root")<<embed;
	encrypt.CommitL();
	CleanupStack::PopAndDestroy(2);
	__UHEAP_MARKEND;

	file->SetRootL(root);
//
	test.Next(_L("Writing temp store"));
	embed=stream.CreateL(*file);
	store=CEmbeddedStore::NewLC(stream);
	secure = CSecureStore::NewLC(*store, *thePBEKey);

	store->SetRootL(testWriteL(*secure));
	CleanupStack::PopAndDestroy(secure);
	store->CommitL();
	CleanupStack::PopAndDestroy();

	__UHEAP_MARK;
	TheTempId=stream.CreateLC(*file);
	encrypt.OpenLC(stream,*thePBEKey);

	encrypt<<_L8(" temp")<<embed;
	encrypt.CommitL();
	CleanupStack::PopAndDestroy();
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	__UHEAP_MARKEND;
//
	file->CommitL();
	CleanupStack::PopAndDestroy(file);
	}
Exemplo n.º 7
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1153
@SYMTestCaseDesc	    Tests for writing using a permanent file store
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for memory and end of file error while creating the store.
                        Tests for writing to replaced,temporary,opened,created file.
						Tests for creating an already existing file.
						Tests for panic while deleting a file.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1153 Creating and failing to open 'ghost' file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	TheFs.Delete(parse.NameAndExt());
	CFileStore* store=CPermanentFileStore::CreateLC(TheFs,parse.NameAndExt(),EFileWrite);
	CleanupStack::PopAndDestroy();
	store=NULL;
	TRAPD(r,store=CPermanentFileStore::OpenL(TheFs,parse.NameAndExt(),EFileRead|EFileWrite));
	test(store==NULL&&r==KErrEof);
//
	test.Next(_L("Empty tests on replaced file"));
	store=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	store->SetTypeL(TUidType(KPermanentFileStoreLayoutUid,KPermanentFileStoreLayoutUid));
	testEmptyL(*store);
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to temp file"));
	store=CPermanentFileStore::TempLC(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KPermanentFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	(void)TheFs.Delete(TheTempFile);
//
	test.Next(_L("Writing to temp file - 2"));
	store=CPermanentFileStore::TempL(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	CleanupStack::PushL(store);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KPermanentFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to opened file"));
	store=CPermanentFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Failing to create existing file"));
	store=NULL;
	TRAP(r,store=CPermanentFileStore::CreateL(TheFs,TheTempFile,EFileWrite));
	test(store==NULL&&r==KErrAlreadyExists);
	if (TheFs.Delete(parse.NameAndExt())!=KErrNone)
		test.Panic(_L("Deleting file"));
//
	test.Next(_L("Writing to created file"));
	RFile file;
	test(file.Create(TheFs,parse.NameAndExt(),EFileWrite)==KErrNone);
	store=CPermanentFileStore::NewLC(file);
	store->SetTypeL(KPermanentFileStoreLayoutUid);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	}
Exemplo n.º 8
0
/** Writes the application identifier (derived from the application object CApaApplication) 
followed by the stream dictionary to the store and makes the stream dictionary the root stream of the
store.

Typically, the function is called by the application when it 
implements a file create or file save type operation. It is called after all 
model and UI data has been persisted. The IDs of the streams containing the 
model and UI data should have been lodged in the stream dictionary.

In effect, the function finishes off the file save or file
create type operation, leaving the file containing the store in a valid state
with the standard interface.

@param aStore  The store to which the root stream is to be written. Before
calling this function, a reference to the store must be saved by putting a
pointer onto the cleanup stack or by making it member data of a class. This
ensures that it is not orphaned in the event of this function leaving.
@param aStreamDic The stream dictionary containing the locations and associated 
UIDs of other streams in the store.
@param aApp  The application used to create the main document in the file
being written. The application identifier to be written is constructed from
this application object. */
EXPORT_C void CApaProcess::WriteRootStreamL(CPersistentStore& aStore,CStreamDictionary& aStreamDic,const CApaApplication& aApp)
	{ // this is a static method
	__SHOW_TRACE(_L("Starting CApaProcess::WriteRootStreamL(app)"));
	// get the app dll name
	TParse dllPath;
	dllPath.SetNoWild(aApp.DllName(),NULL,NULL);
	// set up an app identifier
	TApaAppIdentifier appId(aApp.AppDllUid(),dllPath.NameAndExt());
	// Write the root stream
	WriteRootStreamL(aStore,aStreamDic,appId);
	}
Exemplo n.º 9
0
void CFileEngine::RequestRenameFile(const TDesC& aFileName)
{
	//ASSERT(NULL == iRenameFile);
	CInputDialog* inputDialog = iControlFactory.CreateInputTextDialog(*this,iMainEngine.GetDesById(ETurkeyTextRes_ReName),KNullDesC,ECmdRenameFile);
	TParse parse;
	parse.Set(aFileName,NULL,NULL);
	inputDialog->SetEdwinText(parse.NameAndExt());
	delete iRenameFile;
	iRenameFile = NULL;
	iRenameFile = aFileName.AllocL();
//	iInputEvent = ECmdRenameFile;
}
Exemplo n.º 10
0
EXPORT_C
#if defined (_DEBUG)
void TInuLogger::CreateFlogger(const TDesC& aFileName, TInt aShowDate, TInt aShowTime)
//
//	Create log file in directory KLogsdir\KWapLogsDirName - Note: ingore Drive and Path of aFilename
	{
	iLogger.Connect();
	TParse p;
	p.Set(aFileName, NULL, NULL);
	iLogger.CreateLog(KInuLogsDirName, p.NameAndExt(), EFileLoggingModeOverwrite);
	iLogger.SetDateAndTime(aShowDate, aShowTime);
	iLogger.Write(KTestHeader);
	}
void CMtfTestActionSmtpAddLinkedAttachment::RunTestL()
	{
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	HBufC* paramFilePath   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(2));
	HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(3));

	CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
	CleanupStack::PushL(entry);
	
	CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
	CleanupStack::PushL(emailMsg);
	
	CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
	CleanupStack::PushL(attachment);
	
	attachment->SetMimeTypeL(*paramMimeType);
	
	TParse fileNameParser;
	User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL));
	attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
	
	TEntry fileEntry;
	User::LeaveIfError(paramSession->FileSession().Entry( fileNameParser.FullName(), fileEntry));
	attachment->SetSize(fileEntry.iSize);

	MMsvAttachmentManager& manager = emailMsg->AttachmentManager();
	
	manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus);
	CleanupStack::Pop(attachment); // ownership passed to manager
	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());
	CleanupStack::PopAndDestroy(waiter);
	
	attachment = NULL;
	
	TInt attachmentCount = manager.AttachmentCount();
	attachment = manager.GetAttachmentInfoL(attachmentCount - 1);
	CleanupStack::PushL(attachment);
	
	TMsvAttachmentId attachmentId = attachment->Id();
	
	CleanupStack::PopAndDestroy(attachment);
	
	CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry
	
	StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(4));
	}
Exemplo n.º 12
0
EXPORT_C void CMsvTestUtils::WriteFileDataL(TMsvId aId, const TFileName& aFileName, const TFileName& aLogFilepath, TBool aReplace)
	{
	TParse dirPath;
	RFile attach;

	dirPath.Set(aFileName, NULL, NULL);
	TInt err = KErrNone;
	if (attach.Open(iFs, dirPath.FullName(), KEntryAttNormal) != KErrNone)
		return; // failed to find attachment


	TFileName filename(aLogFilepath);
	filename.Append(KFileNameFiles);
	RFile file;
	if (aReplace)
		err = file.Replace(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
	else
		err = file.Open(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
	if(err==KErrNotFound) // file does not exist - create it
		err=file.Create(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
		
	TInt offset=0;
	__ASSERT_ALWAYS(file.Seek(ESeekEnd, offset)==KErrNone, Panic(KErrGeneral));

	TBuf<100> buf;
	buf.Zero();
	buf.AppendFormat(_L("\n*** %d *************** File Data ***************\n"), aId);
	
	buf.AppendFormat(_L("Filename >>> "));	
	WriteToFileL(file, buf);
	WriteToFileL(file, dirPath.NameAndExt());	
	WriteToFileL(file,_L("\n"));
	
	HBufC8* buffer8 = HBufC8::NewLC(1024);
	TPtr8 buf8 = buffer8->Des();
	do {
		attach.Read(buf8);
		WriteToFileL(file, buf8);
		} while (buf8.Length());
	
	buf.Zero();
	buf.AppendFormat(_L("\n********************* end of File ***********************\n"));
	WriteToFileL(file, buf);
	

	CleanupStack::PopAndDestroy(); // buffer8
	attach.Close();
	file.Close();
	}
Exemplo n.º 13
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1129
@SYMTestCaseDesc	    Tests for reading from a store
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for reading from a root store and temporary store
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testReadL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1129 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead);
//
	test.Next(_L("Reading from root store"));
	TStreamId root=file->Root();
	RStoreReadStream stream;
	stream.OpenLC(*file,root);
	RDecryptStream decrypt;
	decrypt.AttachLC(stream,*thePBEKey);

	TStreamId embed;
	TBuf8<5> b;
	decrypt>>b>>embed;
	test(b==_L8(" root"));
	CleanupStack::PopAndDestroy(2);
	stream.OpenL(*file,embed);
	CEmbeddedStore* store=CEmbeddedStore::FromLC(stream);
	CSecureStore* secure=NULL;
	secure=CSecureStore::NewLC(*store,*thePBEKey);

	testReadL(*secure,store->Root());
	CleanupStack::PopAndDestroy(2);
//
	test.Next(_L("Reading from temp store"));
	stream.OpenLC(*file,TheTempId);
	decrypt.OpenLC(stream,*thePBEKey);

	decrypt>>b>>embed;
	test(b==_L8(" temp"));
	CleanupStack::PopAndDestroy(2);
	stream.OpenL(*file,embed);
	store=CEmbeddedStore::FromLC(stream);
	secure=CSecureStore::NewLC(*store,*thePBEKey);

	testReadL(*secure,store->Root());
//
	CleanupStack::PopAndDestroy(3);
	}
Exemplo n.º 14
0
void CFileEngine::SaveAs()
{
	ASSERT(iSaveAsSrcName);
	ASSERT(iSaveAsDstPath);
	TParse parse;
	parse.Set(*iSaveAsSrcName,NULL,NULL);
	const TDesC& nameAndExt = parse.NameAndExt();
	HBufC* saveAsDstName = HBufC::NewLC(iSaveAsDstPath->Length() + nameAndExt.Length());
	saveAsDstName->Des().Append(*iSaveAsDstPath);
	saveAsDstName->Des().Append(nameAndExt);
	//iFileActiveEngine.MoveFile(*iSaveAsSrcName,*saveAsDstName,this);
	iFileActiveEngine.CopyFile(*iSaveAsSrcName,*saveAsDstName,this);
	CleanupStack::PopAndDestroy(saveAsDstName);
	delete iSaveAsSrcName;
	iSaveAsSrcName = NULL;
	delete iSaveAsDstPath;
	iSaveAsDstPath = NULL;
}
	// class CIconFileHandle : public CBase, public MContextBase, 	
void FigureOutRealPathL(const TDesC& aFullPath, TDes& aRealPath, RFs& aFs) 
	{
		CALLSTACKITEMSTATIC_N(_CL("JuikIcons"), _CL("FigureOutRealPathL"));

		if ( aFullPath == AknIconUtils::AvkonIconFileName() )
			{
				aRealPath.Copy( aFullPath );
				return;
			}
#ifdef __S60V3__
		// Change path to c:\\resource 
		TParse p; p.Set( aFullPath, 0, 0);
		aRealPath=_L("c:\\resource\\");
		aRealPath.Append(p.NameAndExt());
#else
		// Just use given path
		aRealPath=aFullPath;
#endif
		
#ifdef __WINS__
		// in WINS, read always from Z 
		aRealPath.Replace(0, 1, _L("z"));
#else
		// In device, if file doesn't exist, read from E
		TBool try_mif=EFalse;
		if (p.Ext().CompareF(_L(".mbm"))==0) try_mif=ETrue;
again:
		if (! BaflUtils::FileExists(aFs, aRealPath)) {
			aRealPath.Replace(0, 1, _L("e"));
			if (! BaflUtils::FileExists(aFs, aRealPath)) {
				if (try_mif) {
					aRealPath=_L("c:\\resource\\");
					aRealPath.Append(p.Name());
					aRealPath.Append(_L(".mif"));
					try_mif=EFalse;
					goto again;
				}
				User::Leave(KErrNotFound);
			}
		}
#endif
	}
Exemplo n.º 16
0
void TSessionTest::CopyFileToTestDirectory()
//
// Make a copy of the file in ram
//
	{

	TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	TParse f;
	TInt r=iFs.Parse(fn,f);
	test_KErrNone(r);
	test.Next(_L("Copying file to test directory"));
	TParse fCopy;
	r=iFs.Parse(f.NameAndExt(),fCopy);
	test_KErrNone(r);

	RFile f1;
	r=f1.Open(iFs,f.FullName(),EFileStreamText|EFileShareReadersOnly);
	test.Printf(_L("r=%d\n"),r);
	test_KErrNone(r);
	RFile f2;
	r=f2.Replace(iFs,fCopy.FullName(),EFileWrite);
	test_KErrNone(r);
	TBuf8<512> copyBuf;
	TInt rem;
	r=f1.Size(rem);
	test_KErrNone(r);
	TInt pos=0;
	while (rem)
		{
		TInt s=Min(rem,copyBuf.MaxSize());
		r=f1.Read(pos,copyBuf,s);
		test_KErrNone(r);
		test(copyBuf.Length()==s);
		r=f2.Write(pos,copyBuf,s);
		test_KErrNone(r);
		pos+=s;
		rem-=s;
		}
	f1.Close();
	f2.Close();
	}
Exemplo n.º 17
0
EXPORT_C void CSmtpClientMtm::AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
	{
	__ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid==KUidMsvMessageEntryValue, gPanic(ESmtcMTMNotAMessageEntry));

	if( iAttachmentWaiter == NULL )
		{
		iAttachmentWaiter = CImAttachmentWaiter::NewL();
		}

	if (iEmailMessage == NULL)
		{		
		iEmailMessage = CImEmailMessage::NewL(*iMsvEntry);
		}
	else if (iEmailMessage->EmailEntryId() != iMsvEntry->EntryId())
		{
		delete iEmailMessage;
		iEmailMessage = NULL;
		iEmailMessage = CImEmailMessage::NewL(*iMsvEntry);
		}
	
	CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
	CleanupStack::PushL(attachmentInfo);
	
	attachmentInfo->SetMimeTypeL(aMimeType);
	
	TParse fileNameParser;
	User::LeaveIfError(fileNameParser.Set(aFilePath, NULL, NULL));
	attachmentInfo->SetAttachmentNameL(fileNameParser.NameAndExt());

	if( aCharset!=0 )
		{
		CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
		headers->SetMimeCharset(aCharset);
		headers->StoreL(*attachmentInfo);
		CleanupStack::PopAndDestroy(headers);
		}
	
	iEmailMessage->AttachmentManager().AddLinkedAttachmentL(aFilePath, attachmentInfo, iAttachmentWaiter->iStatus);
	CleanupStack::Pop(attachmentInfo);// ownership passed to attachment manager	

	iAttachmentWaiter->StartWaitingL(aStatus, iEmailMessage, EFalse);
	}
// EPOC default constructor can leave.
void CPosResourceReader::ConstructL(const TDesC& aPath)
    {
    User::LeaveIfError(iFileSession.Connect());

    TFindFile* filefinder = new (ELeave) TFindFile(iFileSession);
    CleanupStack::PushL(filefinder);

    TParse* fileparser = new (ELeave) TParse;
    CleanupStack::PushL(fileparser);
    fileparser->Set(aPath, NULL, NULL);

    User::LeaveIfError(filefinder->FindByDir(fileparser->NameAndExt(),
        fileparser->DriveAndPath()));
    
    iResourceFile.OpenL(iFileSession, filefinder->File());
    iResourceFile.ConfirmSignatureL(0);
    
    CleanupStack::Pop(2, filefinder); // fileparser
    delete filefinder;
    delete fileparser;
    }
// -----------------------------------------------------------------------------
// CPosLmLocalDatabaseManager::DatabaseExistsL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TBool CPosLmLocalDatabaseManager::DatabaseExistsL(const TDesC& aDatabaseUri)
    {
    // validate URI
    HBufC* uri = PosLmDatabaseUtility::CreateDatabaseUriL(aDatabaseUri);
    CleanupStack::PushL(uri);

    TPtrC ptr(uri->Des());
    PosLmDatabaseUtility::RemoveProtocolFromUriL(ptr);

    TParse parse;
    User::LeaveIfError(parse.Set(ptr, NULL, NULL));
    TFileName searchUri = parse.NameAndExt();
    searchUri.UpperCase();

    TInt drive;
    User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0], drive));

    RDbs dbSession;
    CleanupClosePushL(dbSession);
    User::LeaveIfError(dbSession.Connect());

    CDbDatabaseNames* names = dbSession.DatabaseNamesL(
            static_cast<TDriveNumber>(drive), KPosLmDbSecureUid);
    CleanupStack::PushL(names);

    TBool exists(EFalse);
    for (TInt i = 0; i < names->Count() && !exists; i++)
        {
        HBufC* databaseName = (*names)[i].AllocLC();
        databaseName->Des().UpperCase();
        if (searchUri == *databaseName)
            {
            exists = ETrue;
            }
        CleanupStack::PopAndDestroy(databaseName);
        }

    CleanupStack::PopAndDestroy(3, uri);  //dbSession
    return exists;
    }
Exemplo n.º 20
0
TPath CImageRescaler::GenerateDestPath(const TDesC& aSrcPath)
    {
    // Image file type
    TParse p;
    TInt err = p.Set(aSrcPath, NULL, NULL);
    TPath destFile;
    
    if (err == KErrNone)
        {
        // Generate the image path
        // Format <path>_timestamp_filename.ext
        destFile.Append(iImagesDirPath);
        destFile.Append(_L("_"));
        
        TTime time;
        time.UniversalTime();
        destFile.AppendNum(time.Int64());
        destFile.Append(_L("_"));
        destFile.Append(p.NameAndExt());
        }
    
    return destFile;
    }
Exemplo n.º 21
0
TInt DoIt()
	{
	TInt  r;

	TBuf<MAX_PATH> sName;
	r = MapEmulatedFileName(sName, SourceName.NameAndExt());
	if(r!=KErrNone)
		return r;

	TBuf<MAX_PATH> dName;
	r = MapEmulatedFileName(dName, DestinationName.FullName());
	if(r!=KErrNone)
		return r;

	if(!Emulator::CopyFile((LPCTSTR)sName.PtrZ(),(LPCTSTR)dName.PtrZ(),FALSE))
		return KErrGeneral;

	HANDLE hFile=Emulator::CreateFile((LPCTSTR)dName.PtrZ(),GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
	if (hFile==INVALID_HANDLE_VALUE)
		return KErrArgument;

	return SetCap(hFile);
	}
Exemplo n.º 22
0
/**
@SYMTestCaseID          PDS-STORE-CT-4020
@SYMTestCaseDesc	    Tests writing and replacing a stream from securestore
@SYMTestPriority 	    High
@SYMTestActions  	    Create a new stream in the store and then open it for replacement
@SYMTestExpectedResults stream is created and writtenn to successfully
@SYMDEF                 DEF135804
*/
LOCAL_C void testWriteReplaceL()
	{
	test.Next(_L("@SYMTestCaseID PDS-STORE-CT-4020"));
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
		
	test.Next(_L("Testing Extend"));
	CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	file->SetTypeL(file->Layout());
	CSecureStore* secure=NULL;

	secure=CSecureStore::NewLC(*file,*thePBEKey);
	RStoreWriteStream out;
	TStreamId id = out.CreateL(*secure);
	test(id != NULL);
	out.Close();
	TRAPD(r, out.OpenL(*secure, id) );
	test(r == KErrNone);
	out.WriteL(KTestDes,8);
	out.CommitL();
	out.Close();
	r = secure->Commit();
	test(r == KErrNone);
	
	TRAP(r,out.ReplaceL(*secure, id));
	test(r == KErrNone);
	out.WriteL(KTestDes,8);
	out.CommitL();
	out.Close();
	secure->Revert();
	out.Close();
	
	CleanupStack::PopAndDestroy(2);
		
	}
Exemplo n.º 23
0
/**
@SYMTestCaseID          PDS-STORE-CT-4019
@SYMTestCaseDesc	    Tests adding and deleting a stream from securestore
@SYMTestPriority 	    High
@SYMTestActions  	    Create a new stream and Delete it again
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF135804
*/
LOCAL_C void testExtendDeleteL()
	{
	test.Next(_L("@SYMTestCaseID PDS-STORE-CT-4019"));
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
		
	test.Next(_L("Testing Extend"));
	CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	file->SetTypeL(file->Layout());
	CSecureStore* secure=NULL;

	secure=CSecureStore::NewLC(*file,*thePBEKey);
	TStreamId id = secure->ExtendL();
	test(id != NULL);
	test.Next(_L("Testing Delete"));		
	TRAPD(r, secure->DeleteL(id));
	test(r == KErrNone);
	TRAP(r, secure->DeleteL(id));
	test(r == KErrNotFound);
	
	CleanupStack::PopAndDestroy(2);
	
	}
Exemplo n.º 24
0
void Application::ReadSettings()
{
emit appWorkChanged(settings->value("settings/appwork",KWork).toBool());
emit autostartChanged(settings->value("settings/autostart",KAutostart).toBool());
#ifdef Q_OS_SYMBIAN
TParse parse;
QString file=settings->value("settings/picture",KPicture).toString();
file=file.replace("file:///","");
TPtrC file1 (reinterpret_cast<const TText*>(file.constData()),file.length());
CEikonEnv::Static()->FsSession().Parse(file1,parse);
TBuf<255> a=parse.NameAndExt();
file=QString::fromRawData(reinterpret_cast<const QChar*>(a.Ptr()),a.Length());
emit pictureChanged(file);

RApaLsSession ls;
ls.Connect();
TApaAppInfo info;
bool ok;
QString name;

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app1",app1).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app1Changed(name);

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app2",app2).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app2Changed(name);

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app3",app3).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app3Changed(name);

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app4",app4).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app4Changed(name);

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app5",app5).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app5Changed(name);

ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("apps/app6",app6).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
app6Changed(name);


ls.GetAppInfo(info, TUid::Uid((TUint32)settings->value("settings/zcamapp",camapp).toString().toULong(&ok,16)));
name=QString::fromRawData(reinterpret_cast<const QChar*>(info.iCaption.Ptr()),info.iCaption.Length());
cameraAppChanged(name);
#endif

emit zoomChanged(settings->value("settings/zoom",KZoom).toInt());
emit playerAlbumChanged(settings->value("settings/playeralbum",KPlayer).toInt());
emit useWallpaperChanged(settings->value("settings/zusewallpaper",0).toInt());
emit useSystemFontChanged(settings->value("settings/zusesystemfont",0).toInt());
emit orientationChanged(settings->value("settings/zzorientation",0).toInt());
settings->beginGroup("keys");
QStringList sets=settings->allKeys();
for (int i=0;i<sets.length();i++) settings->remove(sets[i]);
for (int i=0;i<keys.length();i++) settings->setValue(QString::number(i),keys[i]);
settings->endGroup();

settings->beginGroup("settings");
qDebug()<<settings->allKeys();
settings->endGroup();
}
Exemplo n.º 25
0
void CFileEngine::PasteFile(const TDesC& aFilaName)
{
	if(NULL == iCopiedFile)
	{
		iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_Copy_NotSelect),*this,ECmdNull);
	}
	else
	{
		if(!BaflUtils::FileExists(iFs,*iCopiedFile))
		{
			iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FilePaste_SourceNotExist),*this,ECmdCancelCopy);
		}
		else
		{
			TParse parse;
			parse.Set(*iCopiedFile,NULL,NULL);
			const TDesC& driveAndPath = parse.DriveAndPath();
			const TDesC& nameAndExt = parse.NameAndExt();
			
			TFileName desFileName;
			TBool isFolder = EFalse;
			TInt err = BaflUtils::IsFolder(iFs,aFilaName,isFolder);
			if(KErrNone == err && isFolder)
			{
				desFileName.Append(aFilaName);
				if(desFileName.Right(1).Compare(_L("\\"))!=0)
				{
					desFileName.Append(_L("\\"));
				}
				desFileName.Append(nameAndExt);
			}
			else
			{
				TParse parseDes;
				parseDes.Set(aFilaName,NULL,NULL);
				
				desFileName.Append(parseDes.DriveAndPath());
				if(parseDes.DriveAndPath().Right(1).Compare(_L("\\"))!=0)
				{
					desFileName.Append(_L("\\"));
				}
				desFileName.Append(nameAndExt);
			}
			iMainEngine.WriteLog16(*iCopiedFile);
			iMainEngine.WriteLog16(desFileName);

			TInt result = CheckDiskSpace(*iCopiedFile,desFileName);
			if(1 == result)
			{
				iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_SaveAs_NoSpace),*this,ECmdCancelCopy);
			}
			else if(2 == result)
			{
				iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FilePaste_OtherError),*this,ECmdCancelCopy);
			}
			else
			{
				if(BaflUtils::FileExists(iFs,desFileName))
				{
					TParse parseTemp;
					parseTemp.Set(desFileName,NULL,NULL);

					desFileName.Zero();
					desFileName.Append(parseTemp.DriveAndPath());
					desFileName.Append(iMainEngine.GetDesById(ETurkeyTextRes_Copy_SameName));
					desFileName.Append(parseTemp.NameAndExt());
				}

				iFileActiveEngine.CopyFile(*iCopiedFile,desFileName,this);

				iDialog = iControlFactory.CreateWaitDialog(iMainEngine.GetDesById(ETurkeyTextRes_NewSearch_SaveFile),*this,ECmdCopying);
				delete iCopiedFile;
				iCopiedFile = NULL;
			}
			//CleanupStack::PopAndDestroy();	//desFileName
		}
	}
}
EXPORT_C void LoadIcons(CArrayPtrFlat<CGulIcon> * aIconList, const TIconID* aIconDefs, 
			TInt aNbIcons, TInt aScale)
{
	CALLSTACKITEM_N(_CL(""), _CL("LoadIcons"));

	TFileName real; TFileName prev;
	CEikonEnv* env=CEikonEnv::Static();
	RFs& fs=env->FsSession();
	CWsScreenDevice* screen=env->ScreenDevice();
	RWsSession& ws=env->WsSession();
	RArray<TInt> Offsets; RFile File; bool file_is_open=false;
	CleanupClosePushL(Offsets);
	RFileReadStream s;
	int j=0;

	bool romfile=false;
	for (int i = 0; i<aNbIcons;i++)
	{
		TPtrC file((TText16*)aIconDefs[i].iMbmFile);
#ifdef __S60V3__
		if (file.FindF(_L("avkon"))==KErrNotFound) {
#endif
			
		if (prev.Compare(file)) {
#ifndef __S60V3__
			real=file;
#else
			TParse p; p.Set(file, 0, 0);
			real=_L("c:\\resource\\");
			real.Append(p.NameAndExt());				
				
#endif

#ifdef __WINS__
			real.Replace(0, 1, _L("z"));
#else
			if (! BaflUtils::FileExists(fs, real)) {
				real.Replace(0, 1, _L("e"));
			}
#endif
			prev=file;
			if (file_is_open) {
				s.Close();
				file_is_open=false;
			}
			if (real.Left(1).CompareF(_L("z"))==0) {
				romfile=true;
			} else {
				romfile=false;
				GetIconInfo(real, fs, File, s, Offsets, j);
				file_is_open=true;
			}
			++j;
		}

		auto_ptr<CWsBitmap> bitmap(new (ELeave) CWsBitmap(ws));
		if (!romfile) {
			RFile f1=File;
			s.Attach(f1, Offsets[aIconDefs[i].iBitmap]);	
			bitmap->InternalizeL(s);
		} else {
			TInt err=bitmap->Load(real, aIconDefs[i].iBitmap);
			if (err!=KErrNone) 
				User::Leave(err);
		}
		bitmap->SetSizeInTwips(screen);
#ifdef __S60V2__
		if (aScale>1) {
			auto_ptr<CWsBitmap> scaled(new (ELeave) CWsBitmap(ws));
			ScaleFbsBitmapL(bitmap.get(), scaled.get(), aScale);
			bitmap=scaled;
		}
#endif
		
		auto_ptr<CWsBitmap> mask(NULL);
		if ( aIconDefs[i].iMask != KErrNotFound )
			{
				mask.reset(new (ELeave) CWsBitmap(ws));
				if (!romfile) {
					RFile f2=File;
					s.Attach(f2, Offsets[aIconDefs[i].iMask]);
					mask->InternalizeL(s);
				} else {
					User::LeaveIfError(mask->Load(real, aIconDefs[i].iMask));
				}
				mask->SetSizeInTwips(screen);
#ifdef __S60V2__
				if (aScale>1) {
					auto_ptr<CWsBitmap> scaled(new (ELeave) CWsBitmap(ws));
					ScaleFbsBitmapL(mask.get(), scaled.get(), aScale);
					mask=scaled;
				}
#endif
			}

		auto_ptr<CGulIcon> icon(CGulIcon::NewL(bitmap.get(), mask.get()));
		bitmap.release(); mask.release();
		aIconList->AppendL(icon.get()); icon.release();
#ifdef __S60V3__
		} else {
			auto_ptr<CFbsBitmap> bitmap(0);
			auto_ptr<CFbsBitmap> mask(0);
			if ( aIconDefs[i].iMask != KErrNotFound ) {
				CFbsBitmap *bitmapp=0, *maskp=0;
				AknIconUtils::CreateIconL(bitmapp, maskp, AknIconUtils::AvkonIconFileName(), aIconDefs[i].iBitmap, aIconDefs[i].iMask);
				bitmap.reset(bitmapp);
				mask.reset(maskp);
			} else {
				bitmap.reset(AknIconUtils::CreateIconL(AknIconUtils::AvkonIconFileName(), aIconDefs[i].iBitmap));
			}
			bitmap->SetSizeInTwips(screen);
			if (mask.get()) mask->SetSizeInTwips(screen);
			auto_ptr<CGulIcon> icon(CGulIcon::NewL(bitmap.get(), mask.get()));
			bitmap.release(); mask.release();
			aIconList->AppendL(icon.get()); icon.release();
		}
#endif
	}
	if (file_is_open) {
		s.Close();
	}
	CleanupStack::PopAndDestroy(); // Offsets
}
/**
Performs any necessary configuration file updates to the database if a 
configuration file exists for the database that has not yet been processed.
If a configuration file is processed then the database settings table will 
be updated with the version of the configuration file that was processed.

@param aStoredDbConfigFileVersion The configuration file version that is
								  currently stored in the settings table
@param aFileData The database file data

@param aDbName Logical database name: "main" for the main database or attached database name

@leave One of the system-wide error codes or SQL errors of ESqlDbError type

@panic SqlDb 2 In _DEBUG mode if iDbHandle is NULL (uninitialized TSqlDbSysSettings object)
*/
void TSqlDbSysSettings::ConfigureDatabaseL(TInt aStoredDbConfigFileVersion, const TSqlSrvFileData& aFileData, 
										   const TDesC& aDbName)
	{	
	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_ENTRY, "Entry;0x%X;TSqlDbSysSettings::ConfigureDatabaseL", (TUint)this));    
	
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));

	if(!aFileData.IsSecureFileNameFmt())
		{
		//As a first implementation, config files will only be supported for 
		//shared, secure databases - not for private, secure databases or public databases
		SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_EXIT1, "Exit;0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Not a secure db", (TUint)this));    
		return;	
		}
		
	//Determine whether there is a configuration file 
	//for this database that has not yet been processed
	const CDbConfigFiles* dbConfigFiles = aFileData.DbConfigFiles();
	if(dbConfigFiles)
		{
		//Get the database file name and extension to search for a corresponding config file
		TPtrC dbName = aFileData.FileName();
		TParse parse;
		__SQLLEAVE_IF_ERROR(parse.Set(dbName, NULL, NULL));
		TPtrC dbFileNameAndExt = parse.NameAndExt();
		HBufC* matchingConfigFile = dbConfigFiles->FindConfigFile(dbFileNameAndExt);
		if(matchingConfigFile)
			{
			//There exists a config file for this database - now check whether its
			//version is greater than the version stored in the settings table and 
			//only process the file if it is
			TFileName configFileName;
			configFileName.Copy(matchingConfigFile->Des());
			TInt offset = configFileName.LocateReverse('.') ;
			if(KErrNotFound != offset)
				{
				TInt lengthOfExt = configFileName.Length() - offset - 1;
				TPtrC versionNum = configFileName.Right(lengthOfExt);				
				TLex lex(versionNum);
				TInt fileVersion = 0;
				if(KErrNone == lex.Val(fileVersion))
					{
					if(fileVersion > aStoredDbConfigFileVersion)
						{
						//The latest version of the configuration file has not yet been processed, so do it now
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL1, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S'", (TUint)this, __SQLPRNSTR(configFileName)));	
						ExecuteConfigurationUpdateL(aFileData, configFileName, fileVersion, aDbName);
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL2, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S' was processed, no errors", (TUint)this, __SQLPRNSTR(configFileName)));	
						}
					else
						{
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL3, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S' as this or a later version has already been processed", (TUint)this, __SQLPRNSTR(configFileName)));	
						}
					}
				else
					{
					//Invalid config file name extension - it cannot be converted to an integer
					__SQLLEAVE(KErrCorrupt);
					}
				}
			else
				{
				//Invalid config file name - it doesn't contain the character '.'
				__SQLLEAVE(KErrCorrupt);
				}
			}
		else
			{
			SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL4, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;No config file found for database '%S'", (TUint)this, __SQLPRNSTR(dbFileNameAndExt)));	
			}
		}		
	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_EXIT2, "Exit;0x%X;TSqlDbSysSettings::ConfigureDatabaseL", (TUint)this));    
	}
Exemplo n.º 28
0
TInt ParseCommandLine()
	{
	TBuf<256> c;
	User::CommandLine(c);

	// Get exe name
	TLex l(c);
	if(SourceName.SetNoWild(l.NextToken(),0,&KDefaultSourcePath)!=KErrNone)
		return KErrArgument;

	// Get capability
	TLex cl(l.NextToken());
	if(cl.Val((TInt64&)Capability,EHex)!=KErrNone)
		return KErrArgument;

	// Mask out unsupported capabilities
	TCapabilitySet all;
	all.SetAllSupported();
	((TCapabilitySet&)Capability).Intersection(all);

	// We always update capabilities in the headers
	CapabilitySet = ETrue;

	// Get options
	SecureIdSet = EFalse;
	VendorIdSet = EFalse;
	TPtrC nextToken;
	for (;;)
		{
		nextToken.Set(l.NextToken());
		if (nextToken == KSIDOption)
			{
			// SID specified
			nextToken.Set(l.NextToken());
			if (nextToken == KNullDesC)
				return KErrArgument;				
			TLex sl(nextToken);
			if(sl.Val(SecureId.iId,EHex)!=KErrNone)
				return KErrArgument;
			SecureIdSet = ETrue;
			}
		else if (nextToken == KVIDOption)
			{
			// VID specified
			nextToken.Set(l.NextToken());
			if (nextToken == KNullDesC)
				return KErrArgument;				
			TLex sl(nextToken);
			if(sl.Val(VendorId.iId,EHex)!=KErrNone)
				return KErrArgument;
			VendorIdSet = ETrue;
			}
		else
			break;
		}
				
	// Get target path
	TPtrC s(SourceName.NameAndExt());
	TBuf<sizeof(KDefaultDestinationPath)> defaultDestinationPath(KDefaultDestinationPath);
	defaultDestinationPath[0] = (TUint8) RFs::GetSystemDriveChar();
	
	if(DestinationName.SetNoWild(nextToken,&s,&defaultDestinationPath)!=KErrNone)
		return KErrArgument;

	// Check we used all the arguments
	if (l.NextToken() != KNullDesC)
		return KErrArgument;

	return KErrNone;
	}
Exemplo n.º 29
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1130
@SYMTestCaseDesc	    Tests copying from one stream to another stream
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for copying using different transfer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1130 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
//
	test.Next(_L("Opening source (root) store"));
	TStreamId root=file->Root();
	RStoreReadStream src;
	src.OpenLC(*file,root);
	RDecryptStream decrypt;
	decrypt.OpenLC(src,*thePBEKey);

	TBuf8<5> b;
	TStreamId embed;
	decrypt>>b>>embed;
	test(b==_L8(" root"));
	CleanupStack::PopAndDestroy(2); // src, decrypt
	src.OpenL(*file,embed);
	CEmbeddedStore* source=CEmbeddedStore::FromLC(src);
	CSecureStore* ssource=NULL;
	ssource=CSecureStore::NewLC(*source,*thePBEKey);

	test.Next(_L("Creating target store"));
	RStoreWriteStream trg;
	trg.CreateL(*file);
	CEmbeddedStore* target=CEmbeddedStore::NewLC(trg);
	CSecureStore* starget=NULL;
	starget=CSecureStore::NewLC(*target,*thePBEKey);

	test.Next(_L("Copying using small transfers"));
	RStoreReadStream in;
	in.OpenL(*ssource,source->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*ssource,copyId);
	RStoreWriteStream out;
	TStreamId id=out.CreateL(*starget);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	CleanupStack::PopAndDestroy(5);
	}
/**
 *
 * Open a log.
 *
 * @param	"const TDesC& aLogName"
 *			The log name
 *
 * @param	"TInt aLogMode"
 *			The log mode (as bitmask of TTestFrameworkLogMode)
 *
 * @xxxx
 *
 */
void CTestFrameworkServer::OpenLogL(const TDesC& aLogName, TInt aLogMode)
{
    // NB we need to check if a console is already open - if so, we do NOT
    // create another one. Ditto with file / port.

    if(aLogMode & ELogToConsole)
    {
        if(!iConsole)
        {
            iConsole = CServerConsole::NewL(aLogName);

            CConsoleBase* theConsole = iConsole->Console();
            theConsole->Printf(_L("%S : Server log starting\n"), &aLogName);

            iLogMode |= ELogToConsole;

            if (aLogMode & ELogConsoleFull)
                iLogMode |= ELogConsoleFull;
        }
    }

    // NB relative paths will not work with TParse (there is no file server open).
    // Exception is a bare filename (with no path) : this will be found in root of C:

    // NOTE! We have no mechanism to notify this error. The console will display
    // and then exit. The log file cannot be opened.

    // TO BE ENHANCED - if console is made active, then we can pause

    if(aLogMode & ELogToFile)
    {
        if(!iFileLogger)
        {
            TRAPD(err, iFileLogger = CFileLogger::NewL());
            if(err != KErrNone)
            {
                // if we can't create a logger, we panic
                User::Panic(_L("TestFrameworkServer"), 1);
            }

            _LIT(KLogPath, "C:\\Logs\\TestResults");
            _LIT(KDefault, "C:\\.htm");

            TParse parseLogName;
            parseLogName.Set(aLogName, NULL, NULL);

            TFileName logFilePath;
            logFilePath = KLogPath;

            if(parseLogName.PathPresent())
                logFilePath.Append(parseLogName.Path());
            else
                logFilePath.Append(_L("\\"));


            // overwrite extension if supplied with .htm
            TParse logFileFullName;
            TInt returnCode = logFileFullName.Set(KDefault, &logFilePath, &aLogName);
            if (returnCode == KErrNone)
            {
                TInt ret = iFileLogger->Connect();
                if (ret == KErrNone)
                {
                    iFileLogger->CreateLog(logFilePath, logFileFullName.NameAndExt());
                    iLogMode |= ELogToFile;
                }
            }
        }
    }

    if(aLogMode & ELogToPort)
    {
        // RDebug::Print will deal with the serial port, we don't do anything special here
        iLogMode |= ELogToPort;
    }
}