void CTestImpExvCardSuiteStepBase::OpenBDAYVCFAndImportItemL(TBuf<80> aPath,TInt aIndex)
	{
	// Format buf to hold relevant vcf file
	TFileName fileName;
#ifdef __WINS__
	fileName.Append(_L("c:"));
#else
	TFileName processFileName = RProcess().FileName();
	TParsePtrC parse(processFileName);
	fileName.Append(parse.Drive());
#endif
	fileName.Append(aPath);
	fileName.AppendNum(aIndex);
	fileName.Append(_L(".vcf"));
	
	RFs fs; 
	User::LeaveIfError(fs.Connect());  // push fs
	CleanupClosePushL(fs);
	RFileReadStream readVCFStream;
	User::LeaveIfError(readVCFStream.Open(fs, fileName, EFileRead)); // opens vcf file
	
	TBuf<MAX_TEXT_MESSAGE> message;
	message.Format(KOpenVCFFile, &fileName);
	INFO_PRINTF1(message);
	
	CleanupClosePushL(readVCFStream);   // readVCFStream

	ImportBDAYCardL(readVCFStream);
		
	CleanupStack::PopAndDestroy(); // pop readVCFStream
	fs.Close();
	CleanupStack::PopAndDestroy(); // pop fs
	}
예제 #2
0
void CAccessCountTests::ImportVcardL()
	{
	TBool sucess = EFalse;
	RFileReadStream rfrs;
	CleanupClosePushL( rfrs );
	User::LeaveIfError( rfrs.Open( iParent->Fs(), KVcardFile, EFileRead | EFileShareAny ) );
	
	FOREVER
		{
		CArrayPtr<CContactItem>* imported= 	iContactsDatabase->ImportContactsL( 
											TUid::Uid( KUidVCardConvDefaultImpl ), rfrs, sucess, 
											CContactDatabase::EIncludeX | CContactDatabase::ETTFormat |
											CContactDatabase::EImportSingleContact
											);	
		if(sucess)
			{
			imported->ResetAndDestroy();
			CLEAR(imported);	
			}
		else
			{
			imported->ResetAndDestroy();
			CLEAR(imported);
			break;	
			}
		sucess = EFalse;
		}

	CleanupStack::PopAndDestroy(&rfrs);
	}
예제 #3
0
void CIncallertAppUi::DoConstuctL()
{
    //at first start iAppView would be null as all member ptrs are NULL (defaulted by (ELeave) in CIncallertDocument::CreateAppUiL())
    if(iAppView)//if already called before - just to make sure there's no duplicate ctor alloc
        return;

    iAppView = CIncallertAppView::NewL(this);
    iSettingsView = CIncallertSettingsView::NewL(this);
    iLineStatusHandler = CLineStatusHandler::NewL(this);

    iHelpAppView = CHelpAppView::NewL( ENavigationPaneHelpViewId);
    iAboutAppView = CAboutAppView::NewL( ENavigationPaneAboutViewId);

    _LIT(KIni,"Incallert.ini");
    TFileName fname(KIni);
#ifndef __WINS__
    CompleteWithPrivatePathL(fname);
#endif
    TSettingsListSettings settings;

    TRAPD(err,
          RFs fs = iCoeEnv->FsSession();

          User::LeaveIfError(fs.Connect());
          CleanupClosePushL(fs);
          RFileReadStream rfrs;
          if(rfrs.Open(fs,fname,EFileRead) == KErrNone)
{
    CleanupClosePushL(rfrs);
        settings.InternalizeL(rfrs);
        CleanupStack::PopAndDestroy();
    }
    CleanupStack::PopAndDestroy();
         );
예제 #4
0
// ---------------------------------------------------------------------------
// Restore the file from given directory and given index
// ---------------------------------------------------------------------------
//
EXPORT_C CXIMPTestFileSrvMsg* CXIMPTestFileTool::SrvMsgRestoreLC(
        TInt aObjIndex )
    {
    CXIMPTestFileSrvMsg* msg = CXIMPTestFileSrvMsg::NewLC();

    HBufC* fileName = GetFileNameLC( 
            KFileToolSrvDirBase, 
            aObjIndex );

    // try to instantiate it
    RFileReadStream in;
    CleanupClosePushL( in );

    in.Open( iFs, *fileName, EFileStream );

    msg->InternalizeL( in ); 

    CleanupStack::PopAndDestroy(); // in

    // delete the just read object
    iFs.Delete( *fileName );

    CleanupStack::PopAndDestroy( fileName ); // fileName
    return msg;
    }
예제 #5
0
void VersitImportContactL(const TDesC& aImportFileName)
{
    RFileReadStream readStream;
		
	//Import aImportFileName
	User::LeaveIfError(readStream.Open(fsSession, aImportFileName, EFileRead));
	CleanupClosePushL(readStream);
	
	TBool success=EFalse;
	CArrayPtr<CContactItem>* contactItems=CntTest->Db()->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl),
	                                                                     readStream, success,
	                                                                     CContactDatabase::EImportSingleContact+CContactDatabase::ETTFormat);
	                                                                     
	                                                                     
    //Should be the only contact in the database at this point
	TInt count = CntTest->Db()->CountL();
	test(count == 1);
	
	//Store the id of the new contact - we need this later
	TContactItemId contactId = (*contactItems)[0]->Id();
	CntTest->Db()->SetCurrentItem(contactId);
	
	readStream.Close();                                                                
	CleanupStack::PopAndDestroy(); //readStream.Close()
    contactItems->ResetAndDestroy();
    delete contactItems;
	
}
void CEmTubePlaylist::ConstructL( RFileReadStream& aStream )
	{
	TInt l = aStream.ReadInt32L();
	if( l )
		{
		iName = HBufC::NewL( l );
		TPtr pName( iName->Des() );
		aStream.ReadL( pName, l );
		}
	else
		{
		iName = KNullDesC().AllocL();
		}

	iType = (TEmTubePlaylistType)aStream.ReadInt32L();
	iFlags = aStream.ReadInt32L();

	TInt count = aStream.ReadInt32L();
	for(TInt i=0;i<count;i++)
		{
		CEmTubePlaylistEntry* e = CEmTubePlaylistEntry::NewLC();
		e->ImportL( aStream );
		iEntries.AppendL( e );
		CleanupStack::Pop( e );
		}
	}
/**
Reads the input config file created by sysstart_apparc_setup.bat and returns the
test case number (Defined in sysstart_apparc_run.bat)
@return TInt - the test case number
*/
TInt CSysStartApparcTestCase::ReadConfigFileL()
	{
	RFs	fs;
 	User::LeaveIfError(fs.Connect());
 	CleanupClosePushL(fs);

 	RFileReadStream reader;
	User::LeaveIfError(reader.Open(fs, KApparcConfigFile, EFileRead));
	CleanupClosePushL(reader);

	TChar delimChar('=');

	TBuf8<255> aDes;
	reader.ReadL(aDes, delimChar);

	//Read in a two character representation of a number and convert to an integer
	TChar result1(reader.ReadInt8L());
	TChar result0(reader.ReadInt8L());
	TInt aTestCase = result1.GetNumericValue()*10 + result0.GetNumericValue();

	// clean-up
	CleanupStack::PopAndDestroy(2, &fs);

	return aTestCase;

	}
예제 #8
0
//读取存档
void TPlayerInfo::ReadPlayerInfo()
{

    RFs oFs;
    if (oFs.Connect())
    {
        return;
    };
    RFileReadStream oReadStream;
    //如果打开失败 将返回一个非0值,则返回
    if (oReadStream.Open(oFs, *iFileName, EFileRead))
    {
        oFs.Close();
        return;
    }
    //
    oReadStream.PushL();
    TInt32 playerCount;
    oReadStream >> playerCount;
    for (TInt i = 0; i < playerCount; i++)
    {
        if (i < AWARD_PLAYER_COUNT)
        {
            //iPlayerArray[i].InternalizeL(oReadStream);
            iPlayerList[i]->InternalizeL(oReadStream);
        }
    }
    oReadStream.Pop();
    oReadStream.Release();
    oFs.Close();
}
void CTestImpExvCardSuiteStepBase::ImportItemL(TBuf<80> aPath, TBool aImportBDay)
	{
	RFs fs; 
	User::LeaveIfError(fs.Connect());  // push fs
	CleanupClosePushL(fs);
	RFileReadStream readVCFStream;
	
	INFO_PRINTF1(_L("Opening exported vcf file to import, to check REV property"));
	
	User::LeaveIfError(readVCFStream.Open(fs, aPath, EFileRead));
	
	TBuf<MAX_TEXT_MESSAGE> message;
	message.Format(KOpenVCFFile, &KExportRevUTCFile);
	INFO_PRINTF1(message);
	
	CleanupClosePushL(readVCFStream);  // readVCFStream

	if (aImportBDay)
		{
		ImportBDAYCardL(readVCFStream);
		}
	else
		{
		ImportCardL(readVCFStream);
		}

	CleanupStack::PopAndDestroy();  // readVCFStream
	CleanupStack::PopAndDestroy(); // pop fs
	}
예제 #10
0
void CheckAndInitializeFileL( RFs& aFs, TBuf<KMaxFileName>& aFile, const TDesC16& aFilePath,
                                            RFileReadStream& aTempFile, CFileMan* aFileMan )
    {
    __LOG1( ELogAlways, "CheckAndInitializeFileL() - handling file %S", &aFilePath );
    const TInt err = aTempFile.Open( aFs, aFile, EFileRead | EFileShareAny );
    __LOG1( ELogAlways, "CheckAndInitializeFileL() - open file error %d", err );
    aTempFile.Close();
    if ( err != KErrNone )
        {
        if ( err == KErrNotFound )
            {
            // Path found but not schema.mde, copy schema.m
            const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite );
            __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error );
            }
        else if ( err == KErrPathNotFound)
            {
            // Create private dir
            User::LeaveIfError( aFs.CreatePrivatePath( EDriveC ) );
            
            // Copy schema.mde
            const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite );
            __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error );
            }    
        }    
    }
예제 #11
0
// ---------------------------------------------------------------------------
// Restore the file from given directory and given index
// ---------------------------------------------------------------------------
//
EXPORT_C CXIMPApiEventBase* CXIMPTestFileTool::PluginRestoreLC(
        TInt aObjIndex )
    {
    HBufC* fileName = GetFileNameLC( 
            KFileToolPluginDirBase, 
            aObjIndex );

    // try to instantiate it
    RFileReadStream in;
    CleanupClosePushL( in );

    in.Open( iFs, *fileName, EFileStream );
    TInt len = in.ReadUint32L();
    HBufC8* buffer = HBufC8::NewLC( len );
    TPtr8 ptr = buffer->Des();
    in.ReadL( ptr );

    // instantiate the object
    TInt32 dummy = 0;
    CXIMPApiEventBase* object = XIMPEventCodec::UnPackL( *buffer, dummy );

    CleanupStack::PopAndDestroy( 2 ); // buffer, in

    // delete the just read object
    iFs.Delete( *fileName );

    CleanupStack::PopAndDestroy( fileName );

    CleanupStack::PushL( object );
    return object;
    }
예제 #12
0
// -----------------------------------------------------------------------------
// RDRMRightsClient::URIFileToArrayL
// Converts the given file into an array.
// -----------------------------------------------------------------------------
//
void RDRMRightsClient::URIFileToArrayL( RFs& aFs,
                                       const TDesC& aFile,
                                       RPointerArray< HBufC8 >& aList )
    {
    DRMLOG( _L( "RDRMRightsClient::URIFileToArrayL" ) );
    RFileReadStream stream;
    TUint16 size = 0;
    TPtr8 data( NULL, 0, 0 );

    User::LeaveIfError( stream.Open( aFs, aFile, EFileRead | EFileStream ) );
    CleanupClosePushL( stream );

    size = stream.ReadUint16L();
    while( size > 0 )
        {
        HBufC8* tmp = HBufC8::NewLC( size );
        data.Set( tmp->Des() );
        stream.ReadL( data, size );
        User::LeaveIfError( aList.Append( tmp ) );
        CleanupStack::Pop(); // tmp
        size = stream.ReadUint16L();
        }

    // All read, return.

    CleanupStack::PopAndDestroy(); // stream
    }
예제 #13
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1127
@SYMTestCaseDesc	    Stream encryption test.
                        Tests the functionality of REncryptStream and RDecryptStream classes
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for writing an encrypted string to a stream,reading back the data,decrypt and
                        check with the original data.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testSimpleStreamEncryptionL()
    {
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1127 "));
   	CPBEncryptElement* elementKey = CPBEncryptElement::NewL(KTestPassword);
	CleanupStack::PushL(elementKey);
	TParsePtrC parse(KFileLocationSpec);
	
	RFileWriteStream writeStream;
    writeStream.PushL();
    User::LeaveIfError(writeStream.Replace(TheFs, parse.NameAndExt(), EFileWrite));

	REncryptStream encryptStream;
	encryptStream.OpenLC(writeStream, *elementKey);

    encryptStream << KTestDes;
    encryptStream.CommitL();
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(2); // encryptStream, writeStream

    RFileReadStream readStream;
    readStream.PushL();
    User::LeaveIfError(readStream.Open(TheFs, parse.NameAndExt(), EFileWrite));

    RDecryptStream decryptStream;
	decryptStream.OpenLC(readStream, *elementKey);

    decryptStream >> TheBuf;

    test(KTestDes == TheBuf);

    CleanupStack::PopAndDestroy(3, elementKey); // decryptStream, readStream
    }
예제 #14
0
/**
@SYMTestCaseID			SYSLIB-SQL-CT-1635
@SYMTestCaseDesc		RSqlSecurityPolicy test.
						Tests RSqlSecurityPolicy API.
@SYMTestPriority		High
@SYMTestActions			RSqlSecurityPolicy test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ5792
                        REQ5793
*/
void SqlSecurityPolicyTest()
{
    RSqlSecurityPolicy securityPolicy;
    TInt err = securityPolicy.Create(KDefaultPolicy);
    TEST2(err, KErrNone);

    //Empty RSqlSecurityPolicy object tests
    //Database policies
    TSecurityPolicy policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy);
    TEST(policy == KDefaultPolicy);
    policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy);
    TEST(policy == KDefaultPolicy);
    policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy);
    TEST(policy == KDefaultPolicy);
    //Table policies
    policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("A-Tbl"), RSqlSecurityPolicy::EReadPolicy);
    TEST(policy == KDefaultPolicy);
    policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("B-Tbl"), RSqlSecurityPolicy::EWritePolicy);
    TEST(policy == KDefaultPolicy);
    //
    securityPolicy.Close();

    //Tests with initialized RSqlSecurityPolicy object
    CreateTestSecurityPolicy(securityPolicy);
    //Check the created and initialized object
    CheckTestSecurityPolicy(securityPolicy);

    //Externalize, then internalize and check the security policy object
    RFileWriteStream out;
    err = out.Replace(TheFs, KTestFile, EFileRead | EFileWrite);
    TEST2(err, KErrNone);
    TRAP(err, securityPolicy.ExternalizeL(out));
    TEST2(err, KErrNone);
    TRAP(err, out.CommitL());
    out.Close();
    TEST2(err, KErrNone);

    securityPolicy.Close();
    err = securityPolicy.Create(KDefaultPolicy);
    TEST2(err, KErrNone);
    RFileReadStream in;
    err = in.Open(TheFs, KTestFile, EFileRead);
    TEST2(err, KErrNone);
    TRAP(err, securityPolicy.InternalizeL(in));
    in.Close();
    TEST2(err, KErrNone);
    CheckTestSecurityPolicy(securityPolicy);

    //Change some security policies and check that the RqlSecurityPolicy content was properly updated
    err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy, KPolicy3);
    TEST2(err, KErrNone);
    policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy);
    TEST(policy == KPolicy3);
    policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EWritePolicy);
    TEST(policy == KPolicy2);
    //
    securityPolicy.Close();
}
예제 #15
0
//  Local Functions
void  ImportEntriesL(const TDesC& aFileName, RPointerArray<CCalEntry>& aCalEntries)
    {
    RFileReadStream fileReadStream;
    CleanupClosePushL(fileReadStream);
    TInt err = fileReadStream.Open(calTestLibrary->FileSession(), aFileName, EFileRead);
    
    calTestLibrary->DataExchangeL().ImportL(KUidVCalendar, fileReadStream, aCalEntries);
	
	CleanupStack::PopAndDestroy(&fileReadStream);
    }
/**
Reads data chunk from the file stream.
@return ETrue if the EOF found.
@param aFileReadStream - reference to file stream 
@param aPtrLineBuffer - reference to the buffer data read
@param aIsUnicode - flag to check is it Unicode or ASCII file
@param aIgnoreCharList - pointer to ingnore char list
@leave KErrNotFound
 */
TBool TestFrameworkActionsUtils::ReadDataL(RFileReadStream& aFileReadStream,
	  TPtr& aPtrLineBuffer, TBool aIsUnicode, CArrayFixFlat<TUint16>* aIgnoreCharList)
 	{
	TUint16			element = 0;
	TKeyArrayFix	key(0, ECmpTUint16);
	TInt			charPosition = 0;
	TBool			eof = EFalse;
	TInt			errorCode = KErrNone;
	TUint8			aCharASCII = 0;

	aPtrLineBuffer.FillZ();
	aPtrLineBuffer.SetLength(0);	
	
	// Validate the input ignore char list
	if (!aIgnoreCharList)
		{
		// Invalid parameter passed to ReadDataL: No ignore char list passed
		User::Leave(KErrNotFound);
		}

	// Read data from file and store it in lineBuffer 
	do   
		{
		if(aIsUnicode)
			{
			TRAP(errorCode, (element = aFileReadStream.ReadUint16L()));
			}
		else
			{
			TRAP(errorCode, (aCharASCII = aFileReadStream.ReadUint8L()));
			element = (TUint16) aCharASCII;
			}
			
		if (errorCode!=KErrEof)
			{		
			// Check the availability of ignore char in the array							
			if ( aIgnoreCharList->Find(element, key, charPosition) != KErrNone )
				{
				// Append the char to the buffer if the read char is not ignore char
				aPtrLineBuffer.Append(element);
				}
			}								
			else
				{
				eof = ETrue;
				break;
				}
				
			// Stop at the end of line or no more data 
			} while(aPtrLineBuffer.Length()<KDefBufferSize);
	
	// Return end of file flag		
	return eof;	
	}
예제 #17
0
// -----------------------------------------------------------------------------
// RDRMRightsClient::FileToListL
// Converts the given file into an array.
// -----------------------------------------------------------------------------
//
void RDRMRightsClient::FileToListL( RFs& aFs,
                                   const TDesC& aFileName,
                                   RPointerArray< CDRMPermission >& aList )
    {
    DRMLOG( _L( "RDRMRightsClient::FileToListL" ) );
    TInt error = KErrNone;

    // Temporary storage.
    CDRMPermission* tmpObject;

    // To access the file data.
    RFileReadStream fileStream;

    // How many objects there is in the file.
    TInt size = 0;

    // Temporary counter.
    TInt count = 0;


    // Open the file.
    User::LeaveIfError( fileStream.Open( aFs, aFileName, EFileRead | EFileStream ) );
    CleanupClosePushL( fileStream );

    size = fileStream.ReadInt32L();

    while( count < size )
        {
        // Allocate a new RO.
        tmpObject = CDRMPermission::NewL();

        // Read the object.
        TRAP( error, tmpObject->InternalizeL( fileStream ) );

        if ( !error )
            {
            // Add the object into the list.
            error = aList.Append( tmpObject );
            }

        if ( error )
            {
            delete tmpObject;
            User::Leave( error );
            }

        // Now tmpObject is under responsibility of aList.
        ++count;
        }

    // All done.
    CleanupStack::PopAndDestroy(); // fileStream
    }
예제 #18
0
void CTransactionsStep::TransactionPerformanceL(	const TBool aDelete, 
													const FieldFullness aField,
													const TInt aContacts,
													TReal &aDiffseconds,
													TReal &aCumseconds)
	{
	iContacts = ( ( aContacts / KTransactionSize ) + 1 ) * KTransactionSize ;
	TInt64 cumlative = 0;
	TInt64 diff = 0;
	TTime startT;
	TTime finishT;
	TTime start;
	TTime finish;

	TInt j = 0;
	for(; j < KPerfIter; ++j)
		{
		CPerformanceFunctionalityBase::InitializeL();
		ModifyContactsL(aField);
		ExportVcardL( aDelete, KVcardFile );
		RFileReadStream rfrs;
		CleanupClosePushL( rfrs );
		User::LeaveIfError( rfrs.Open( iParent->Fs(), KVcardFile, EFileRead | EFileShareAny ) );
		
		TInt i = 0;
		start.UniversalTime();
		for(; i < iContacts; i+=KTransactionSize)
			{
			iContactsDatabase->DatabaseBeginLC(EFalse);
			ImportVcardL(KTransactionSize, rfrs);
			startT.UniversalTime();
			iContactsDatabase->DatabaseCommitLP(EFalse);
			finishT.UniversalTime();
			cumlative += ( finishT.MicroSecondsFrom( startT ).Int64() );
			}
		finish.UniversalTime();
		diff += ( finish.MicroSecondsFrom(start).Int64() );
		CleanupStack::PopAndDestroy(&rfrs);
		}
	User::LeaveIfError( iParent->Fs().Delete(KVcardFile) );
	
	aDiffseconds = (TReal) diff / (1000000 * KPerfIter);
	aCumseconds = (TReal) cumlative / (1000000 * KPerfIter);
	
	_LIT(KMicroPerformance, "Micro performance: %d");
	_LIT(KSecondsPerformance, "performance in seconds: %f");
	_LIT(KCommitPerformance, "commit performance in seconds: %f");
	ALLPRINT2(KMicroPerformance, diff); 
	ALLPRINT2(KSecondsPerformance, aDiffseconds ); 
	ALLPRINT2(KCommitPerformance, aCumseconds ); 
	}
예제 #19
0
// -----------------------------------------------------------------------------
// CBSBrandHandler::VerifyVersionL()
// -----------------------------------------------------------------------------
//
void CBSBrandHandler::VerifyVersionL()
	{
	if( !iHandle )
		{
		User::Leave( KErrNotReady );
		}
	RFileReadStream stream;
	stream.Attach( *iHandle );
	CleanupClosePushL( stream );
	
	VerifyVersionL( stream );
	
	CleanupStack::PopAndDestroy(); // stream
	}
예제 #20
0
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CRequestManager::ReadConfigInfoL()
    {
    FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::ReadConfogInfoL Sstart"));
    RFileReadStream readStream;
    User::LeaveIfError( readStream.Open(CCoeEnv::Static()->FsSession(), 
    					iCongFileName->Des(), EFileRead) );
    readStream.PushL();
    readStream >> iVendorName; 
	readStream >> iProductName;
	
    CleanupStack::PopAndDestroy(&readStream);
    
    FLOG(_L("[IMAGEPRINTUI]\t CRequestManager::ReadConfogInfoL end"));
    }
예제 #21
0
TBool CSyntaxTest::LoadResultsL()
	{
	RFile resultsFile;
	TFileName fullPath;
	TInt err, fileSize;
	HBufC8 *fileInfo;

	fullPath.Append(iPath);
	fullPath.Append(KResultsFile);

	err = resultsFile.Open(iFs, fullPath, EFileRead);
	if (err != KErrNone)
		{
		iConsole.Printf(_L("Error opening results file : "));
		iConsole.Printf(fullPath);
		iConsole.Printf(_L("\n"));
		return(EFalse);
		}

	CleanupClosePushL(resultsFile);
	resultsFile.Size(fileSize);
	CleanupStack::PopAndDestroy(); // resultsFile
	
	fileInfo = HBufC8::NewLC(fileSize);
	TPtr8 fileInfoPtr(fileInfo->Des());
	fileInfoPtr.SetLength(fileSize);

	RFileReadStream fileStream;
	User::LeaveIfError(fileStream.Open(iFs, fullPath, EFileStream));
	CleanupClosePushL(fileStream);
	fileStream.ReadL(fileInfoPtr, fileSize);

	TLex8 theLex(fileInfoPtr);
	CSyntaxResult *syntaxResult = NULL;
	
	do
		{
		syntaxResult = CSyntaxResult::NewLC();
		syntaxResult->SetFilename(theLex.NextToken());
		syntaxResult->SetResult(theLex.NextToken());
		iExpectedResults->Append(syntaxResult);
		CleanupStack::Pop(); // syntaxResult
		}
	while(!theLex.Eos());

	CleanupStack::PopAndDestroy(2);  // fileinfo & fileStream
	return(ETrue);
	};
/**
 Overload of the CCoeAppUi virtual method.
 The method in the base class merely returns ETrue. Overloads would normally just return EFalse.
 In this case however, we do some jiggery-pokery in order to invoke the StartSafe retry mechanism.
 ie we return EFalse on each of several invocations but don't do the Rendezvous, then 
 eventually ETrue, so the Framework Rendezvous for us. our final invocation therefore being successful.
 
 The count file is written from the test-step, and 
 if successful, deleted here.
 
 The code is nearly all parenthesised within a TRAP harness in order to preserve the integrity 
 of this function, which is called by the framework.

*/
TBool CTestAppUi::FrameworkCallsRendezvous() const
	{
	
	TBool frameworkRendezvous = EFalse;

	TRAPD( err,
		{			
		RFs fs;
		RFileReadStream readStream;
		RFileWriteStream writeStream;
						
		CleanupClosePushL( fs );
		CleanupClosePushL( readStream );
		CleanupClosePushL( writeStream );
		
			
		if( KErrNone != fs.Connect()
		 || KErrNone != readStream.Open(fs, KDontRvCountFile, EFileRead) )
			{
			User::Leave( KErrCouldNotConnect );	
			}
		

		TInt failCount = readStream.ReadInt8L();
		readStream.Close();	
		

		if( 0 == failCount )
			{
			fs.Delete( KDontRvCountFile );
			
			// We've decided to be good this time. Let the framework do it for us.
			frameworkRendezvous = ETrue;
			}
		else
			{
			// StartSafe will timeout while waiting for a Rendezvous()
			User::LeaveIfError( writeStream.Open(fs, KDontRvCountFile, EFileWrite) );
	
			writeStream.WriteInt8L( --failCount );
			writeStream.CommitL();
			writeStream.Close();
			}
			
		CleanupStack::PopAndDestroy( 3, &fs );
		} );
void CAppfwkAmaStarterTestStepCancel::TestCase1L()
	{
	// Launch the appropriate AMAStarter(s) via CAmaStart::StartL()
	
	TRequestStatus myRequestStatus;

	CAmaStart* amaStart = CAmaStart::NewL();
	CleanupStack::PushL(amaStart);
	
	amaStart->Start(TUid::Uid(0x10000017), myRequestStatus);
	TEST(myRequestStatus == KRequestPending);
	User::After(100000); // Wait for a tenth of a second to give the starter a chance to start something - if the cancel is issued without waiting, nothing is started.
	amaStart->CancelStart();	
	User::WaitForRequest(myRequestStatus);
	TEST(myRequestStatus == KErrCancel);
	INFO_PRINTF3(_L("CAmaStart->Start(TUid::Uid(0x10000017), &myRequestStatus) finished with request status '%d' (expected '%d')"), myRequestStatus.Int(), KErrCancel);
	
	//Check that the last item in the DSC didn't run
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	RFileReadStream rs;
	TInt ret = rs.Open(fs, KLogFileName, EFileShareExclusive|EFileRead);
	if (KErrNone != ret)
		{
		ERR_PRINTF2(_L("Could not open log file. Leave code: '%d'"), ret);
		User::LeaveIfError(ret);
		}
	rs.PushL();
	const TInt KMaxCommandLength = 256;
	TBuf<KMaxCommandLength> commandLine;
	rs.ReadL(commandLine,1);
	TEST(commandLine.Compare(_L("9")) != 0);
	INFO_PRINTF2(_L("Checking log result: Expected not '9', Actual '%s'"), &commandLine);
	CleanupStack::PopAndDestroy(); //rs
	
	ret = fs.Delete(KLogFileName);
	if (KErrNone != ret)
		{
		ERR_PRINTF2(_L("Could not delete log file. Leave code: '%d'"), ret);
		User::LeaveIfError(ret);
		}

	// clean-up
	CleanupStack::PopAndDestroy(2,amaStart); // fs, amaStart
	}
예제 #24
0
// -----------------------------------------------------------------------------
// CBSBrandHandler::VerifyVersionL()
// -----------------------------------------------------------------------------
//
void CBSBrandHandler::VerifyVersionL( RFileReadStream& aStream )
	{
	TInt version = aStream.ReadInt16L();
	if( version != iReserved )
		{
		User::Leave( KErrArgument );
		}
	}
void CEmTubePlaylistEntry::ImportL( RFileReadStream& aStream )
	{
	TInt l = aStream.ReadInt32L();
	if( l )
		{
		iLocation = HBufC::NewL( l );
		TPtr pLocation( iLocation->Des() );
		aStream.ReadL( pLocation, l );
		}
	else
		{
		iLocation = KNullDesC().AllocL();
		}

	l = aStream.ReadInt32L();
	if( l )
		{
		iName = HBufC::NewL( l );
		TPtr pName( iName->Des() );
		aStream.ReadL( pName, l );
		}
	else
		{
		iName = KNullDesC().AllocL();
		}

	iPlayCount = aStream.ReadInt32L();
	iType = (TEmTubePlaylistEntryType)aStream.ReadInt32L();
	TReal t = aStream.ReadReal64L();
	iTime = TTime( Int64( t ) );
	}
void CJavaDebugAgentSettings::LoadL(const TDesC& aPrefsFile)
{
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFileReadStream in;
    in.PushL();
    User::LeaveIfError(in.Open(fs, aPrefsFile, EFileRead));
    TRAPD(err, LoadL(&in));
    in.Close();
    in.Pop();

    if (err != KErrNone) {
        err = fs.Delete(aPrefsFile);
    }
    CleanupStack::PopAndDestroy(&fs);
}
예제 #27
0
/**
 Start a test application synchronously using Wait-for-Signal with timeout
 more than the time required for the application to start and which starts after the no. of retries given.
*/
void CSsTestStepAppTimeout::DoTestWaitForSignalWithMoreTimeOutAndWithRetriesL()
	{	
	INFO_PRINTF1(_L("Performing Wait-for-Signal test with timeout and retries"));

	// Write the retry number to a file to be read, updated 
	// and eventually deleted by the test-app.
	RFs fs;	
	CleanupClosePushL( fs );
	
	RFileWriteStream writeStream;
	CleanupClosePushL( writeStream );

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(writeStream.Replace(fs, KFileForFAndF, EFileWrite));

	const TInt KSsTestRequiredDelay = 0;
	const TInt KSsTestFailCount = 1;
	const TInt KSsTestRetryCount = 0;
	writeStream.WriteInt8L(KSsTestRetryCount);
	writeStream.WriteInt8L(KSsTestFailCount);
	writeStream.WriteInt8L(KSsTestRequiredDelay);
	writeStream.CommitL();
	writeStream.Close();
	
	const TInt KRetries = KSsTestFailCount + 1;
	TInt completionCode = DoTestAndStopperL(KRetries, KWaitTimeForTestAppForFAndF * 3, KTestAppForFAndF);
	TEST(completionCode == 0);
	
	INFO_PRINTF2( _L("Anticipated completion code 0. Supplied completion code %d"),completionCode);
	RFileReadStream readStream;
	CleanupClosePushL(readStream);

	User::LeaveIfError(readStream.Open(fs, KFileForFAndF, EFileRead));
	TInt retryCount = readStream.ReadInt8L();
	readStream.Close();	
	fs.Delete(KFileForFAndF);

	CleanupStack::PopAndDestroy(3, &fs);

	TEST(1 == FindAndKill(KTestAppForFAndF));
	TEST(retryCount == 1);

	INFO_PRINTF3( _L("ssmtestappsucessfulafterretry.exe is started after %d retries. anticipated retries value %d"),retryCount, 1);
	}
예제 #28
0
// ----------------------------------------------------------------------------
// CAudioStreamEngine::LoadAudioFileL()
//
// loads the audio data from a file into the buffer
// ----------------------------------------------------------------------------
void CAudioStreamEngine::LoadAudioFileL()
    {
    RFileReadStream audiofile;

    // open file
    TFileName fileName;
    fileName.Copy(iAudioFilePath);
    fileName.Append(iAudioFile);

    TInt err = audiofile.Open(iFs, fileName, EFileRead|EFileStream);
    iStreamBuffer->Des().FillZ(iFrameCount * iFrameSize);  // Empty the stream buffer
    if (err==KErrNone) 
        {
        // file opened ok, proceed reading
        if (iUseAMR)
            {
            // Read the AMR header (the first 6 bytes). We don't need to save/use the header,
            // since while playback we already know it's an AMR-NB encoded stream.
            TBuf8<KAMRHeaderLength> temp;
            audiofile.ReadL(temp, KAMRHeaderLength);
            }

        TUint idx=0;
        while (idx < iFrameCount)
            {
            TRAPD(fstatus, audiofile.ReadL(GetFrame(idx), iFrameSize));
            if (fstatus!=KErrNone)
                break;
            idx++;
            }
        iStreamStart=0;
        iStreamEnd=idx-1;
        ShowMessage(_L("CAudioStreamEngine::LoadAudioFileL() Loading complete!"), ETrue);
        iBufferOK = ETrue;  
        }   
    else 
        {
        // failed to open file
        ShowMessage(_L("CAudioStreamEngine::LoadAudioFileL() Error loading audio sample!"), ETrue); 
        iBufferOK = EFalse;
        }
    audiofile.Close();
    }
예제 #29
0
EXPORT_C TInt TEFparser::ReadFileLC(RFs& aFs, 
										const TDesC& aScriptFilepath,
										TPtrC& aScriptFileContents )
	{
	
	RFile scriptFile;
	TInt err = scriptFile.Open(aFs, aScriptFilepath, EFileStream | EFileRead | EFileShareAny);
	if (err != KErrNone)
		{	
		return KErrNotFound;
		}
	// gets size of ini file
	TInt size;
	scriptFile.Size(size);
	scriptFile.Close();
			
	// reads ini into iTestInput
	HBufC* scriptFileH16 = HBufC::NewLC(size);
	HBufC8* scriptFileH = HBufC8::NewLC(size);
	
	//RBuf scriptFileR;
	TPtr8 pInput = scriptFileH->Des(); 
	TPtr pInput16 = scriptFileH16->Des(); 
	
	pInput.SetLength(size); 
	
	RFileReadStream stream;
	User::LeaveIfError(stream.Open(aFs, aScriptFilepath, EFileStream | EFileRead | EFileShareReadersOnly));
	CleanupClosePushL(stream);
	stream.ReadL(pInput,size);
	
//	stream.ReadL(pInput, size);
	
	pInput16.Copy(pInput);
	//scriptFileR.Assign(scriptFileH16);
	
	aScriptFileContents.Set(*scriptFileH16);
	
	CleanupStack::PopAndDestroy(2); // stream, testInput
	
	return KErrNone;
	}
예제 #30
0
HBufC8* CValidateTest::ReadFileLC(const TDesC& aFilename)
	{
	RFile file;
	User::LeaveIfError(file.Open(iFs, aFilename, EFileRead));
	CleanupClosePushL(file);
	TInt size;
	file.Size(size);
	CleanupStack::PopAndDestroy(1);//fileClose

	HBufC8* res = HBufC8::NewLC(size);
	TPtr8 p(res->Des());
	p.SetLength(size);

	RFileReadStream stream;
	User::LeaveIfError(stream.Open(iFs, aFilename, EFileStream));
	CleanupClosePushL(stream);
	stream.ReadL(p, size);
	CleanupStack::PopAndDestroy();//streamClose...bleurgh
	return res;
	}