// -----------------------------------------------------------------------------
// CContactSubscriber::RunL()
// Assyncronous request handler , on completion of notification
// -----------------------------------------------------------------------------
//
void CContactSubscriber::RunL()
{
    __TRACE_CALLSTACK;
    SubscribeChangeNotiFication();
    // property updated, get new value 
    TBuf8 <KBufferSize> value; 
    TPtrC8  id; 
    TPtrC8  sourceType; 
    TPtrC8  addressCount; 
    
    if ( KErrNone == iProperty.Get( value ) )
    { 
        TInt pos =  value.Locate(TChar('-')); 
        id.Set( value.Left(pos) ); 
        
        TPtrC8 ptr = value.Right(3); 
        sourceType.Set(ptr.Left(1)); 
        addressCount.Set(ptr.Right(1)); 
        
        TInt appId = -1, addressType = -1, addressTypeCount = -1; 
        TLex8 lex(id); 
        lex.Val(appId); 
        
        TLex8 lex1(sourceType); 
        lex1.Val( addressType ); 
        
        TLex8 lex2(addressCount); 
        lex2.Val(addressTypeCount); 
        
        iNotifyChange.GetChangeNotificationL( appId, addressType,addressTypeCount ); 
    } 
}
void CTmsTestStep::CleanUpAndWriteResults()
{
    RFs fs;
    fs.Connect();
    CleanupClosePushL(fs);

    iTestStepPositions.Close();
    if (iTestStepNames != NULL)
    {
        iTestStepNames->Reset();
        delete iTestStepNames;
        iTestStepNames = NULL;

        if (BaflUtils::FolderExists(fs, KLogLocation))
        {
            RFile file;
            if (BaflUtils::FileExists( fs, KLogLocation ))
            {
                // open the temporary tms log
                TInt err = file.Open( fs, KLogLocation, EFileRead|EFileShareAny);
                if(err == KErrInUse)
                {
                    CleanupStack::PopAndDestroy();
                    return;
                }
                if (err == KErrNone)
                {
                    CleanupClosePushL(file);
                    TBuf8<256> line;
                    TBuf<250> testID;
                    TBuf<6> testResult;
                    // get a line from the temporary tms log
                    while (CTmsTestStep::ReadNextLineL(file,line))
                    {
                        TInt blankPos = line.Find(KBlankSpace);

                        // get the ID from the line
                        testID.Copy(line.Left(blankPos));

                        //get the pass or fail result from the line
                        testResult.Copy(line.Mid(blankPos+1,4));

                        // print into the standard tef log the id and the result in the correct format
                        // so that they are correctly parsed into the TMS csv file
                        INFO_PRINTF2(_L("START_TESTCASE %S"),&testID);
                        INFO_PRINTF2(_L("Line = 1 Command = START_TESTCASE %S"),&testID);
                        INFO_PRINTF2(_L("END_TESTCASE %S"),&testID);
                        INFO_PRINTF3(_L("Line = 1 Command = END_TESTCASE %S ***TestCaseResult = %S"),&testID,&testResult);
                    }
                    CleanupStack::PopAndDestroy();
                }
                // remove the temporary tms log
                fs.Delete(KLogLocation);
            }
        }
    }
    CleanupStack::PopAndDestroy();
}
Ejemplo n.º 3
0
CPBDecryptor* CPBEncryptSet::NewDecryptL(void) const
	{
	TBuf8<KPBEMaxCipherKeyBytes> masterKey;
	DecryptMasterKeyL(masterKey);

	CPBDecryptor* decryptor = 0;
	//make sure the masterkey we pass is exactly the right length for the cipher
	decryptor = CPBDecryptorSet::NewL(iData->EncryptParms().Cipher(),
		masterKey.Left(PBE::GetKeyBytes(iData->EncryptParms().Cipher())));		
	return decryptor;
	}
Ejemplo n.º 4
0
void CCntPBAPSupport::CompareExportsL(const TDesC8& aExpected)
    {
    
	RFile exportedFile;	
	TInt err = exportedFile.Open(iFsSession, KTempExportFile(), EFileRead);
	if (err != KErrNone)
		{
		ReportFileErrorL(err, KTempExportFile());	
		}
	CleanupClosePushL(exportedFile);
	RFileReadStream stream1(exportedFile);
	CleanupClosePushL(stream1);

	TBuf8<0x80> bufO;
	
	TInt line = 1;
	do {
		TRAP(err, stream1.ReadL(bufO, TChar(0xa)));
		if (err != KErrNone && err != KErrEof)
			{
			User::Leave(err);	
			}
        			
    	_LIT8(KPropREV,"REV:");
    	_LIT8(KPropUID,"UID:");
		TBufC8<4> first4char(bufO.Left(4));
		if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID()))
		    {
		    continue;
		    }
		
        if (KErrNotFound == aExpected.Find(bufO))
        	{
        	TBuf<256> info;
            info.Copy(bufO);
            TRefByValue<const TDesC> format(info);
            test.Printf(format);
            test (EFalse);
        	}
		++line;
		} while (err != KErrEof);
	CleanupStack::PopAndDestroy(2,&exportedFile);
    }
Ejemplo n.º 5
0
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
	{
	TBuf8<KMaxBinaryLength> val;
	TInt ret = iImpl->Get(aKey, val);	
	if (ret==KErrNone)
		{
		TInt settingValueLength=val.Length();
		//now check whether any string overflow
		if (settingValueLength > aValue.MaxLength())
			{
			aActualLength=settingValueLength;
			aValue.Copy(val.Left(aValue.MaxLength()));
			return KErrOverflow;
			}
		else
			{
			aValue.Copy(val);
			}
		}	
	return ret;	
	}
TInt RMmCustomAPI::GetParameterValue(TInt aLineNumber,TInt aIndex ) 
{
		
		if ( KErrNone != iFileError)
		 	return -1;
		
		RFile fread;	
		TInt lError = fread.Open(iFs,KMyFile,EFileRead); 	
		RFileReadStream rfs(fread);
		
		TChar delmeter(10); 
		TInt ret = -9999;
		TInt err;
		if ( KErrNone == lError )
		    {
		    for(TInt i = 0; i < aLineNumber; i++ )
		    	{
					TRAP(err,rfs.ReadL(iLineBuffer,delmeter));
					if(err != KErrNone)
						{
							rfs.Close();	
							fread.Close();	    
							return -1;
						}
					iLineBuffer.Copy(iLineBuffer.Left(iLineBuffer.Length() - 2 ));
		    	}
		    }
		    
	TBuf8<64> restBuffer;  
	TInt pos = KErrNotFound;
	TChar c(44); // 44 means ',' 
	
	if(aIndex != -1 )
		{
			for(TInt i = 0; i < aIndex; i++ )
				{
					pos = iLineBuffer.Locate(c);    
					if(pos == KErrNotFound)
						break;
					restBuffer.Copy(iLineBuffer.Left(pos ));
					iLineBuffer.Copy(iLineBuffer.Mid( pos + 1));
				}
			if(pos != KErrNotFound)	
				iLineBuffer.Copy(restBuffer);
		}
		
	if(ret == -9999)	    
		{
			pos = iLineBuffer.Locate(c);    
			if(pos != KErrNotFound)
				{
					restBuffer.Copy(iLineBuffer.Left(pos ));
					iLineBuffer.Copy(restBuffer);
				}
			TLex8 input(iLineBuffer);		    
			input.Val(ret);
		}
	
	rfs.Close();	
	fread.Close();	    

	return ret;
	
#if 0
		RFs fs;
		RFile fread;
		TInt lError = fs.Connect();
		if ( KErrNone != lError )
		 	return -1;
		 	
		 lError = fread.Open(fs,KMyFile,EFileRead);
		RFileReadStream rfs(fread);
		TBuf8<8> buf;
		TChar delmeter(10); 
		TInt ret = -999;
		TInt err;
		if ( KErrNone == lError )
		    {
		    for(TInt i = 0; i < aIndex; i++ )
		    	{
					TRAP(err,rfs.ReadL(buf,delmeter));
					if(err != KErrNone)
						{
							rfs.Close();	
							fread.Close();	    
							fs.Close();
							return -1;
						}
					buf.Copy(buf.Left(buf.Length() - 2 ));
		    	}
		    }
		    
	if(ret == -999)	    
		{
			TLex8 input(buf);		    
			input.Val(ret);
		}
	
	rfs.Close();	
	fread.Close();	    
	fs.Close();
	return ret;
#endif	

}	
Ejemplo n.º 7
0
// -----------------------------------------------------------------------------
// CLogPlayerManager::ContinueExecutionL()
// -----------------------------------------------------------------------------
//
void CLogPlayerManager::ContinueExecutionL()
    {
    _LIT8( KOpenDb, "OPENDB" );
    _LIT8( KDefineVolume, "DEFINEVOLUME" );
    _LIT8( KReset, "RESET" );
    _LIT8( KFlush, "FLUSH" );
    _LIT8( KAdd, "ADD" );
    _LIT8( KUpdate, "UPDATE" );
    _LIT8( KDelete, "DELETE" );
    _LIT8( KSearch, "SEARCH" );
    _LIT8( KGet, "GET" );
    _LIT8( KCancel, "CANCEL" );
    _LIT8( KHouseKeep, "HOUSEKEEP" );


    // Note: Huge descriptor from stack. Re-use this if possible.
	// TODO: Remove and use member variable iTextBuffer
	TBuf8<KLogPlayerMaxTextLength> textBuffer;

	// Read command
	ReadTextL(iReadStream, textBuffer);

	// Command: OPENDB
	if (textBuffer.Compare(KOpenDb) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("OPENDB\n"));
            }
		TInt index = 0;
		TBool isSearcher = EFalse;
		HBufC* baseAppClass = ReadOpenDbL(iReadStream, index, isSearcher);
		CleanupStack::PushL( baseAppClass );

		if ( index == iHandle )
		{
			if ( isSearcher )
			{
				TRAP_IGNORE( iSearcher->OpenDatabaseL(*baseAppClass) );
			}
			else
			{
				TRAP_IGNORE( iIndexer->OpenDatabaseL(*baseAppClass) );
			}
		}
		CleanupStack::PopAndDestroy( baseAppClass );

		// Check if handler for this index is created
		if ( iHandle == -1 && !IsHandlerCreated( index ) )
		{
			THandleInformation handleInformation;
			handleInformation.iLogFileName = iLogFileName;
			handleInformation.iFilePosition = iStartPosition.Offset();
			handleInformation.iHandleId = index;
			handleInformation.iStartTime = iStartTime;

			iHandleInformationArray.Append( handleInformation );

			// Create new thread for this new handler
			// Thread name: "LogManager_" + handle id
			TBuf<KMaxFileName> threadName;
			_LIT( KThreadNameBase, "LogManager_" );
			threadName.Append( KThreadNameBase );
			threadName.AppendNum( index );

			// Create thread
			RThread thread;
			thread.Create( threadName,
					ThreadFunction,
					1024*10,
					0,
					&iHandleInformationArray[iHandleInformationArray.Count()-1] );
			thread.Resume();
		}
	}
	// Command: DEFINEVOLUME
	else if (textBuffer.Compare(KDefineVolume) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("DEFINEVOLUME\n"));
            }

		// Get QualifiedBaseAppClass
		ReadTextL(iReadStream, textBuffer, KDefineVolumeSeparator);
		HBufC* qualifiedBaseAppClass = HBufC::NewLC(textBuffer.Length());
		TUint textBufferLen = textBuffer.Length() - 1; // Remove separator at end
		qualifiedBaseAppClass->Des().Copy( textBuffer.Left( textBufferLen ) );
		qualifiedBaseAppClass->Des().Trim();

		// Get Index path
		ReadTextL(iReadStream, textBuffer, KLogPlayerFieldSeparatorEndLine);
		HBufC* indexDbPath = HBufC::NewLC(textBuffer.Length());
		indexDbPath->Des().Copy(textBuffer);

		if ( iHandle == -1 )
		{
			iSession.DefineVolume(*qualifiedBaseAppClass, *indexDbPath);
		}

		CleanupStack::PopAndDestroy(indexDbPath);
		CleanupStack::PopAndDestroy(qualifiedBaseAppClass);
	}
	// Command: RESET
	else if (textBuffer.Compare(KReset) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("RESET\n"));
            }

		TInt index = 0;
		ReadResetL(iReadStream, index);
		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->ResetL() );
		}
	}
	// Command: FLUSH
	else if (textBuffer.Compare(KFlush) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("FLUSH\n"));
            }

		TInt index = 0;
		ReadFlushL(iReadStream, index);
		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->FlushL() );
		}
	}
	// Command: ADD
	else if (textBuffer.Compare(KAdd) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("ADD\n"));
            }

		TInt index = 0;
		CSearchDocument* doc = ReadAddL(iReadStream, index);
		CleanupStack::PushL(doc);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->AddL(*doc) );
		}

		CleanupStack::PopAndDestroy(doc);
	}
	// Command: UPDATE
	else if (textBuffer.Compare(KUpdate) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("UPDATE\n"));
            }

		TInt index = 0;
		CSearchDocument* doc = ReadAddL(iReadStream, index);
		CleanupStack::PushL(doc);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->UpdateL(*doc) );
		}

		CleanupStack::PopAndDestroy(doc);
	}
	// Command: DELETE
	else if (textBuffer.Compare(KDelete) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("DELETE\n"));
            }

		TInt index = 0;
		HBufC* docUid = ReadDeleteL(iReadStream, index);
		CleanupStack::PushL(docUid);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iIndexer->DeleteL(*docUid) );
		}

		CleanupStack::PopAndDestroy(docUid);
	}
	// Command: SEARCH
	else if (textBuffer.Compare(KSearch) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("SEARCH\n"));
            }

		TInt index = 0;
		HBufC* searchQuery = ReadSearchL(iReadStream, index);
		CleanupStack::PushL(searchQuery);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iSearcher->SearchL(*this, *searchQuery) );
		}

		CleanupStack::PopAndDestroy(searchQuery);
	}
	// Command: GET
	else if (textBuffer.Compare(KGet) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("GET\n"));
            }

		TInt index = 0;
		TInt docIndex = ReadGetL(iReadStream, index);

		if ( index == iHandle )
		{
			TRAP_IGNORE( iSearcher->GetDocumentL(docIndex, *this) );
		}
	}
	// Command: CANCEL
	else if (textBuffer.Compare(KCancel) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("CANCEL\n"));
            }

		TInt index = 0;
		ReadCancelL(iReadStream, index);

		if ( index == iHandle )
		{
			iSearcher->Cancel();
		}
	}
	// Command: HOUSEKEEP
	else if (textBuffer.Compare(KHouseKeep) == 0)
	{
        if ( iConsole )
            {
            iConsole->Printf(_L("HOUSEKEEP\n"));
            }

		ReadHouseKeepingL(iReadStream);
		if ( iHandle == -1 )
		{
			iSession.ForceHouseKeeping();
		}
	}
	else
	{
		iWait->AsyncStop();
		return;
	}
	
	ReadTimeAndWait();
}
Ejemplo n.º 8
0
// ----------------------------------------------------------------------------------------
// CFMSServer::ReadFromFile() 
// ----------------------------------------------------------------------------------------
TBool CFMSServer::ReadFromFile(TInt& aReason, TInt& aBearer, TInt& aDrive, TInt& aSize
		, TInt& aWcdmaBearer )
	{
	TInt err = iFile.Open(iFs,KFotaInterruptFileName,EFileRead);
	FLOG(_L("CFMSServer::ReadFromFile() error as %d"),err);
	if(err == KErrNone)
		{
		TInt size = KErrNone;
		err = iFile.Size(size);	
		if(size == 0) //file empty
			{
			FLOG(_L("CFMSServer::ReadFromFile() file size is empty"));
			iFile.Close();
			return EFalse;		
			}
		TBuf8<30> data;
		iFile.Read(data);
		iFile.Close();	
		TBuf8<30> data1;    
		if(data.Length()>0)
			{
			TInt len =0 ;
			if((len=data.LocateF(',')) > 0)
				{
				TLex8 value( data.Left(len));            
				value.Val(aReason);
				FLOG(_L("CFMSServer::ReadFromFile() retrieving reason as %d"),aReason);
				data1.Insert(0,data.Right(data.Length()-(len+1)));
				data.Zero();
				//    len=data1.LocateF(',');
				if( data1.Length() > 0 && (len=data1.LocateF(',')) > 0)
					{
					value=data1.Left(len);            
					value.Val(aBearer);  
					FLOG(_L("CFMSServer::ReadFromFile() retrieving aBearer as %d"),aBearer);
					data.Insert(0,data1.Right(data1.Length()-(len+1)));            
					data1.Zero();
					//  len=data.LocateF(','); 
					if(data.Length() > 0 && (  len=data.LocateF(','))> 0)
						{
						value=data.Left(len);            
						value.Val(aDrive);
						FLOG(_L("CFMSServer::ReadFromFile() retrieving aDrive as %d"),aDrive);
						data1.Insert(0,data.Right(data.Length()-(len+1)));
						data.Zero();
						if(data1.Length() > 0 && (  len=data1.LocateF(','))> 0 )
							{
							value=data1.Left(len);
							value.Val(aSize);
							FLOG(_L("CFMSServer::ReadFromFile() retrieving aSize as %d"),aSize);
							data.Insert(0,data1.Right(data1.Length()-len-1));
							data1.Zero();
							if(data.Length() > 0 )
								{
								value=data;  
								value.Val(aWcdmaBearer);
								FLOG(_L("CFMSServer::ReadFromFile() retrieving aWcdmaBearer as %d"),aWcdmaBearer);
								}
							}
						} 
					}
				}    
			}
		}
	else
		{
		return EFalse;
		}
	return ETrue;
	}
/**
ConstructL()
Parses a .txt file and creates Arrays of fields and there values

@param aFileName
Name of the file to be parsed.
*/
EXPORT_C void CT_MsgUtilsConfigFileParserUtility::ConstructL(const TDesC& aFileName)
	{
	RFs fileServerSession;

	fileServerSession.Connect();

	RFile file;
	User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));

	TInt eof = EFalse;
	TInt fileOffset = 0;
	TBuf8<KFileBufferSize> fileBuffer;

	while (!eof)
		{
		fileBuffer.SetLength(0);
		User::LeaveIfError(file.Read(fileOffset, fileBuffer, KFileBufferSize));
		TInt read = fileBuffer.Length();

		if (read < KFileBufferSize)
			{
			fileBuffer.Append('\n');
			eof = ETrue;
			}

		TInt lineOverflow = fileBuffer.Locate('\n');
		
		if ((lineOverflow == KErrNotFound) && (read == KFileBufferSize))
			{
			User::Leave(KErrOverflow);
			}

		TInt eol = EFalse;
		
		while (!eol)
			{
			TInt lineFeedLocation = fileBuffer.Locate('\n');
			
			if (lineFeedLocation == KErrNotFound)
				{
				eol = ETrue;
				}
			
			else
				{
				fileOffset += lineFeedLocation + 1;
				TInt lineLength;
				if ((lineFeedLocation != 0) && (fileBuffer[lineFeedLocation - 1] == '\r'))
					{
					lineLength = lineFeedLocation - 1;
					}
					
				else
					{
					lineLength = lineFeedLocation;
					}
					
				TPtrC8 line  = fileBuffer.Left(lineLength);
				TInt commentLocation = line.Match(KComment);
				
				if (commentLocation != KErrNotFound)
					{
					TPtrC8 skipComment = line.Left(commentLocation);
					line.Set(skipComment);
					}
					
				TInt seperatorLocation = line.Locate('=');
				
				if (seperatorLocation != KErrNotFound)
					{
					if ((seperatorLocation == 0) || (seperatorLocation == line.Length() - 1))
						{
						seperatorLocation = KErrNotFound;
						}
					}
					
				if (seperatorLocation != KErrNotFound)
					{
					TPtrC8 namePtr = line.Left(seperatorLocation);
					HBufC8* nameBuf8 = HBufC8::NewL(namePtr.Length());
					CleanupStack::PushL(nameBuf8);
					
					TPtr8 name8 = nameBuf8->Des();
					name8.Copy(namePtr);
					name8.Trim();
					HBufC* nameBuf16 = HBufC::NewL(namePtr.Length());
					TPtr name16 = nameBuf16->Des();
					name16.Copy(name8);
					iName.Append(nameBuf16);
					CleanupStack::PopAndDestroy(nameBuf8);

					TPtrC8 contentPtr = line.Mid(seperatorLocation + 1);
					HBufC8* contentBuf8 = HBufC8::NewL(contentPtr.Length());
					CleanupStack::PushL(contentBuf8);
					TPtr8 content8 = contentBuf8->Des();
					content8.Copy(contentPtr);
					content8.Trim();
					
					HBufC* contentBuf16 = HBufC::NewL(contentPtr.Length());
					TPtr content16 = contentBuf16->Des();
					content16.Copy(content8);
					iContent.Append(contentBuf16);
					iContent8.Append(contentBuf8);
					CleanupStack::Pop(contentBuf8);
					}
				TPtrC8 theRest = fileBuffer.Mid(lineFeedLocation + 1);
				fileBuffer.Copy(theRest);
				}
			}
		}
	file.Close();
	fileServerSession.Close();
	}