void
CContentWindowContainer::DataReceived(const isab::DataGuiMess* aMess,
      const char *aUrl)
{
   list<class CResolveItem*>::iterator it = iReqList.begin();
   if (iBrCtlInterface) {
      class CResolveItem* item = NULL;
      while (it != iReqList.end()) {
         item = *it;
         HBufC* url = WFTextUtil::AllocLC(aUrl);
         if (!url->Find(item->getUrl())) {
            CleanupStack::PopAndDestroy(url);
            iReqList.erase(it);
            DataReceived(item->getLinkContent(), aMess, aUrl);
            delete item;
            return;
         }
         CleanupStack::PopAndDestroy(url);
         it++;
      }
   }
   class CResolveItem* item;
   while (it != iReqList.end()) {
      item = *it;
      it++;
      iReqList.pop_front();
      delete item; 
   }
}
/**
CheckIfFooterMessageExistsL()
Checks the email for the presence of the footer string

@param aRecvBodyText
Reference to a descriptor holding the body text

@param aFooterSize
The expected number of KB remaining on the server which has been inserted into the footer string

@return
ETrue if footer string found otherwise EFalse 
*/
TBool CT_MsgComparePopEmailMsgs::CheckIfFooterMessageExistsL(TPtrC& aRecvBodyText , TInt& aFooterSize)
	{
	RResourceFile resFile;
	CT_MsgUtils ::OpenResourceFileL(resFile, iFs, KImEngineResourceFile);	// NB leaves if file not found
	TCleanupItem close(CT_MsgUtils ::CloseResourceFile, &resFile);
	CleanupStack::PushL(close);
	
	HBufC8* buf = NULL;
	buf = resFile.AllocReadLC(PARTIAL_DOWNLOAD_FOOTER_MESSAGE);
	TResourceReader reader;
	reader.SetBuffer(buf);

	HBufC* resourceBuf = (reader.ReadTPtrC()).AllocL();
	CleanupStack::PushL(resourceBuf);

	TInt len = resourceBuf->Find(_L("%d"));
	const TInt KBufLen = 256;
	TBuf<KBufLen> findBuf;

	if(len == KErrNotFound)
		{
		len = resourceBuf->Length();
		}

	if(len > KBufLen)
		{
		len = KBufLen;
		}
	
	findBuf.Copy(resourceBuf->Ptr(), len);
	len = aRecvBodyText.Find(findBuf);

	if(len>=0)
		{
		TPtrC rest=aRecvBodyText.Right(aRecvBodyText.Length()-len-findBuf.Length());
		TLex lex(rest.Left(rest.Locate(TChar(' '))));
		lex.Val(aFooterSize);
		}
	else
		{
		aFooterSize=0;
		}

	CT_MsgUtils ::CloseResourceFile(&resFile);
	CleanupStack::PopAndDestroy(3); // buf, resourceBuf, close
	return (len != KErrNotFound);
	}
/**
 * This function sets up a console, a log file and checks
 * whether we need to wait for a key pressed after test 
 * completion.
 * First DoThreadedTestsL is called, if everything is ok
 * it return ETrue and we move on to the standard tests.
 * If something went amiss (return EFalse) we skip 
 * the standard test and return. 
 */
LOCAL_D void SetupAndRunTests() 
{

	CConsoleBase* console = Console::NewL(_L("Test code"), TSize(KConsFullScreen, KConsFullScreen));
	
	HBufC* logFile = GetArgument(1);
	
	if (logFile->Length()==0) 
		{
		_LIT(defaultLog, "\\tcertstore.log");
		TDriveUnit sysDrive (RFs::GetSystemDrive());
		TDriveName sysdriveName (sysDrive.Name());
		TBuf <18> fileName (sysdriveName);
		fileName.Append(defaultLog);
		logFile->ReAlloc(18);
		TPtr16 plog = logFile->Des();
		plog.Append(fileName);
		}
		
	HBufC* wait = GetArgument(2);

	TBool waitAfterCompletion = EFalse;
	if (wait->Find(_L("-w")) != KErrNotFound) 
		{
		waitAfterCompletion = ETrue;
		}
	
	TBool res = EFalse;	
	TRAPD(err, res = DoThreadedTestsL(console, logFile, waitAfterCompletion));
	
	if (res) 
		{
		// Now run a normal tcertstore test to check store integrity
		TRAP(err, DoTests());
		}
		
	delete console;
	delete wait;
	delete logFile;
}
/*
-------------------------------------------------------------------------------

    Class: CStifFileParser

    Method: NextSectionL

    Description: Finds n-th (aSeeked) section in file starting from m-th (aOffset) position

    Parameters: const TDesc& aStartTag: in:     Starting tag of a section
                const TDesc& aEndTag:   in:     Ending tag of a section
                TInt& aOffset:          in out: Current offset in file (*)
                TInt aSeeked:           in:     Which section is to be found
    
    Notification: aOffset has different meaning than before adding INCLUDE functionality.
                  If it has 0 value, that means that we need to remove files stack and go
                  back to base file to the beginning. Otherwise we don't change current
                  file read-handler position.

    Return Values: HBufC *: address of a descriptor containing section. Section is returned without tags.
                            Caller must take care about the freeing descriptor.

    Errors/Exceptions:  Leaves if aSeeked is less than 1 or aOffset is negative
    					Leaves if seek command leaves
    					Leaves if cannot allocate buffers
    					Leaves if cannot allocate section
    					Leaves if length of readed line exceeds KMaxLineLength constant

    Status: Proposal

-------------------------------------------------------------------------------
*/
HBufC* CStifFileParser::NextSectionL(const TDesC& aStartTag,
                                     const TDesC& aEndTag,
                                     TInt& aOffset,
                                     TInt aSeeked)
	{
	// Check arguments
	if(aSeeked < 1)
		{		
		User::Leave(KErrArgument);
		}
	if(aOffset < 0)
		{		
		User::Leave(KErrArgument);
		}

	TInt foundSection = 0;
	TInt ret;

	// Alloc buffers to read line
	const TInt KMaxLineLength = 4096; //If length of readed line exceeds this constant, method will leave

	HBufC* buf = HBufC::NewL(KMaxLineLength);
	CleanupStack::PushL(buf);
	TPtr bufPtr(buf->Des());

	HBufC* withoutCommentsBuf = HBufC::NewL(KMaxLineLength);
	CleanupStack::PushL(withoutCommentsBuf);
	TPtr withoutCommentsBufPtr(withoutCommentsBuf->Des());

	HBufC* endOfLine = HBufC::NewL(8);  //After reading a line it contains 0D0A or 0A or null (how readed line is ended)
	CleanupStack::PushL(endOfLine);
	TPtr endOfLinePtr(endOfLine->Des());

	//Set valid position in file
	//but only if offset shows to 0. Otherwise keep previus position
	if(aOffset == 0)
		{
		User::LeaveIfError(iBaseFile.Seek(ESeekStart, aOffset));
		ClearFileStack();
		aOffset = 1;
		}

	//Prepare to read lines
	TBool validSectionBeginFound = EFalse;
	TBool validSectionEndFound = EFalse;
	TSectionFind whatToFindSection = ESectionStart;
	//If no start tag is given start to find end tag immediatly
	if(aStartTag.Length() == 0)
		{
		foundSection++;
		whatToFindSection = ESectionEnd;
		validSectionBeginFound = ETrue;
		}
	if(aEndTag.Length() == 0)
		{
		validSectionEndFound = ETrue;
		}
	TWhatToFind whatToFind = EStart;

	//Perform reading file
	while(ReadLineL(bufPtr, endOfLinePtr))
		{
		if(iCommentType == CStifParser::ECStyleComments)
			{				
			ReplaceCommentsLineL(bufPtr, withoutCommentsBufPtr, whatToFind);
			}
		else
			{
			ReplaceHashCommentsLineL(bufPtr, withoutCommentsBufPtr);
			}
			if(whatToFindSection == ESectionStart)
			{
			//Find in line star tag (if start tag is not given, behave like we've found it)
			if(aStartTag.Length() == 0)
				{
				ret = 0;
				}
			else
				{
				ret = withoutCommentsBuf->Find(aStartTag);
				}
			//If found remember position, move offset of file to actual position
			if(ret >= 0)
				{
				whatToFindSection = ESectionEnd;
				TInt offset = -(bufPtr.Length() + endOfLinePtr.Length() - ret - aStartTag.Length()) * iBytesPerChar;
				User::LeaveIfError(iCurrentFile->Seek(ESeekCurrent, offset));

				whatToFind = EStart; //reset marker, because if we've found tag, we couldn't be in the middle of comment or quota
				foundSection++;
				//Add this line to section lines array
				if(foundSection == aSeeked)
					{
					validSectionBeginFound = ETrue;
					}
				continue;
				}
			}
		else if(whatToFindSection == ESectionEnd)
			{
			//Find in line end tag (if end tag is not given, behave like we've found it)
			if(aEndTag.Length() == 0)
				{
				ret = KErrNotFound;
				}
			else
				{
				ret = withoutCommentsBuf->Find(aEndTag);
				}
				//If found check if this is the one we're looking for
			if(ret >= 0)
				{
				whatToFindSection = ESectionStart;
				TInt offset = -(bufPtr.Length() + endOfLinePtr.Length() - ret - aEndTag.Length()) * iBytesPerChar;
				User::LeaveIfError(iCurrentFile->Seek(ESeekCurrent, offset));

				whatToFind = EStart; //reset marker, because if we've found tag, we couldn't be in the middle of comment or quota
				if(foundSection == aSeeked)
					{
					//Add this line to section lines array
					HBufC* line = HBufC::NewLC(bufPtr.Length());
					TPtr linePtr(line->Des());
					linePtr.Copy(bufPtr.MidTPtr(0, ret));
					User::LeaveIfError(iSectionLines.Append(line));
					CleanupStack::Pop(line);
					validSectionEndFound = ETrue;
					break;
					}
				else
					{
					continue;
					}
				}
			else
				{
				//If we're in section we are looking for, add line to array
				if(foundSection == aSeeked)
					{
					HBufC* line = HBufC::NewLC(bufPtr.Length() + endOfLinePtr.Length());
					TPtr linePtr(line->Des());
					linePtr.Copy(bufPtr);
					linePtr.Append(endOfLinePtr);
					User::LeaveIfError(iSectionLines.Append(line));
					CleanupStack::Pop(line);
					}
				}
			}
		}

	//Clean data
	CleanupStack::PopAndDestroy(endOfLine);
	CleanupStack::PopAndDestroy(withoutCommentsBuf);
	CleanupStack::PopAndDestroy(buf);
	
	//Load into section if found
	HBufC* section = NULL;

	if(validSectionBeginFound && validSectionEndFound)
		{
		//Count amount of memory needed for section
		TInt i;
		TInt size = 0;
		for(i = 0; i < iSectionLines.Count(); i++)
			size += iSectionLines[i]->Length();
		
		//Copy section from array to buffer
		section = HBufC::NewL(size);
		CleanupStack::PushL(section);
		TPtr sectionPtr(section->Des());

		for(i = 0; i < iSectionLines.Count(); i++)
			sectionPtr.Append(*iSectionLines[i]);

		ClearSectionLinesArray();
		
		//Clean local data
		CleanupStack::Pop(section);
		
		return section;
		}
	
	ClearSectionLinesArray();

	//If section was not found, then for compability with CSectionParser leave when not first section was seeking, return NULL when first section was seeking
	if(foundSection != aSeeked)
		{
		if( aSeeked - foundSection > 1)
			{			
			User::Leave(KErrNotFound);
			}
		}

    return section;
	}
// -----------------------------------------------------------------------------
// CSisxUIAppInfo::PrepareIteratorL
// Prepares the iterator to be shown in details dialog.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CSisxUIAppInfo::PrepareIteratorL( const Swi::CAppInfo& /*aInfo*/ )
    {
    FreeIterator();

    iKeys = new( ELeave )CDesCArrayFlat( 6 );
    iValues = new( ELeave )CDesCArrayFlat( 6 );

    // Name
    SetFieldL( R_SWCOMMON_DETAIL_NAME, Name() );

    // Version
    HBufC* stringBuf = CommonUI::CUIUtils::ConstructVersionStringLC( Version().iMajor,
                                                                     Version().iMinor,
                                                                     Version().iBuild );    
    TPtr ptr = stringBuf->Des();
    AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
    HBufC* tmpBuf = HBufC::NewLC( KLRE().Length() + stringBuf->Length() + KPDF().Length() ); 
    TInt position = stringBuf->Find( KLeftParenthes() );
    if ( position >= 0 )
        {
        tmpBuf->Des() = stringBuf->Mid( 0, position );
        tmpBuf->Des() += KLRE();
        tmpBuf->Des() += stringBuf->Mid( position, stringBuf->Length() - position );
        tmpBuf->Des() += KPDF();
        }
    else
        {
        tmpBuf->Des() = *stringBuf;	
        }   
    SetFieldL( R_SWCOMMON_DETAIL_VERSION, *tmpBuf );
    CleanupStack::PopAndDestroy( tmpBuf );
    CleanupStack::PopAndDestroy( stringBuf );

     // Supplier
    if ( IsTrusted() )
        {        
        SetFieldL( R_SWCOMMON_DETAIL_SUPPLIER, Vendor() );
        }
    else
        {
        tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_UNKNOWN_SUPPLIER );
        SetFieldL( R_SWCOMMON_DETAIL_SUPPLIER, *tmpBuf );
        CleanupStack::PopAndDestroy( tmpBuf );        
        }  

    // size
    tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_UNKNOWN_SIZE );
    SetFieldL( R_SWCOMMON_DETAIL_APPSIZE, *tmpBuf );  
    CleanupStack::PopAndDestroy( tmpBuf );

    // Technology
    tmpBuf = HBufC::NewLC( KLRE().Length() + KSymbian().Length() + KPDF().Length() );
    tmpBuf->Des() = KLRE(); 
    tmpBuf->Des() += KSymbian();
    tmpBuf->Des() += KPDF();
    SetFieldL( R_SWCOMMON_DETAIL_TECHNOLOGY, *tmpBuf ); 
    CleanupStack::PopAndDestroy( tmpBuf );  

    // Type
    tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_APPLICATION );    
    SetFieldL( R_SWCOMMON_DETAIL_TYPE, *tmpBuf );
    CleanupStack::PopAndDestroy( tmpBuf );    
    }
Example #6
0
void CCmdIniEdit::DoRunL()
	{
	TBool interactive = ETrue;
	if (iForce)
		{
		iReader = CIniReader::NewL(iIniFile);
		}
	else
		{
		iReader = CIniFile::NewL(iIniFile, iDescriptionFile);
		}
	TBool updated = EFalse;
		
	if (iSet)
		{
		TInt eqPos = iSet->Find(KEquals);
		TPtrC value(KNullDesC);
		TPtrC id(KNullDesC);
		if (eqPos == KErrNotFound)
			{
			id.Set(*iSet);
			
			Stdin().SetReadModeL(RIoReadHandle::ELine);
			iBuf.CreateL(0x100);
			Stdin().ReadL(iBuf);
			value.Set(iBuf);
			}
		else
			{
			id.Set(iSet->Left(eqPos));
			value.Set(iSet->Mid(eqPos+1));
			}
		
		iReader->SetValueL(Trim(id), value);
		updated = ETrue;
		interactive = EFalse;
		}
	if (iRemove)
		{
		iReader->RemoveValueL(*iRemove);
		updated = ETrue;
		interactive = EFalse;
		}
	
	if (iGet)
		{
		const TDesC* value = iReader->GetValue(*iGet);
		if (!value) LeaveIfErr(KErrNotFound, _L("id '%S' not found in %S"), iGet, &iIniFile);
		Write(*value);
		interactive = EFalse;
		}
	else if (iDump)
		{
		RPointerArray<CValue> values;
		CleanupClosePushL(values);
		iReader->GetValuesL(values);
		for (TInt i=0; i<values.Count(); ++i)
			{
			if (iForce)
				{
				Printf(_L("%S: %S\n"), &values[i]->Id(), &values[i]->Value());
				}
			else
				{
				CSetting* setting = (CSetting*)values[i];
				Printf(_L("%S: %S\n"), &setting->Name(), &setting->Value());
				}
			}
		CleanupStack::PopAndDestroy(&values);
		interactive = EFalse;
		}
	
	if (interactive)
		{
		// TODO enter interactive mode
		LeaveIfErr(KErrNotSupported, _L("Interactive mode not implemented yet."));
		}

	if (updated)
		{
		WriteIniFileL(iIniFile, *iReader);
		}
	}
// -----------------------------------------------------------------------------
// CAknKeyRotatorImpl::GetKeyRotatorCompensationL
// Parses wsini.ini to read key rotator compensation value.
// -----------------------------------------------------------------------------
//
TInt CAknKeyRotatorImpl::GetKeyRotatorCompensationL()
    {
    TInt result = 0;
    HBufC* wsiniText = GetWsiniLC();
    
    // Now look for keyword
    const TInt pos = wsiniText->Find( KAknKeyRotatorKey );
    if ( pos != KErrNotFound )
        {        
        // Keyword was found. Check that it is the beginning of line.
        // Three cases:
        // 1. Keyword could be at the beginning of the file.
        // 2. Keyword could be at the beginning of the file 
        //    after byte ordering marker.
        // 3. Previous character can be end of line marker.
        const TInt previousPos = pos - 1;
        if ( previousPos < 0 || 
             ( !previousPos && 
               IsByteOrderingMarker( (*wsiniText)[ previousPos ] ) ) || 
             IsEndOfLine( (*wsiniText)[ previousPos ] ) )
            {
            TLex text( wsiniText->Mid( pos + KAknKeyRotatorKey().Length() ) );
            
            // First, there must be at least a space after keyword.
            TBool fail = !( SkipSpaces( text ) & EAknWasSpace );
           
            // Case 1: Disabled
            TBool wasDisabled = EFalse;
            if ( !fail )
                {
                wasDisabled = 
                    !text.Remainder().Left( KAknKeyRotatorDisabled().Length() ).
                    CompareF( KAknKeyRotatorDisabled );

                if ( wasDisabled )
                    {
                    // wasDisabled == True, KAknKeyRotatorDisabled was prefix
                    // of text. So skip over it
                    text.Inc( KAknKeyRotatorDisabled().Length() );
                    }
                }
            
            // Case 2: Then follows a sequence of digits, optionally preceded by '-'.
            if ( !wasDisabled && !fail )
                {
                // Check optional -
                TBool negate = EFalse;
                if ( !text.Eos() && text.Peek() == '-' )
                    {
                    negate = ETrue;
                    text.Inc();
                    }
                    
                // Get digit sequence and convert to integer value.
                TPtrC token = GetDigits( text );
                fail = !token.Length() || 
                       ( TLex( token ).Val( result ) != KErrNone );
                
                // Handle negation
                if ( !fail && negate )
                    {
                    result = -result;
                    }
                }

            // That sequence of digits is followed by sequence of spaces until
            // end of line or end of file.
            fail = fail || ( SkipSpaces( text ) & EAknWasCharacter );
            
            if ( !wasDisabled )
                {
                // Finally, that sequence of digits must represent
                // one valid decimal value of the following: 
                // -270, -180, -90, 0, 90, 180, 270.
                fail = fail || !CheckCompensationValue( result );
                }
                
            // If any of above checks failed, use default value 0.
            if ( fail )
                {
                result = 0;
                }
            else
                {
                if ( wasDisabled )
                    {
                    result = KMaxTInt;
                    }
                }
            }
        }
        
    CleanupStack::PopAndDestroy( wsiniText );   
    return result;
    }