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 ) );
	}
/**
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;

	}
// ---------------------------------------------------------------------------
// 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;
    }
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 );
		}
	}
// -----------------------------------------------------------------------------
// 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
    }
// ----------------------------------------------------------------------------
// 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();
    }
示例#7
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);
	};
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
	}
示例#9
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;
	}
示例#10
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;
	}
EXPORT_C TInt CSenLogger::CreateL(TInt aChannel, TInt aLevel, const TDesC& aLogDir, const TDesC& aLogFileName, TFileLoggingMode aMode)
    {
    TInt index(KErrNotFound);
    CSenLogger* pSenLogger = NULL;
    TWsTls* tls = (TWsTls*)Dll::Tls();
    if( !tls )
        {
        tls = new (ELeave) TWsTls();
        tls->iLogger = NULL;
        tls->iProxy = NULL;
        Dll::SetTls( tls );
        }
    pSenLogger = tls->iLogger;    
	if ( !pSenLogger )
  		{
  		pSenLogger = new (ELeave) CSenLogger();
        if ( pSenLogger )
            {
            tls->iLogger = pSenLogger;
      		pSenLogger->iCount = 0;
      		//reading the configuration file for the logging levels!!!
      		
      		/*the file has the  following format (IN ANSI)
      		* ==============================================================================
      		  * LogChannel LogLevel
      		    1000 0
      		    2000 1
      		      .
      		      .
      		      .
      		      .
      		      .
      		      ....
      		    18000 2
      		   this means first you need to write the channel followed by the corresponding logging level after a space
      		 
      		 the file has to be located under C:\Config.txt
      		 * ==============================================================================*/
      		 
      
      		TInt res;
      	    RFs fs;
      	    res=fs.Connect();
      	      if(res==KErrNone)
			{
			RFileReadStream readStream;
	      	res=readStream.Open(fs, KPath, EFileRead|EFileStreamText);
			if(res == KErrNone)
				{
				TInt error;
				TInt retVal;
				do
					{
					TBuf8<128> readLineBuf;
					TRAP(error, readStream.ReadL(readLineBuf, (TChar)'\n'));
					if(error == KErrNone)
						{      
						TInt32 length(0);
						length = readLineBuf.Length() ;
						TInt *key = new (ELeave) TInt;
						TLex8 lexBuf(readLineBuf);
						retVal = lexBuf.Val(*key);

						if(retVal!=0)
							{
							delete key;
							continue;
							}
						else
							{
							TInt *value = new (ELeave) TInt;
							lexBuf.SkipSpace();
							retVal=lexBuf.Val(*value);
							if(retVal==0)
								{
								retVal = pSenLogger->iMap.Append(key,value);
								if(retVal != KErrNone)
									{
									delete key;
									delete value;
									}
								}
							else
								{
								delete key;
								delete value;
								}
							}
						}
					}while(error == KErrNone);
				readStream.Close();
				}
			fs.Close();
			}
            }
        else
            {
            return KErrGeneral;
            }
  		}
  	else
  	    {
  	    index = pSenLogger->ChannelIndex(aChannel);
  	    }	
  	
  	if (index == KErrNotFound)
  	    {
  	    TInt channelIndex;
        TLog* pTLog = new (ELeave) TLog;
        CleanupStack::PushL(pTLog);
        pTLog->iChannel=aChannel;
        channelIndex=pSenLogger->iMap.Find(aChannel);
        if(channelIndex==KErrNotFound)
        {
        pTLog->iLevel=aLevel;
        }
        else
        {
        pTLog->iLevel=*(pSenLogger->iMap.ValueAt(channelIndex));
        }
        pTLog->iCount=1;
        pTLog->iLog.Connect();
        pTLog->iLog.CreateLog(aLogDir, aLogFileName, aMode);
        pTLog->iLog.Write(_L("SenTLSLogger - Log file opened"));
#ifdef EKA
        pSenLogger->iLogs.AppendL(pTLog);
#else
        User::LeaveIfError(pSenLogger->iLogs.Append(pTLog));
	  
#endif
        CleanupStack::Pop(pTLog);
  	    }
  	else
  	    {
  	    pSenLogger->iLogs[index]->iCount++;
  	    }
  	pSenLogger->iCount++;
    
    return KErrNone;
    }
示例#12
0
void CVideoEntry::ImportL( RFileReadStream &aStream )
	{
	delete iBitmap;
	iBitmap = NULL;
	delete iScaledBitmap;
	iScaledBitmap = NULL;
	delete iMediaTitle;
	iMediaTitle = NULL;
	delete iUrl;
	iUrl = NULL;
	delete iThumbnailUrl;
	iThumbnailUrl = NULL;
	delete iThumbnailFile;
	iThumbnailFile = NULL;
	delete iVideoId;
	iVideoId = NULL;
	delete iAuthorName;
	iAuthorName = NULL;
	delete iAuthorUrl;
	iAuthorUrl = NULL;
	delete iRelatedUrl;
	iRelatedUrl = NULL;
	delete iAuthorVideosUrl;
	iAuthorVideosUrl = NULL;

	TInt len;

	len = aStream.ReadInt16L();
	if( len )
		{
		iMediaTitle = HBufC::NewL( len );
		TPtr tmp(iMediaTitle->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iMediaTitle = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iUrl = HBufC::NewL( len );
		TPtr tmp(iUrl->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iUrl = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iThumbnailUrl = HBufC::NewL( len );
		TPtr tmp(iThumbnailUrl->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iThumbnailUrl = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iThumbnailFile = HBufC::NewL( len );
		TPtr tmp(iThumbnailFile->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iThumbnailFile = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iVideoId = HBufC::NewL( len );
		TPtr tmp(iVideoId->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iVideoId = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iAuthorName = HBufC::NewL( len );
		TPtr tmp(iAuthorName->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iAuthorName = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iAuthorUrl = HBufC::NewL( len );
		TPtr tmp(iAuthorUrl->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iAuthorUrl = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iRelatedUrl = HBufC::NewL( len );
		TPtr tmp(iRelatedUrl->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iRelatedUrl = KNullDesC().AllocL();
		}

	len = aStream.ReadInt16L();
	if( len )
		{
		iAuthorVideosUrl = HBufC::NewL( len );
		TPtr tmp(iAuthorVideosUrl->Des());
		aStream.ReadL(tmp, len);
		}
	else
		{
		iAuthorVideosUrl = KNullDesC().AllocL();
		}

	iThumbnailHeight = aStream.ReadInt32L();
	iThumbnailWidth = aStream.ReadInt32L();
	iDuration = aStream.ReadInt32L();
	iAverageRating = aStream.ReadReal32L();
	iViewCount = aStream.ReadInt32L();
	}
示例#13
0
// ----------------------------------------------------------------------------
// WidgetPreferences::PreferenceL
// Get preference for a key
//
//
// ----------------------------------------------------------------------------
TInt WidgetPreferences::preferenceL( const TDesC& akey, HBufC*& avalue)
{

    TInt rSuccess = KErrNotFound;
    TInt size = 0;

    if ( !m_basepath || (m_basepath->Length() <= 0) )
        return rSuccess;


    if ( akey.Length() <= KMaxKeyValueSize ) {

        HBufC* k = HBufC::NewLC( akey.Length() + KMaxIntLength + 1 );
        k->Des().Format( KKeyFormat, m_widgetid, &akey );

        PrefElement* pref = m_preferences->Find( *k );

        if ( !pref ) {
            CleanupStack::PopAndDestroy( k );
            return rSuccess;
        }

        size = pref->valueSize();

        if ( size > KMaxKeyValueSize ) {
            // return contents from temp file whose name is stored
            // in the m_value member of m_preferences
            RFs fs;

            if ( fs.Connect() == KErrNone ) {
                CleanupClosePushL( fs );
                HBufC* filePath = HBufC::NewLC( pref->value().Length() );
                TPtr fName( filePath->Des() );
                fName.Append( pref->value() );

                RFileReadStream readStream;

                if ( readStream.Open( fs, *filePath, EFileRead ) == KErrNone ) {
                    CleanupClosePushL( readStream );
                    TInt len( readStream.ReadInt32L() );
                    if ( len > 0 ) {
                        HBufC* v = HBufC::NewLC( len );
                        TPtr ptrvalue = v->Des();
                        readStream.ReadL( ptrvalue, len );
                        avalue = v; // ownership xfered
                        CleanupStack::Pop( v );
                        rSuccess = KErrNone;
                    }
                    CleanupStack::PopAndDestroy();//readStream
                }

                CleanupStack::PopAndDestroy( 2 ); //filePath,fs
            }
        }
        else if ( size >= 0 ) {
            avalue = pref->value().AllocL();
            rSuccess = KErrNone;
        }

        CleanupStack::PopAndDestroy( k );
    }

    return rSuccess;

}