Example #1
0
void CRichText::OverrideFormatForParsersIfApplicable(TPtrC& aText, TCharFormatX& aFormat, TInt aStartPos) const
	{
	if (aFormat.iParserTag && iParserData->iActiveParserList && iParserData->iEditObserver)
		{
		// Replace format
		TInt start = -1;
		TInt length = 0;
		TInt curPos = iParserData->iLastKnownCursor;
		if (curPos > DocumentLength())
			curPos = DocumentLength();  // This shouldn't be neccesary but it makes it more
										// bulletproof if the calls from outside are made in
										// the wrong order
		if (curPos != -1)
			{
			TCharFormatX format;
			TCharFormatXMask varies;
			MParser* parser;

			GetExtendedCharFormat(format, varies, curPos, 1);
			// If char at curpos has a tag then cursor is over that tag, get extents of tag
			if (CParserList::ReformatOnRollover(format.iParserTag))
				DoCursorOverTag(curPos, parser, start, length);
			else if (curPos)
				{
				GetExtendedCharFormat(format, varies, curPos - 1, 1);
				// Try the char "before" curpos
				if (CParserList::ReformatOnRollover(format.iParserTag))
					DoCursorOverTag(curPos - 1, parser, start, length);
				}
			}

		MParser* parser = iParserData->iActiveParserList->ParserWithThisTag(aFormat.iParserTag);
		
		if (length && (aStartPos >= start) && (aStartPos < start + length))
			{
			if (start + length < aStartPos + aText.Length())
				aText.Set(aText.Left(start + length - aStartPos));
			if (parser != NULL)
				{
				// Only accept the rollover format if the parser agrees 
				// with the framework match of a tag
				if (parser->ConfirmCursorOverTag(*this, start, length, curPos))
					parser->GetRolloverFormat(aFormat.iCharFormat);
				else 
					// Reset format to recognised format if parser disagrees
					// with the framework match as the tag is still in view
					// and must be formatted as in the else clause below.
					parser->GetRecogniseFormat(aFormat.iCharFormat);
				}
			}
		else
			{
			if (length && (start > aStartPos))
				aText.Set(aText.Left(start - aStartPos));
			if (parser != NULL)
				parser->GetRecogniseFormat(aFormat.iCharFormat);
			}
		}
	}
/**
used by concurrent tests to write shared text to aShare either appedning or overwriteing
*/
void CPerformanceFunctionalityBase::SetSharedTextL(const TDesC &aShare, const TDesC &aText, const TBool aAppend)
	{

	TPtrC txtWriteData;
	txtWriteData.Set(aText); // Copy the literal to a text buffer
	WriteSharedDataL(aShare, txtWriteData, (aAppend ? EAppendText : ESetText) ); // Data copied to shared location

	}
TInt CSoundManager::PlayFile()
{
    TPtrC file = iData->GetSelectFile();
    if (file.Compare(KNullDesC)== 0)
        return KErrNotFound;
    else
        return LoadFile(file);
}
void CNSmlDummyDataProvider_Test::DoListStoresLCL()
    {
    CDesCArray* store = iCNSmlDummyDataProvider->DoListStoresLC();
    TPtrC ptrStoreName = ( *store )[ 0 ];
    EUNIT_PRINT( ptrStoreName );
    EUNIT_ASSERT( ptrStoreName.Compare( KDefaultDBName ) == 0 );
    CleanupStack::PopAndDestroy( store );
    }
TPtrC CSystemStartupStateInfo::Name() const
	{
	TPtrC retval;
	if (iName)
		{
		retval.Set(*iName);
		}
	return retval;
	}
// ----------------------------------------------------
// CUniAddressHandler::AddRecipientL
//
// Performs address(es) fetch operation.
// ----------------------------------------------------
//
EXPORT_C TBool CUniAddressHandler::AddRecipientL( TBool& aInvalid )
    {
    TBool addressesAdded( EFalse );
    aInvalid = EFalse;
    
    CMsgRecipientList* recipientList = CMsgRecipientList::NewL();
    CleanupStack::PushL( recipientList );

    CMsgRecipientArray* recipients = new ( ELeave ) CMsgRecipientArray( 10 );
    CleanupStack::PushL( TCleanupItem( CleanupRecipientArray, recipients ) );
    
    // Multiple entry fetch to get the contact    
    if ( !iCheckNames )
        {
        iCheckNames = CMsgCheckNames::NewL();
        }
        
    iCheckNames->FetchRecipientsL( *recipients, iValidAddressType );
    
    // Contacts now fetched, verify that valid address is given for every contact
    while ( recipients->Count() > 0 )
        {
        CMsgRecipientItem* recipient = recipients->At( 0 );
        
        TPtrC namePtr = recipient->Name()->Des();
        TPtrC addressPtr = recipient->Address()->Des();

        // Don't parse away chars here so this is consistent with 
        // addresses that user writes "-()" are saved to draft
        // but removed when sending
        if ( CheckSingleAddressL( addressPtr ) )
            {
            //  add it to the list of valid addresses
            recipient->SetValidated( ETrue );
            recipient->SetVerified( ( namePtr.Length() > 0 ? ETrue : EFalse ) );
            recipientList->AppendL( recipient );
            }
        else
            {
            aInvalid = ETrue;
            ShowAddressInfoNoteL( addressPtr, namePtr );
            delete recipient;
            }
        
        recipients->Delete( 0 );
        }
    
    if ( recipientList->Count() > 0 )
        {
        iControl.AddRecipientsL( *recipientList );
        addressesAdded = ETrue;
        }
 
    CleanupStack::PopAndDestroy( 2, recipientList );//recipients
    
    return addressesAdded;
    }
void CSimpleAppUi::DialogWithAnimationL(TInt aResourceId)
	{
    TPtrC ptr;
	ptr.Set(KTBmpAnimMBMFilePath/*Application()->BitmapStoreName()*/);
	
	
	CEikDialog* dialog = new (ELeave) CAnimationDlg(ptr);
	dialog->ExecuteLD(aResourceId);
	}
/*
	Tests whether Publishing a Service/Device is performing as specified in UPnP specifications.
	@param			aOperationType is reference to a section name in ini file where required parameters
					needs to be referred for this operation.
	@return			None.
 */
void CTestRControlChannel::PublishServiceL (const TDesC& aOperationType)
	{
	_LIT(KInfoLogFile, "CTestRControlChannel::PublishServiceL ().... \n");
	INFO_PRINTF1(KInfoLogFile);
	CRControlChannelObserver* upnpObserver = CRControlChannelObserver::NewL(this);
	CleanupStack::PushL( upnpObserver );
	iObserverArray.Append(upnpObserver);

	RPnPParameterBundle pnpBundle ;
	pnpBundle.Open();
    CleanupClosePushL( pnpBundle );
    pnpBundle.SetPnPObserver((MPnPObserver*)upnpObserver);
    RParameterFamily family = pnpBundle.CreateFamilyL(EUPnPServiceRegisterParamSet);
   	CUPnPServiceRegisterParamSet* registerServiceParamSet = CUPnPServiceRegisterParamSet::NewL(family );

   	_LIT(KParentDeviceUid, "ParentDeviceUid");
   	TPtrC parentDeviceUid;
	GetStringFromConfig(aOperationType, KParentDeviceUid, parentDeviceUid);

	RBuf8 parentDeviceUidBuf;
	parentDeviceUidBuf.Create(parentDeviceUid.Length());
	parentDeviceUidBuf.Copy(parentDeviceUid);
	registerServiceParamSet->SetDeviceUidL (parentDeviceUidBuf);


	TPtrC serviceType;
	GetStringFromConfig(aOperationType, KServiceType, serviceType);
	RBuf8 serviceTypeBuf;
	serviceTypeBuf.Create(serviceType.Length());
	serviceTypeBuf.Copy(serviceType);
	registerServiceParamSet->SetUriL ( serviceTypeBuf );


	TInt duration;
	GetIntFromConfig(aOperationType, KCacheControl, duration);
	registerServiceParamSet->SetCacheControlData (duration);

	ExtractServiceDescriptionL (aOperationType, *registerServiceParamSet);

	_LIT8(KInitialMessage, "Initial notification message");
	registerServiceParamSet->SetInitialMessageL(KInitialMessage);
	
	OpenPublisherL();

	iPublisher.Publish( pnpBundle );
	CActiveScheduler::Start();

	serviceTypeBuf.Close();
	parentDeviceUidBuf.Close();
	CleanupStack::PopAndDestroy( &pnpBundle );
	CleanupStack::Pop( upnpObserver );
	
	InitiateControlL();
	_LIT(KInfoLogFile1, "CTestRControlChannel::PublishServiceL () Stop.... \n");
	INFO_PRINTF1(KInfoLogFile1);
	
	}
 void GetChars(TPtrC& aView,TCharFormat& aFormat, TInt aStartPos)const
 {
     TCharFormat cf;
     aFormat = cf;
     if (aStartPos == LdDocumentLength())
         aView.Set(KEnd);
     else
         aView.Set(iDes->Mid(aStartPos));
 }
TInt CCmdShowTransaction::ProcessL(const TDesC& aCommand)
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	
	TPtrC param;
	TInt error = KErrNone;
	TRAP(error, param.Set( ParamsL(aCommand)));
	if (error != KErrNone)
		return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());
	
	CObjCatalogue *trnsctns = Machine()->Domains();
	TInt iTrans = 0;

	Log(_L("\tCurrent Transactions:"));
	Log(_L("\tName  \tMethod  \tURI"));
	for (TInt i = 0; i < trnsctns->Count(); ++i)
		{
		CAnyObject *obj = (CAnyObject *)trnsctns->At(i);
		if (obj->Tag() == THA_KHTTP_Transaction)
			{
			TPtrC label = obj->Name();
			TInt eStrIndex = obj->Index();
			CTestTransaction *trans = (CTestTransaction *)obj->Ptr();
			TBuf<256> uri;
			uri.Copy (trans->Uri()) ;
									
			TPtrC mthd;
						
			switch (eStrIndex)
				{
				case HTTP::EGET : mthd.Set(THA_TxtCmdTransactionGET); break;
				case HTTP::EPOST : mthd.Set(THA_TxtCmdTransactionPOST); break;
				case HTTP::EPUT : mthd.Set(THA_TxtCmdTransactionPUT); break;
				case HTTP::EDELETE : mthd.Set(THA_TxtCmdTransactionDELETE); break;
				case HTTP::EHEAD : mthd.Set(THA_TxtCmdTransactionHEAD); break;
				case HTTP::EOPTIONS : mthd.Set(THA_TxtCmdTransactionOPTIONS); break;
				case HTTP::ETRACE : mthd.Set(THA_TxtCmdTransactionTRACE); break;
				default : break;
				}
			++iTrans;
//			if (trans->iState == CTestTransaction::EActive)
			if (trans->State() == CTestTransaction::EActive)
				{
				Log(_L("\t%d\t%S\t%S\t%S"), iTrans, 
					&label, 
					&mthd,
					&uri);
				}
			}
		}
	if (iTrans == 0)
		Log(_L("\tNo transactions have been defined"));
		
	return KErrNone;
	
	}
void CMemSpyEngineActiveObject::ConstructL( CMemSpyEngine& /*aEngine*/ )
    {
    TBuf<256> item;

    _LIT(KBasicFormat, "\t0x%08x\t\t");
    item.Format( KBasicFormat, VTable() );

    // Add modifiers
    _LIT( KModifiers, "%d" );
    _LIT( KBoxedCharFormat, " [%c]" );
    item.AppendFormat( KModifiers, RequestStatusValue() );
    if  ( IsActive() )
        {
        item.AppendFormat( KBoxedCharFormat, 'A' );
        }
    if  ( RequestIsPending() )
        {
        item.AppendFormat( KBoxedCharFormat, 'P' );
        }
    iCaption = item.AllocL();

    // Listbox items
    TPtrC value;

    // Address
    _LIT(KCaption1, "\tAddress\t\t0x%08x");
    item.Format( KCaption1, iAddress );
    AppendL( item );

    // vTable
    _LIT(KCaption2, "\tVTable\t\t0x%08x");
    item.Format( KCaption2, iVTable );
    AppendL( item );

    //
    _LIT(KCaption3, "\tStatus Value\t\t%d");
    item.Format( KCaption3, iRequestStatusValue );
    AppendL( item );

    //
    _LIT(KCaption5, "\tIs Active\t\t%S");
    value.Set( YesNoValue( IsActive() ) );
    item.Format( KCaption5, &value );
    AppendL( item );

    //
    _LIT(KCaption6, "\tRequest Pending\t\t%S");
    value.Set( YesNoValue( RequestIsPending() ) );
    item.Format( KCaption6, &value );
    AppendL( item );

    //
    _LIT(KCaption4, "\tPriority\t\t%d");
    item.Format( KCaption4, iPriority );
    AppendL( item );
    }
Example #12
0
void CHttpTypes::ReadHttpTypesFileL(const TDesC& aFileName)
{
	RFs fs;

#if EPOC_SDK >= 0x06000000
	User::LeaveIfError(fs.Connect());
	iHttpTypesArray = new (ELeave) CDesCArrayFlat(HTTP_TYPES_ARRAY_GRANURALITY);

	HBufC *config = NULL;
	// Need to TRAP leaves, because must close the fs (right).
	// Thus, no point in using the CleanupStack for config either.
	//
	TRAPD(err, config = UnicodeLoad::LoadL(fs, aFileName));
	if (err == KErrNone && config != NULL)
		{
		TLineBuffer buffer(config->Des());
		while (!buffer.EOB())
			{
			TPtrC line = buffer.ReadLine();
			if (line.Length() > 0)
				{
				TRAP(err, ParseTypeLineL(line));
				if (err != KErrNone)
					break;
				}
			}
		}
	delete config;
	User::LeaveIfError(err);

#else
	RFile cfg;
	TFileText cfgtxt;
	TBuf<256> buffer;

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(cfg.Open(fs,aFileName,EFileStreamText));

	iHttpTypesArray = new (ELeave) CDesCArrayFlat(HTTP_TYPES_ARRAY_GRANURALITY);
	
	cfgtxt.Set(cfg);
	User::LeaveIfError(cfgtxt.Seek(ESeekStart));
	
	cfgtxt.Read(buffer);
	while (buffer.Length() > 0)
	{
		ParseTypeLineL(buffer);
		cfgtxt.Read(buffer);
	}
	
	cfg.Close();
#endif
	iHttpTypesArray->Sort();

	fs.Close();
}
Example #13
0
LOCAL_C void testTPtrLocateReverse()
//
// Test locating in reverse on an empty TPtr
//
	{

	TPtrC a;
	test(a.LocateReverse('0')==KErrNotFound);
	test(a.LocateReverseF('0')==KErrNotFound);
	}
Example #14
0
//Add aItem to DSC at aPos
void CDscDatabase::AddItemL(CDscItem& aItem, TDscPosition aPos)
	{
	//Leave if DB is opened for enumeration
	if (iIsEnumOpened)
		{
		User::Leave(KErrLocked);
		}
	
	//verify data integrity,
	LeaveIfFileParamsNotValidL(aItem);
	if(aItem.ItemId() != 0)
		{
		User::Leave(KErrArgument);
		}

	//Start transaction
	DatabaseBeginLC();

	//Leave if aDscId doesn't exist
	if (!DscExistsL(aItem.DscId()))
		{
		User::Leave(KErrNotFound);
		}

	//Leave if aItem exists
	if (ItemExistsL(aItem))
		{
		User::Leave(KErrAlreadyExists);
		}

	const TPtrC filename = aItem.FileName();
	const TPtrC argList = aItem.Args();	//whitespace already trimmed
	const TInt itemId = GetNextItemIdL(aPos, aItem.DscId());
	
	RBuf sqlCmd;
	CleanupClosePushL(sqlCmd);
	sqlCmd.CreateL(KSqlInsertDscItemLength + filename.Length() + argList.Length());
	
	//insert the item
	sqlCmd.Format(KSqlInsertDscItem, &KItemTable, &KDscIdCol, &KItemIdCol, &KFileNameCol, &KArgListCol,
				&KStartMethodCol, &KTimeoutCol, &KNoOfRetriesCol, &KMonitorCol, &KStartupTypeCol,
				&KViewlessCol, &KStartInBackgroundCol, aItem.DscId(), itemId, &filename, &argList, aItem.StartMethod(),
				aItem.Timeout(), aItem.NoOfRetries(), aItem.Monitored(),
				aItem.StartupType(), aItem.Viewless(), aItem.StartInBackground());

	DebugPrint(sqlCmd);
	
	User::LeaveIfError(iDatabase.Execute(sqlCmd));
	CleanupStack::PopAndDestroy(&sqlCmd);
	DatabaseCommitL(); //CommitL + CleanupStack::Pop()
	
	//Now aItem is persistent, set the ItemId so it can be read by the client
	aItem.SetItemId(itemId);
	}
Example #15
0
TBool CCmdRemark::Recognize( const TDesC& aCommand  )
{
// Obey the command family's step over mode.
SetStepOver(Family()->StepOver());

// Check if is empty or begins with # character.
TPtrC cmd = TfrLex::Trim(aCommand);

//	look for empty, # or //
return ((cmd.Length() == 0) || (cmd.Match( _L("#*")) == 0) || (cmd.Match(_L("//*")) == 0 ));
}
inline TBool IsAdaptiveFindMatchClassic( const TDesC& aItemString, const TDesC& aSearchText )
    {
    TPtrC itemptr = aItemString;
    TPtrC searchptr = aSearchText;

    TBool match = EFalse;
    
    for(;;) 
        {
        // Loop invariant: itemptr is next character from ' ' or '-'
        // Loop invariant: seachptr is at beginning of searched item
    
        TInt val = MyFindC(itemptr,searchptr);
        if (val == 0)
            {
            match = ETrue;
            break;
            }
        if (val != KErrNotFound && IsFindWordSeparator(itemptr[val-1]))
            {
            match = ETrue;
            break;
            }

        // find the word separator characters from list item
        TInt spacepos = itemptr.LocateF(TChar(' '));
        TInt minuspos = itemptr.LocateF(TChar('-'));
        TInt tabpos = itemptr.LocateF(TChar('\t'));
        if (spacepos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(spacepos+1));
            }
        else if (minuspos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(minuspos+1));
            }
        else if (tabpos != KErrNotFound)
            {
            itemptr.Set(itemptr.Mid(tabpos+1));
            }
        else
            {
            match = EFalse;
            break;
            }
        if (itemptr.Length() == 0)
            {
            match = EFalse;
            break;
            }

        }
    return match;
    }	
TInt COpenRSubConnectionStep::ConfigureFromIni()
	{
	iParams.Reset();
	
	// Read in appropriate fields
	if((GetStringFromConfig(iSection, KTe_SubConnectionName, iParams.iSubConnectionName) != 1)
		|| (iParams.iSubConnectionName.Length() == 0))
		{
		INFO_PRINTF1(_L("Couldn't find appropriate field in config file"));
		return KErrNotFound;
		}
		
    if (GetStringFromConfig(iSection,KTe_SocketServName,iParams.iSockServName)!=1)
        {
        INFO_PRINTF2(_L("%S: Socket server name missing."),&iParams.iSubConnectionName);
        return KErrNotFound;
        }

    if (GetStringFromConfig(iSection,KTe_ConnectionName,iParams.iConnectionName)!=1)
        {
        INFO_PRINTF2(_L("%S: Connection name missing."),&iParams.iSubConnectionName);
        return KErrNotFound;
        }

	TPtrC subConnTypeName;
    if (GetStringFromConfig(iSection,KTe_SubConnectionTypeName,subConnTypeName)!=1)
        {
        INFO_PRINTF2(_L("%S: SubConnection type missing."),&iParams.iSubConnectionName);
        return KErrNotFound;
        }

    if (subConnTypeName.Compare(KTe_SubConnectionTypeAttach)==0)
	    { iParams.iSubConnType = RSubConnection::EAttachToDefault; }
    else if (subConnTypeName.Compare(KTe_SubConnectionTypeNew)==0)
	    { iParams.iSubConnType = RSubConnection::ECreateNew; }
    else
       {
       INFO_PRINTF3(_L("%S: SubConnection type (%S) not recognised."),&iParams.iSubConnectionName,&subConnTypeName);
       return KErrNotFound;
       }

	if (!GetIntFromConfig(iSection, KExpectedError, iExpectedError))  
       {
       	iExpectedError = KErrNone;
       }

       else
       {
       	INFO_PRINTF2(_L("Error to be expected: %d"),iExpectedError);
       }

    // All ok if we got this far
    return KErrNone;
	}
TInt CCmdConnect::ProcessL( const TDesC& aCommand )
{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();

	TPtrC framework;
	TPtrC conname;

	TInt error;
	if (( error = ParseCmdArgs( aCommand, framework, conname )) != KErrNone)
		return error;
	
	if (conname.Size() != 0)
		{		
		//	Check if the connection already is defined. 
		//	If it is return error, if not create a session and ptr!
		CAnyObject *cnx = (CAnyObject *)Machine()->Domains()->Name(conname);
	
		if (cnx != NULL)		//	already exists
			return Error(KErrAlreadyExists, THA_KErrCnxionExists, &conname);
		else
			{
			CFrmwrkSession *cithc = CFrmwrkSession::NewLC(conname, framework, Machine());
			cithc->iEventDispatcher = iEventDispatcher ;

			TRAPD(error, cithc->OpenL());
			if (error == KErrNone)
				{
				cithc->SetPropertiesL();
			
				TRAP(error, cithc->ConnectL());
				
				if (error == KErrNone)
					{
					//	now create reference to name in domains
					//	note: the value is 1 for HTTP and 0 for WSP
					Machine()->Domains()->AddL(conname, 0, THA_KHTTP_Connect, (TAny *) cithc);
					WriteDateStamp();
					Log(_L("Connection '%S' has been opened!"), &conname);
					}
				else
					Error(error, KTxtErrConnectFailed);
				}
			
			CleanupStack::Pop();	// cithc
			}
		}
	else
		{		
		(void) ShowSessions () ;
		}

	return error;
}
Example #19
0
TPtrC TfrLex::Peel( const TDesC& aText )
{
TPtrC result;
TInt  length = aText.Length();
if ( length >= 2 && (aText[0] == '"' && aText[length-1] == '"') )
	result.Set( aText.Mid(1,length-2) );
else
	result.Set( aText );

return result;
}
Example #20
0
// ---------------------------------------------------------
// CPosTp52::CheckLongCategoryNameL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp52::CheckLongCategoryNameL(TInt aNumExpectedCategories )
{
    iLog->Log(_L("CheckLongCategoryNameL"));
    // Should only exist one landmark in db
    CPosLandmark* lm = iDatabase->ReadLandmarkLC(1);

    RArray<TPosLmItemId> array;
    CleanupClosePushL(array);
    lm->GetCategoriesL(array);
    TInt nr = array.Count();
    TPtrC name;

    _LIT(KLONGNAME1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234");
    _LIT(KLONGNAME2, "Pizzeria10Pizzeria20Pizzeria30Pizzeria40Pizzeria50Pizzeria60Pizzeria70Pizzeria80Pizzeria90Pizzeria10Pizzeria10Pizzeria20Pizz");
    _LIT(KLONGNAME3, "Gizzeria10Gizzeria20Gizzeria30Gizzeria40Gizzeria50Gizzeria60Gizzeria70Gizzeria80Gizzeria90Gizzeria10Gizzeria10Gizzeria20_ABC");
    _LIT(KLONGNAME4, "Dizzeria10Dizzeria20Dizzeria30Dizzeria40Dizzeria50Dizzeria60Dizzeria70Dizzeria80Dizzeria90Dizzeria10Dizzeria10Dizzeria20_ABC");

    const TInt numNames = 4;
    const TPtrC names[] = { KLONGNAME1(), KLONGNAME2(), KLONGNAME3(), KLONGNAME4() };

    if (nr != aNumExpectedCategories) //LogErrorAndLeave(_L("Wrong number of categories for landmark"));
    {
        iLog->Log(_L("Wrong number of categories for landmark"));
        User::Leave(-1);
    }

    CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase);
    CleanupStack::PushL(categoryManager);

    for ( TInt i = 0; i < aNumExpectedCategories; i++ )
    {
        CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(array[i]);

        cat->GetCategoryName(name);
        // Maximum size for category name is 124 characters
        if (name.Length() != 124)
        {
            iLog->Log(_L("Category name has wrong size, should be 124"));
            User::Leave(-1);

        }
        if (name.Compare(names[i]) != 0)
        {
            iLog->Log(_L("Long category name does not match"));
            iErrorsFound++;
        }
        CleanupStack::PopAndDestroy(cat);
    }

    CleanupStack::PopAndDestroy(categoryManager);

    CleanupStack::PopAndDestroy(&array);
    CleanupStack::PopAndDestroy(lm);
}
TInt CConfigParams::FindNumVar(const TDesC &aVarName, const TInt aDefault)
	{
	TInt result;
	TPtrC ptr = FindAlphaVar(aVarName,KNullDesC);
	if(ptr.Length())
		{
		TLex lex(ptr);
		if (lex.Val(result)==KErrNone)
			return result;
		}
	return aDefault;
	}
Example #22
0
void CWebServerEnv::ReadConfigFileL(const TDesC& aConfigFileName)
//Function which reads and parse the confing file
{

	RFs fs;
#if EPOC_SDK >= 0x06000000
	User::LeaveIfError(fs.Connect());
	HBufC *config = NULL;
	// Need to TRAP leaves, because must close the fs (right).
	// Thus, no point in using the CleanupStack for config either.
	//
	TRAPD(err, config = UnicodeLoad::LoadL(fs, aConfigFileName));
	if (err == KErrNone && config != NULL)
		{
		TLineBuffer buffer(config->Des());
		while (!buffer.EOB())
			{
			TPtrC line = buffer.ReadLine();
			if (line.Length() > 0)
				{
				TRAP(err, ParseConfigLineL(fs, line));
				if (err != KErrNone)
					break;
				}
			}
		}
	delete config;
	fs.Close();
	User::LeaveIfError(err);
#else
	RFile cfg;
	TFileText cfgtxt;
	TBuf<256> buffer;

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(cfg.Open(fs,aConfigFileName,EFileStreamText));
	
	cfgtxt.Set(cfg);
	User::LeaveIfError(cfgtxt.Seek(ESeekStart));
	cfgtxt.Read(buffer);
	while (buffer.Length() > 0)
	{
		ParseConfigLineL(fs,buffer);
		cfgtxt.Read(buffer);
	}
	
	cfg.Close();

	fs.Close();
#endif
	CheckAndSetDefaultL();

}
// ----------------------------------------------------------
// CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL
// Shows the notifier in backround 
// ----------------------------------------------------------
//
void CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL()
	{
	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete()"));
	
	//get full path to the DCMO resource file
	TParse* parser = new (ELeave) TParse;
	parser->Set(KDcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL);
	CleanupStack::PushL(parser);
	TFileName* fileName = new (ELeave) TFileName;
	*fileName = parser->FullName();
	CleanupStack::PopAndDestroy(parser);
	CleanupStack::PushL(fileName);
	
	//create the resource reader object that we need to use several times
	CTulStringResourceReader* reader = CTulStringResourceReader::NewL(*fileName);
	CleanupStack::PushL(reader);
	
	//get pointer to the message part of the notifier
	TPtrC resourceString;
	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE));

	//create descriptor with a max length to fit the localised "disabled" text + new line + "Bluetooth"
	RBuf content;
	content.CreateL(resourceString.Length() + KNewLine().Length() + KDefaultBluetoothStringLength);
	CleanupClosePushL(content);
	
	//add resource string and new line character to the content descriptor
	content.Append(resourceString);	
	content.Append(KNewLine());
	
	//get pointer to the Bluetooth name part of the notifier (can't assume this is actually "Bluetooth" in all languages)
	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH));
	
	//check that the resource string will fit into the content descriptor
	TInt requiredLength = content.Length() + resourceString.Length();
	if (requiredLength > content.MaxLength())
		{
		//allocate more space in the content descriptor
		content.ReAllocL(requiredLength);
		}
	
	//add resource string to the content descriptor
	content.Append(resourceString);	
	
	//display the notifier and complete
	iNotifUiUtil->ShowInfoNoteL(content, ECmdBTnotifUnavailable);
	CompleteMessage(KErrNone);
	
	//pop and destroy the content descriptor, resource reader and file name
	CleanupStack::PopAndDestroy(3, fileName);
	
	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete() complete"));
	}
/*!
    Retrieves date format from Symbian locale and
    transforms it to Qt format.

    When \a short_format is true the method returns
    short date format. Otherwise it returns the long format.
*/
static QString symbianDateFormat(bool short_format)
{
    TPtrC dateFormat;

    if (short_format) {
        dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale));
    } else {
        dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale));
    }

    return s60ToQtFormat(qt_TDesC2QString(dateFormat));
}
EXPORT_C HBufC* CResourceLoader::LoadLC( TInt aResourceId )
    {
    TResourceReader reader;
    HBufC8* readBuffer = CreateResourceReaderLC( reader, aResourceId );
    TPtrC textdata = reader.ReadTPtrC();
    
    HBufC16* textBuffer = HBufC16::NewL( textdata.Length() );
    *textBuffer = textdata;
    CleanupStack::PopAndDestroy( readBuffer );
    CleanupStack::PushL( textBuffer );
    return textBuffer;
    }
Example #26
0
EXPORT_C HBufC* CTIniData::ReadStrL(const TPtrC& aIniParam, const TDesC& aConfigFile)
	{
	CIniData * iniData = CIniData::NewL(aConfigFile);
	CleanupStack::PushL(iniData);
	
	TPtrC value;
	User::LeaveIfError(iniData->FindVar(KDefaultSectionName, aIniParam, value));
	HBufC* ret = value.Alloc();

	CleanupStack::PopAndDestroy(iniData);
	return ret;
	}
LOCAL_C void TestUpdateContactL()
{
    test.Next(_L("TestUpdateContactL"));

    SETUP;

    CContactItem* contact = CContactItem::NewLC(KUidContactCard);

    TContactItemId id = cntClient.CreateContactL(*contact);
    CleanupStack::PopAndDestroy(contact);

    // View definition to read image field
    CContactItemViewDef* imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields);
    imageViewDef->AddL(KUidContactFieldMatchAll);

    contact = cntClient.OpenContactLX(imageViewDef ,id);
    CleanupStack::PushL(contact);

    CContactItemField* newField = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldCodImage);
    newField->SetMapping(KUidContactFieldVCardMapUnknown);
    newField->TextStorage()->SetTextL(KSrcImage());
    contact->AddFieldL(*newField); // Takes ownership
    CleanupStack::Pop(newField);

    cntClient.CommitContactL(*contact, EFalse);
    CleanupStack::PopAndDestroy(2);  //  contact, imageViewDef

    // View definition to read image field
    imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields);
    imageViewDef->AddL(KUidContactFieldCodImage);

    contact = cntClient.ReadContactL(imageViewDef ,id);

    TInt index = contact->CardFields().Find(KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown);

    // Test image field found
    test(index != KErrNotFound);

    CContactItemField& field = contact->CardFields()[index];
    TPtrC imagePtr = field.TextStorage()->Text();

    // Image should exist
    test(BaflUtils::FileExists(fs, imagePtr));

    // Test for GUID
    TPtrC guid = contact->Guid();
    test(imagePtr.Find(guid));

    cntClient.CloseContact(id);
    CleanupStack::PopAndDestroy(2);  //  contact, imageViewDef

    TEAR_DOWN;
}
void CTGDIFontRenderingPerf::GCP2TypingTextPerfL(TPtrC aPtr,const TDesC& aTestCaseName)
	{
	//Setting up the required Font
	CFontStore* fontStore = CFontStore::NewL(&User::Heap());
	CleanupStack::PushL(fontStore);
	LoadOpenFontLibrariesL(fontStore);
	//Adding any required font files
	TUid fontFileUid = fontStore->AddFileL(KTestIndicFontFile);
	TFontSpec testFontSpec(KTestIndicFontFaceName,15); 
	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
	CleanupStack::PushL(ts);
	CFbsFont* font = NULL;
	ts->GetNearestFontToDesignHeightInTwips((CFont* &)font,testFontSpec);
	iTestText1.SetLength(aPtr.Length());
	for(TInt i = 0; i < aPtr.Length(); i++)
	{
		iTestText1[i]=aPtr[i];
	}
	iParam.iDirection = CFont::EHorizontal;
	iParam.iFlags = CFont::TPositionParam::EFLogicalOrder;
	iProfiler->InitResults();	
	for(TInt j = 0; j < KIterations ;j++)
	{
	TBuf<130> testText3(0);
	for (TInt length = 0; length < (aPtr.Length()); length++)
		{
		testText3.Append(iTestText1[length]);
		iParam.iText.Set(testText3);
		iParam.iPosInText = 0;
		iParam.iPen.iX = iParam.iPen.iY = 0;
		TInt k = testText3.Length();
		iParam.iPen.iX = iParam.iPen.iY = 0;
		TInt prev_pos_inText = iParam.iPosInText;
		for (TInt m =0 ; m<5; m++)
			{
			iParam.iPosInText = prev_pos_inText;
			RShapeInfo  shapeInfo;
			while (iParam.iPosInText <(testText3.Length()))
				{
				iParam.iPen.iX = iParam.iPen.iY = 0;
				font->GetCharacterPosition2(iParam,shapeInfo);
				}
			shapeInfo.Close();
			}
		}
	iProfiler->MarkResultSetL();
	}
	iProfiler->ResultsAnalysisAverageByNumberOfIterations(aTestCaseName,0,0,0,KIterations);
	CleanupStack::PopAndDestroy(ts);
	fontStore->RemoveFile(fontFileUid);
	CleanupStack::PopAndDestroy(fontStore);
	}
Example #29
0
/**
Searches all contact items in the view for fields that contain the search
strings specified. 

@capability ReadUserData
@param aFindWords A descriptor array containing one or more search strings
@param aMatchedContacts On return, an array of matching contact items
@param find behaviour configuration uid to be passed to the server.
 */
void RContactRemoteView::ContactsMatchingCriteriaL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid)
    {
    if(aUid != KNullUid)
        {
        TIpcArgs args(aUid.iUid);
        User::LeaveIfError(SendReceive(ECntSendPluginUidToServer,args));
        }
    CBufBase* buffer = CBufFlat::NewL(32);
    CleanupStack::PushL(buffer);
    RBufWriteStream writeStream(*buffer);
    CleanupClosePushL(writeStream);

    writeStream.WriteUint32L(aPrefixSearch);
    const TInt count = aFindWords.MdcaCount();
    writeStream.WriteUint32L(count);
    for (TInt i=0; i<count; ++i)
        {
        TPtrC ptr = aFindWords.MdcaPoint(i);
        writeStream.WriteUint32L(ptr.Length());
        writeStream << ptr;
        }
    
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()

    TPtr8 ptr(buffer->Ptr(0));
    const TInt bufferSize = buffer->Size();
    TPckg<TInt> size(bufferSize);

    TPckgBuf<TInt> pckg;
    TIpcArgs args(&pckg,&size,&ptr);
    User::LeaveIfError(SendReceive(ECntContactMatchingCriteriaExternalizedSize,args));
    CleanupStack::PopAndDestroy(buffer);

    //Internalize Contacts
    HBufC8* buf=HBufC8::NewLC(pckg());
    TPtr8 contactsbufPtr(buf->Des());
    TIpcArgs args2(&contactsbufPtr);
    User::LeaveIfError(SendReceive(ECntGetContactMatchingCriteria,args2));

    RDesReadStream readStream(contactsbufPtr);
    CleanupClosePushL(readStream);
    const TInt findCount = readStream.ReadUint32L();
    for (TInt zz=0;zz<findCount;++zz)
        {
        CViewContact* thisContact = CViewContact::NewLC(KNullContactId);
        readStream >> *thisContact;
        aMatchedContacts.AppendL(thisContact);
        CleanupStack::Pop(thisContact);
        }
    CleanupStack::PopAndDestroy(2, buf);
    }
Example #30
0
// -----------------------------------------------------------------------------
// Cosmo4AppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void COsmo4AppUi::ConstructL()
{
    // Initialise app UI with standard value.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    /*Create display*/
    iAppView = COsmo4AppView::NewL( ClientRect() );
	AddToStackL(iAppView);

	/*create playlist*/
#ifndef GPAC_GUI_ONLY
	iPlaylist = CPlaylist::NewL( ClientRect(), iAppView->GetUser() );

	iPlaylist->MakeVisible(EFalse);
#endif
	
	iAppView->MakeVisible(ETrue);
	view_mode = 0;

	m_title = NULL;

	//StatusPane ()->SwitchLayoutL ( R_AVKON_STATUS_PANE_LAYOUT_SMALL );

	nb_keys = 0;
	CaptureKeys(1);



	CCommandLineArguments *args = CCommandLineArguments::NewL();
#ifndef GPAC_GUI_ONLY
	if (args->Count() > 1) {
		TPtrC url = args->Arg(1);
#if defined(_UNICODE)
		char szURL[1024];
		u16 szURLUTF16[1024];
		size_t len;
		len = url.Size();
		memcpy(szURLUTF16, url.Ptr(), sizeof(u8)*len);
		szURLUTF16[len/2] = 0;
		const u16 *sptr = szURLUTF16;
		len = gf_utf8_wcstombs(szURL, 512, &sptr);
		if (len != (size_t) -1) {
			szURL[len] = 0;
			iAppView->Connect((const char *)szURL);
		}
#else
		iAppView->Connect((const char *)url.Ptr());
#endif
	}
#endif
	delete args;
}