Example #1
0
TCertStatus CPolicyStore::PolicyCertificateStatusL(CIkeData* aIkeData) const
    {
    LOG(Log::Printf(_L("-> CPolicyStore::PolicyCertificateStatusL()")));
    TCertStatus status = ECertValid;

    CArrayFixFlat<TCertInfo*> *cAList = aIkeData->iCAList;
    if ((cAList == NULL || cAList->Count() == 0) && 
        !aIkeData->iOwnCert.iOwnCertExists)
        {
        status = ECertNotNeeded;
        }
    else
        {        
        RPKIServiceAPI pkiService;
        User::LeaveIfError(pkiService.Connect());
        CleanupClosePushL(pkiService);

        pkiService.SetInformational(ETrue);
                    
        CDesC8ArrayFlat* caSubjectNameArray = new (ELeave) CDesC8ArrayFlat(2);
        CleanupStack::PushL(caSubjectNameArray);                        
            
        if (cAList != NULL && cAList->Count() > 0)
            {                    
            status = PkiUtil::GetValidCaCertSubjectNameListL(pkiService, *cAList,
                                                             *caSubjectNameArray);        
            }
            
        if (status == ECertValid)
            {
			// Set store type to device store,
			// if Own_cert_type is defined as "DEVICE"            
			if ( aIkeData->iClientCertType != NULL )
			  	{
				TPtrC16 certStoreType = aIkeData->iClientCertType->GetData();
				if ( certStoreType.CompareF(_L("DEVICE")) == 0 )
					{
					LOG(Log::Printf(_L("Set store type to STORETYPE_DEVICE")));    
					pkiService.SetStoreType(EPkiStoreTypeDevice);            
					}
                else
                    {
					LOG(Log::Printf(_L("Set store type to STORETYPE_USER")));    
					pkiService.SetStoreType(EPkiStoreTypeUser);                                
                    }
				}
            else
                {
				LOG(Log::Printf(_L("Set store type to STORETYPE_USER")));    
				pkiService.SetStoreType(EPkiStoreTypeUser);                                                
                }
            status = PkiUtil::CheckUserCertValidityL(pkiService, *caSubjectNameArray,
                                                     aIkeData->iOwnCert);
            }
        CleanupStack::PopAndDestroy(caSubjectNameArray);
        CleanupStack::PopAndDestroy(); //pkiService            
        }
	LOG(Log::Printf(_L("<- CPolicyStore::PolicyCertificateStatusL()")));        
    return status;
    }
TInt CContextMediaArrayImpl::MdcaCount() const
{
	CALLSTACKITEM_N(_CL("CContextMediaArrayImpl"), _CL("MdcaCount"));

	if (iItem == ENone) {
		return iPostArray->Count();
	} else {
		return iPostArray->Count()+1;
	}
}
Example #3
0
//#pragma warning( disable : 4701 )	//local variable 'docPosError' may be used without having been initialized
TBool CLinePaginatorTest::CompareArrays()
	{
	TInt numPages=iCharsPerPage->Count();
	TInt numTestPages=iTestChars->Count();
	TInt numChars;
	TInt numTestChars;
	TBool pagesSame=EFalse;
	TBuf8<128> text;
	TInt prevDocPos=0;
	TInt docPosError=0;

	TBuf<256> buf;
	if (numPages==numTestPages)
		{
 		buf.AppendFormat(_L("Correct Number of Pages = %d\n"), numPages);
 		TESTPRINT(buf);
		pagesSame=ETrue;
		for (TInt i=0; i<numPages; i++)
			{
			numChars=(*iCharsPerPage)[i];
			numTestChars=(*iTestChars)[i]-prevDocPos;
			if(numChars!=numTestChars)
				{
				if (pagesSame)
					docPosError=(*iTestChars)[i];
				pagesSame=EFalse;
				}
			prevDocPos=(*iTestChars)[i];
			}
		if (pagesSame)
			{            
 			TESTPRINT(_L("Correct Number of Characters on Pages -- PASSED\n"));
			}
		else
			{
            TESTPRINT(_L("Incorrect Number of Characters on Pages -- FAILED\n"));            
            buf.Zero();
			buf.AppendFormat(_L("First Error Occurs at Position = %d"), docPosError);
			TESTPRINT(buf);
			}
		}
	else
		{
        TESTPRINT(_L("Incorrect Number of Pages  -- FAILED\n"));
        buf.Zero();
		buf.AppendFormat(_L("Number Calculated	by LinePaginator = %d\n"), numPages);		
		buf.AppendFormat(_L("Number Contained in File = %d\n"), numTestPages);
		TESTPRINT(buf);
		}

	iTestFile.Close();
	return pagesSame;
	}
void CBCTestPtiEngine::TestLanguageL()
    {
    CArrayFixFlat<TInt>* langs = new (ELeave) CArrayFixFlat<TInt>(100);
    CleanupStack::PushL(langs);
    iEngine->GetAvailableLanguagesL(langs);

    AssertTrueL(langs->Count()>0, _L("available languages got"));
    CleanupStack::PopAndDestroy( 1 ); // cores, langs

    RArray<TInt> langRefs;
    iEngine->GetAvailableLanguagesL(langRefs);
    AssertTrueL(langRefs.Count()>0, _L("available languages got into RArray"));

    //
    //activate
    //
    if(langRefs.Count())
        {
        MPtiLanguage *lan = iEngine->GetLanguage(langRefs[0]);
        if (lan->HasInputMode(EPtiEngineMultitapping))
            {
            iEngine->ActivateLanguageL(lan->LanguageCode(), EPtiEngineMultitapping);
            AssertTrueL( ETrue, _L("activate multitapping"));
            }
        else
            {
            iEngine->ActivateLanguageL(lan->LanguageCode(), EPtiEnginePredictive);
            AssertTrueL( ETrue, _L("activate predictive"));
            }
        }

    langRefs.Close();
    }
Example #5
0
TUint32 CIkev2NatT::CheckPeerNotifysL(const CArrayFixFlat<TNotifPayloadIkev2*>& aNotifys, 
                                      const TInetAddr& aLocalAddr, const  TInetAddr& aRemoteAddr, TUint16 aPort, 
									  const TDesC8& aInitiatorSpi, const TDesC8& aResponderSpi, TBool& aSupported)
{    
  //
  // Check does there exists NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP
  // Notify payload. If found compare payload data to local end NAT
  // traversal data as follows:
  // -- NAT_DETECTION_SOURCE_IP Notifys are examined against local Notify
  //    payload iDstIdentiy data: If no match found
  //    ==> Peer is behind  NAT
  // -- NAT_DETECTION_DESTINATION_IP Notify is examined against local Notify
  //    payload iSrcIdentiy data: If no match found
  //    ==> Local end behind NAT
  //
    aSupported = EFalse;
	TInt Count = aNotifys.Count();

	CIkev2NatT* RefObj = CIkev2NatT::NewL(aLocalAddr, aRemoteAddr, aPort, 
                                          aInitiatorSpi, aResponderSpi);
	 
	TNotifPayloadIkev2* PeerNotify;
	TUint32 PeerLth;
	TBool SrcMatch   = EFalse;
	TBool DstMatch   = EFalse;	
    TUint32 NatFlags = 0;
    TInt i = 0;

	while ( i < Count )
	{
		PeerNotify = aNotifys.At(i);
		if ( (PeerNotify->GetMsgType() == NAT_DETECTION_SOURCE_IP) && !SrcMatch )
		{
			NatFlags |= REMOTE_END_NAT;
			PeerLth = TPayloadIkev2::Cast(PeerNotify)->GetLength() - (TUint32)(PeerNotify->Size() + PeerNotify->GetSPISize());
			const TPtrC8 peerNotify(PeerNotify->NotifData(), PeerLth);
			if ( RefObj->DestinNofify().Compare(peerNotify) == 0)
			{
				SrcMatch  = ETrue;
				NatFlags &= ~REMOTE_END_NAT;
			}	
		}
		else if ( (PeerNotify->GetMsgType() == NAT_DETECTION_DESTINATION_IP) && !DstMatch )
		{
			aSupported = ETrue;						
			NatFlags  |= LOCAL_END_NAT;
			PeerLth = TPayloadIkev2::Cast(PeerNotify)->GetLength() - (TUint32)(PeerNotify->Size() + PeerNotify->GetSPISize()); 
			const TPtrC8 peerNotify(PeerNotify->NotifData(), PeerLth);
			if ( RefObj->SourceNofify().Compare(peerNotify) == 0 )
			{
				DstMatch  = ETrue;							
				NatFlags &= ~LOCAL_END_NAT;
			}	
		}			
	    i ++;
    }

	delete RefObj;	
    return NatFlags;     
}
Example #6
0
/**
   @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery5L
  
   @SYMPREQ 538
  
   @SYMTestCaseDesc Test the functionality of GetAppServicesL which gets all the service uids of a particular app 
   
   @SYMTestPriority 
  
   @SYMTestStatus Implemented
   
   @SYMTestActions Call GetAppServicesL with two parameters: the app uid and an array to put in the uid of the services 
   on z: drive.\n
   API Calls:\n	
   RApaLsSession::GetAppServicesL(TUid aAppUid, CArrayFixFlat<TUid>& aServiceUids) const
   
   @SYMTestExpectedResults Populates the array with the uids of the services offered by this particular app. 
   The returned data should be the same as that defined in the registration files. 
    
 */
void CT_ServicesTestStep::TestServiceDiscovery5L()
	{
	INFO_PRINTF1(_L("TestServiceDiscovery5 about to start..."));
	const TUid KUidServerApp = {0x10004c56};
	const TUid KUidService1234 = {0x01020304};
	const TUid KUidService2345 = {0x02030405};
	const TUid KUidService5678 = {0x05060708};
	const TUid KUidService = {0x01020333};
	// get UIDs of all services implemented by an app
	CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
	CleanupStack::PushL(uidArray);
	iApaLsSession.GetAppServicesL(KUidServerApp,*uidArray);
	TInt count = uidArray->Count();
	TUid uid;
	if(count>0)
		{
		TEST(count==6);	// Takes into account the open service
		uid = (*uidArray)[0];
		TEST(uid==KUidService);
		uid = (*uidArray)[1];
		TEST(uid==KUidService5678);
		uid = (*uidArray)[2];
		TEST(uid==KUidService5678);
		uid = (*uidArray)[3];
		TEST(uid==KUidService2345);
		uid = (*uidArray)[4];
		TEST(uid==KUidService1234);
		}
	CleanupStack::PopAndDestroy(uidArray);
	uidArray = NULL;
	}
Example #7
0
CGulIcon* CTap2MenuAppUi::LoadAppIconHard(TUid aUid)
	{
	RApaLsSession ls;
	ls.Connect();
	CGulIcon *retval = NULL;
	CArrayFixFlat<TSize> *array = new CArrayFixFlat<TSize>(3);
	CleanupStack::PushL(array);
	TInt err = ls.GetAppIconSizes(aUid, *array);
	if(err == KErrNone && array->Count() > 0)
		{
		CApaMaskedBitmap *bitmap = CApaMaskedBitmap::NewLC();
		err = ls.GetAppIcon(aUid, (*array)[0], *bitmap);
		if(err == KErrNone)
			{
			CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
			CleanupStack::PushL(bmp);
			CFbsBitmap* bmp_mask = new (ELeave) CFbsBitmap();
			CleanupStack::PushL(bmp_mask);
			User::LeaveIfError(bmp->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()));
			User::LeaveIfError(bmp_mask->Create(bitmap->Mask()->SizeInPixels(), bitmap->Mask()->DisplayMode()));
			CopyBitmapL(bitmap, bmp);
			CopyBitmapL(bitmap->Mask(), bmp_mask);
			retval = CGulIcon::NewL(bmp, bmp_mask);
			CleanupStack::Pop(2); // bmp, bmp_mask
			}
			CleanupStack::PopAndDestroy(bitmap);
		}
		CleanupStack::PopAndDestroy(array);
		ls.Close();
		return retval;
	}
/**
This method should only be used by CImapAtomParser.
During parsing, a ReAllocL() may be required on the heap buffer that this atom and its 
descendants' string data descriptor points at.
This happens when the heap buffer needs to be expanded.
If this causes the heap buffer's address to change, then this atom and its descendants' 
pointer descriptors need updating.
@param The address of the new heap buffer
@param The address of the data within the heap buffer before the ReAllocL took place.
*/
void CImapAtom::FixupL(const HBufC8 *aNewBuffer, const TText8 *aOldBuffer)
	{
   // Fixup descriptor pointers
	CArrayFixFlat<CImapAtom*>* atomStack = new (ELeave) CArrayFixFlat<CImapAtom*>(10);
	CleanupStack::PushL(atomStack);

	atomStack->AppendL(this);
	CImapAtom* currentAtom;
	while (atomStack->Count() != 0)
   		{
		// Pop the top atom off of the stack
		currentAtom = (*atomStack)[atomStack->Count() - 1];
 		atomStack->ResizeL(atomStack->Count() - 1);
 
		// Fix up the current atom
		if (currentAtom->iAtom.Length()>0)
			{
			// Find offset from start of old buffer
			TInt start=(currentAtom->iAtom.Ptr()-aOldBuffer);

 			// Make new descriptor & assign it
			TPtrC8 bufptr(aNewBuffer->Ptr()+start,currentAtom->iAtom.Length());
			currentAtom->iAtom.Set(bufptr); // Note that we are setting the real iAtom not the copy returned by Atom()
			}
 
		// Add the first sibling to the stack,
		// subsequent siblings are added when this sibling is visited
		CImapAtom* siblingAtom = currentAtom->Next();
		if (siblingAtom)
			{
			atomStack->AppendL(siblingAtom);
			}
   
		// Add child to the stack
		CImapAtom* childAtom = currentAtom->Child();
		if (childAtom)
			{
			atomStack->AppendL(childAtom);
			}			
   		}
   
	CleanupStack::PopAndDestroy(atomStack);
   	}
void CContextMediaArrayImpl::ReleasePosts()
{
	if (iPostArray) {
		int i;
		for (i=0;i<iPostArray->Count();i++) {
			CCMPost * aPost = (*iPostArray)[i];
			if (aPost) {
				CC_TRAPD(err, iStorage.Release( aPost, 0 ));
			}
		}
	}
}
LOCAL_C void CloseArrayOfCallObjects(TAny* aCallArray)
/**
Close and delete the call object array.
*/
	{
	CArrayFixFlat<RMobileCall>* callArray = reinterpret_cast<CArrayFixFlat<RMobileCall>*>(aCallArray);
	TInt count = callArray->Count();
	for (TInt i=count-1; i>=0; --i)
		{
		callArray->At(i).Close();
		}	
	delete callArray;
 	callArray = NULL; 	
	}
void CContextMediaArrayImpl::PostEvent(CCMPost* aParent, CCMPost* aChild, TEvent aEvent)
{
	CALLSTACKITEM_N(_CL("CContextMediaArrayImpl"), _CL("PostEvent"));
	
	if (aParent != iParentPost) return;

	if (aEvent==EChildAdded) {
		iPostIdArray->AppendL(aChild->iPostId());
		iPostArray->AppendL(0);
		iObserver.PostEvent(aParent, aChild, aEvent);
	}

	if (aEvent==EPlaceholderFilled) {
		TInt i;
		for (i=0; i<iPostIdArray->Count();i++) {
			if (iPostIdArray->At(i) == aChild->iPostId()) {
				CC_TRAPD(ignore, iStorage.Release(iPostArray->At(i), 0));
				iPostArray->At(i) = 0;
				iObserver.PostEvent(aParent, aChild, aEvent);
				return;
			}
		}
	}

	if (aEvent==EPostHidden) {
		ReadFromStorage();
		iObserver.PostEvent(aParent, aChild, aEvent);
	}

	if (aEvent==EPostVisible) {
		ReadFromStorage();
		iObserver.PostEvent(aParent, aChild, aEvent);
	}

	if (aEvent==EPostUpdated) {
		iObserver.PostEvent(aParent, aChild, aEvent);
	} 

	if ((aEvent==EThumbnailLoaded) || (aEvent==EUnreadChanged)) {
		iObserver.PostEvent(aParent, aChild, aEvent);
	}

	if (aEvent==ELastPostChanged) {
		iObserver.PostEvent(aParent, aChild, aEvent);
	}
	
	//do nothing for:
	//	EMediaLoaded,
	//	EErrorUpdated,
}
LOCAL_C TBool operator==(const CArrayFixFlat<TTaskSchedulerCondition>& aConditions1, const CArrayFixFlat<TTaskSchedulerCondition>& aConditions2)
	{
	TInt count1 = aConditions1.Count();
	TInt count2 = aConditions2.Count();
	
	// Compare the conditions.	
	if( count1 != count2 )
		{
		// Different number of conditions - no match.
		return EFalse;
		}
		
	// Search for all the conditions in info1 are in info2
	for( TInt ii = 0; ii < count1; ++ii )
		{
		TTaskSchedulerCondition condition1 = aConditions1[ii];
		TTaskSchedulerCondition condition2;
		TBool found = EFalse;
		TInt jj = 0;
		while( !found && jj < count2 )
			{
			condition2 = aConditions2[jj];
			
			if( condition2.iKey == condition1.iKey )
				found = ETrue;
			else
				++jj;
			}
		if( !found || condition2.iState != condition1.iState || condition2.iType != condition1.iType )
			{
			// Either aConditions2 has not got this condition or it has but it 
			// does not match - no match.
			return EFalse;
			}
		}
	return ETrue;
	}
/*!
    \brief Returns names and identifiers of supported languages in a phone.
 
    Language names are localized according the language's native presentation.
    Language ID's returned by this functions may be used as language parameter for changeLanguage(int language) function.
    Language IDs and names are OS specific and may vary across the platforms and releases.
    
    \attention Symbian specific API
    
    \deprecated HbLanguageUtil::supportedLanguages()
        is deprecated. Please use HbLocaleUtil::supportedLanguages() instead.
     
    \return Symbian - localized names and integer identifiers of languages supported in a device  
    \return other platforms - empty QHash    
*/
QHash<int, QString> HbLanguageUtil::supportedLanguages()
{
#if defined(Q_OS_SYMBIAN)   
    QHash<int, QString> languages; 
    
    QTranslator translator;
    QString path = "c:";
    path += QString(TRANSLATOR_PATH);
    if (!translator.load(path)) {
        path = "z:";
        path += QString(TRANSLATOR_PATH);
        if (!translator.load(path)) {
            return languages;
        } 
    } 

    QCoreApplication::installTranslator(&translator);
    QHash<int, QString> hashLanguageNames = readLanguageList();
 
    CArrayFixFlat<TInt>* systemEpocLanguageCodes = 0;
    TInt error = SysLangUtil::GetInstalledLanguages( systemEpocLanguageCodes );
    if ( error != KErrNone ) {
        delete systemEpocLanguageCodes;
        return languages;
    }
    
    for (int i = 0; i < systemEpocLanguageCodes->Count(); ++i) {
        int code = systemEpocLanguageCodes->At(i);
        QString id = QString(LANGUAGE_ID_PREFIX);
        id += QString::number(code);
        QString locName = hbTrId(id.toAscii().constData());
        if (locName.isEmpty() || locName == id) {
            locName = hashLanguageNames.value(code);
        }
        languages.insert(code, locName);
    }
    
    delete systemEpocLanguageCodes;
    return languages;
#else 
    QHash<int, QString> dummy;
    return dummy;
#endif
}
/**
Searches the scheduler for an existing conditions schedule item with a set of 
pending conditions and timeout value that matches with those supplied.

@see RScheduler::GetScheduleL

@param aScheduler
Handle to the scheduler.

@param aConditions
The set of System Agent conditions that are required to be met to trigger the
schedule.

@param aTimeout
The timeout value for the schedule.

@param aRef
On return, the schedule item.

@leave KErrNotFound
No schedule found matching the schedule conditions and timeout.
*/
EXPORT_C void CMsvScheduleSend::FindScheduleL(
								RScheduler&										aScheduler, 
								const CArrayFixFlat<TTaskSchedulerCondition>&	aConditions, 
								const TTime&									aTimeout, 
								TSchedulerItemRef& 								aRef)
	{
	CArrayFixFlat<TTaskSchedulerCondition>* schConditions = new (ELeave) CArrayFixFlat<TTaskSchedulerCondition>(KMsvSchsendArrayGrowth);
	CleanupStack::PushL(schConditions);

	CArrayFixFlat<TTaskInfo>* taskInfos = new (ELeave) CArrayFixFlat<TTaskInfo>(1);
	CleanupStack::PushL(taskInfos);

	aRef.iHandle = KErrNotFound;

	CArrayFixFlat<TSchedulerItemRef>* refs = new (ELeave) CArrayFixFlat<TSchedulerItemRef>(KMsvSchsendArrayGrowth);
	CleanupStack::PushL(refs);
	
	User::LeaveIfError(aScheduler.GetTaskRefsL(*refs, EAllSchedules, EMyTasks));

	TInt count = refs->Count();
	TScheduleState2 state;
	TTsTime nextTimeout;
	
	while( count-- && aRef.iHandle == KErrNotFound )
		{
		const TSchedulerItemRef& tempRef = (*refs)[count];

		TScheduleType type;
		User::LeaveIfError(aScheduler.GetScheduleTypeL(tempRef.iHandle, type));
		if( type == EConditionSchedule )
			{
			taskInfos->Reset();
			const TInt err = aScheduler.GetScheduleL(tempRef.iHandle, state, *schConditions, nextTimeout, *taskInfos);
			if( err == KErrNone && nextTimeout.GetUtcTime() == aTimeout && *schConditions == aConditions )
				aRef = tempRef;
			}
		}

	CleanupStack::PopAndDestroy(3, schConditions);
	if (aRef.iHandle == KErrNotFound)
		User::Leave(KErrNotFound);
	}	
/**
Searches the scheduler for an existing schedule item with a schedule time that
matches with time supplied.

@see RScheduler::GetScheduleL()

@param aScheduler
Handle to the scheduler.

@param aStartTime
Schedule start time.

@param aRef
On return, the schedule item.

@leave KErrNotFound
No schedule found matching the schedule time.
*/
EXPORT_C void CMsvScheduleSend::FindScheduleL(RScheduler& aScheduler, const TTime& aStartTime, TSchedulerItemRef& aRef)
	{
	CArrayFixFlat<TScheduleEntryInfo2>* entryInfos = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
	CleanupStack::PushL(entryInfos);

	CArrayFixFlat<TTaskInfo>* taskInfos = new (ELeave) CArrayFixFlat<TTaskInfo>(1);
	CleanupStack::PushL(taskInfos);

	aRef.iHandle = KErrNotFound;

	CArrayFixFlat<TSchedulerItemRef>* refs = new (ELeave) CArrayFixFlat<TSchedulerItemRef>(KMsvSchsendArrayGrowth);
	CleanupStack::PushL(refs);

	User::LeaveIfError(aScheduler.GetTaskRefsL(*refs, EAllSchedules, EMyTasks));

	TInt count = refs->Count();
	TScheduleState2 state;
	TTsTime nextDue;

	while (count-- && aRef.iHandle == KErrNotFound)
		{
		const TSchedulerItemRef& tempRef = (*refs)[count];

		TScheduleType type;
		User::LeaveIfError(aScheduler.GetScheduleTypeL(tempRef.iHandle, type));
		if( type == ETimeSchedule )
			{
			entryInfos->Reset();
			taskInfos->Reset();
			const TInt err = aScheduler.GetScheduleL(tempRef.iHandle, state, *entryInfos, *taskInfos, nextDue);
			if( err == KErrNone && nextDue.GetUtcTime() == aStartTime )
				aRef = tempRef;
			}
		}

	CleanupStack::PopAndDestroy(3, entryInfos);
	if (aRef.iHandle == KErrNotFound)
		User::Leave(KErrNotFound);
	}
// ---------------------------------------------------------------------------
// CAknDiscreetPopupDrawer::WrapTitleTextL
// Wraps long text to two lines.
// ---------------------------------------------------------------------------
//
void CAknDiscreetPopupDrawer::WrapTitleTextL()
    {
    CArrayFixFlat<TInt>* lineWidths 
        = new ( ELeave ) CArrayFixFlat<TInt>( KMaxNumOfLines );
    CleanupStack::PushL( lineWidths );
    CArrayFixFlat<TPtrC>* wrappedArray
        = new ( ELeave ) CArrayFixFlat<TPtrC>( KMaxNumOfLines );
    CleanupStack::PushL( wrappedArray );

    for ( TInt i = 0; i < KMaxNumOfLines; i++ )
        {
        lineWidths->AppendL( iTitleTextData.iTextRect.Width() );
        }

    HBufC* visualBuffer = HBufC::NewLC( 
            iTitleText->Length() + KMaxNumOfLines * KAknBidiExtraSpacePerLine );
    *visualBuffer = *iTitleText;
    TPtr ptr( visualBuffer->Des() );

    AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
            ptr, *lineWidths, *iTitleTextData.iTextFont, *wrappedArray, ETrue );

    if ( wrappedArray->Count() && wrappedArray->At( 1 ) != KNullDesC )
        {
        delete iTitleText;
        iTitleText = NULL;
        delete iBodyText;
        iBodyText = NULL;
        iTitleText = wrappedArray->At( 0 ).AllocL();
        iBodyText = wrappedArray->At( 1 ).AllocL();
        }

    CleanupStack::PopAndDestroy( visualBuffer );
    CleanupStack::PopAndDestroy( wrappedArray );
    CleanupStack::PopAndDestroy( lineWidths );
    }
EXPORT_C void CSchSendTestUtils::DisplayAllSchedulesL(TInt& rSchCount, TInt& rSchSize)
	{
	Printf(_L("Displaying all Schedules:\n"));
	rSchCount = 0;
	rSchSize = 0;

	TParse parse;
	TFileName fileName(_L("\\system\\schedules\\")); 
	_LIT(KCDrive, "C:");
	parse.Set(fileName, &KCDrive, NULL);

	CDir* entryList;
	TPtrC drive(parse.DriveAndPath());
	TInt err = iFs.GetDir(drive, KEntryAttNormal, ESortNone, entryList);
	
	if (err)
		{
		Printf(_L("\tiFs.GetDir(%S) returned %d\n"), &drive, err);
		return;
		}

	CleanupStack::PushL(entryList);
	
	TInt count = entryList->Count();

	while (count--)
		{
		TEntry entry((*entryList)[count]);
		rSchSize += entry.iSize;
		}

	Printf(_L("\tFiles in %S have total size %d\n"), &drive, rSchSize);

	CleanupStack::PopAndDestroy(entryList);

	RScheduler sch;
	err = sch.Connect();

	if (err)
		{
		Printf(_L("\tRScheduler::Connect() returned %d\n"), err);
		return;
		}
	
	CleanupClosePushL(sch);

	IMPORT_C TInt GetScheduleL(const TInt aScheduleHandle, TScheduleState& aState, 
			CArrayFixFlat<TScheduleEntryInfo>& aEntries, CArrayFixFlat<TTaskInfo>& aTasks, TTime& aDueTime);

	CArrayFixFlat<TSchedulerItemRef>* schRefArray = new (ELeave) CArrayFixFlat<TSchedulerItemRef>(10);
	CleanupStack::PushL(schRefArray);

	CArrayFixFlat<TScheduleEntryInfo>* schEntries = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(10);
	CleanupStack::PushL(schEntries);

	CArrayFixFlat<TTaskInfo>* schTasks = new (ELeave) CArrayFixFlat<TTaskInfo>(10);
	CleanupStack::PushL(schTasks);

	err = sch.GetScheduleRefsL(*schRefArray, EAllSchedules);

	if (!err)
		{
		TScheduleState schState;
		TTime schDueTime;
		count = schRefArray->Count();
		rSchCount = count;
		Printf(_L("\t%d schedules in the task scheduler\n"), count);

		while (count--)
			{
			err = sch.GetScheduleL((*schRefArray)[count].iHandle, schState, *schEntries, *schTasks, schDueTime);

			if (!err)
				{
				TInt taskCount = schTasks->Count();
				Printf(_L("\tSchedule %d (\"%S\") has %d tasks\n"), (*schRefArray)[count].iHandle, &(*schRefArray)[count].iName, taskCount);

				while (taskCount--)
					{
					TTaskInfo taskInfo((*schTasks)[taskCount]);
					TInt size;
					err = sch.GetTaskDataSize(taskInfo.iTaskId, size);

					if (!err)
						{
						HBufC* hBuf = HBufC::NewLC(size);
						TPtr ptr(hBuf->Des());
						TSchedulerItemRef schRef;

						err = sch.GetTaskInfoL(taskInfo.iTaskId, taskInfo, ptr, schRef, schDueTime);

						if (!err)
							{
							TPckgBuf<TMsvSchedulePackage> mtmBuf;
							mtmBuf.Copy(*hBuf);
							Printf(_L("\t\tTask %d: msvId %d, commandId %d, pollProgress %d\n"), taskInfo.iTaskId, mtmBuf().iId, mtmBuf().iCommandId, mtmBuf().iPollProgress.Int());
							}
						else
							{
							Printf(_L("\t\tRScheduler::GetTaskInfoL(%d) returned %d\n"), taskInfo.iTaskId, err);
							}

						CleanupStack::PopAndDestroy(hBuf);
						}
					else
						{
						Printf(_L("\t\tRScheduler::GetTaskDataSize(%d) returned %d\n"), taskInfo.iTaskId, err);
						}
					}
				}
			else
				{
				Printf(_L("\tRScheduler::GetScheduleL(%d (\"%S\")) returned %d\n"), (*schRefArray)[count].iHandle, &(*schRefArray)[count].iName, err);
				}
			}
		}
	else
		{
		Printf(_L("RScheduler::GetScheduleRefsL() returned %d"), err);
		}

	CleanupStack::PopAndDestroy(3); //schRefArray, schEntries, schTasks
	CleanupStack::PopAndDestroy(); //sch
	}
Example #18
0
void CFMSServer::DeleteScheduledRemindersL()
    {
    FLOG(_L("CFMSServer::DeleteScheduledRemindersL >>"));
    
    TScheduleEntryInfo2                     ret;
    TInt                                    err;    
    RScheduler                              sc;
    TTime                                   t; 
    TTsTime                                 time;
    TSchedulerItemRef                       scitem; 
    CArrayFixFlat<TSchedulerItemRef>*       aSchRefArray = new CArrayFixFlat <TSchedulerItemRef>(5);
    TScheduleFilter                         aFilter(EAllSchedules);
    User::LeaveIfError( sc.Connect() ); 
    CleanupClosePushL( sc );
    CleanupStack::PushL(aSchRefArray);

    User::LeaveIfError( sc.GetScheduleRefsL( *aSchRefArray,aFilter) );
    FLOG(_L("Schedule items: "));
    for ( TInt i=0; i<aSchRefArray->Count(); ++i  )
    {
    TSchedulerItemRef it = (*aSchRefArray)[i];
    if ( it.iName == TUid::Uid(KFMSServerUid).Name()  )
        {
        TScheduleState2 sc_state;
        CArrayFixFlat<TScheduleEntryInfo2>*  sc_entries = new CArrayFixFlat <TScheduleEntryInfo2>(5);
        CArrayFixFlat<TTaskInfo>*            sc_tasks  = new CArrayFixFlat <TTaskInfo>(5);
        TTsTime                              sc_duetime;
        CleanupStack::PushL( sc_entries );
        CleanupStack::PushL( sc_tasks );
        FLOG (_L("%d. schedule handle: %d name:'%S'"),i,it.iHandle, &(it.iName) );

        err = sc.GetScheduleL ( it.iHandle , sc_state, *sc_entries,*sc_tasks,sc_duetime ); // xx

        TDateTime  dtm = sc_duetime.GetLocalTime().DateTime();
        FLOG(_L("   schedule duetime:%d:%d"), dtm.Hour(), dtm.Minute());

        if ( err ) FLOG(_L("     schedule  sc get err %d"),err);
        else 
            {
            for ( TInt k=0; k<sc_entries->Count();++k)
                {
                TScheduleEntryInfo2 sc_entry = (*sc_entries)[k];
                ret = sc_entry;
                TTime sctime = sc_entry.StartTime().GetLocalTime();
                FLOG(_L("         schedule entry %d int-type:%d int:%d start: %d:%d"),k,sc_entry.IntervalType(),sc_entry.Interval(),sctime.DateTime().Hour(),sctime.DateTime().Minute());
                }

            for ( TInt j=0; j<sc_tasks->Count();++j)
                {
                TTaskInfo sc_task = (*sc_tasks)[j];
                FLOG(_L("         schedule task  %d  '%S'"),sc_task.iTaskId,&(sc_task.iName) );
                if ( sc_task.iName==TUid::Uid(KFMSServerUid).Name() )
                    {
                    FLOG(_L("          schedule DeleteTask %d"),sc_task.iTaskId);
                    User::LeaveIfError( sc.DeleteTask(sc_task.iTaskId) );
                    }
                }
            }

        FLOG(_L("     DeleteSchedule %d"),it.iHandle);
        err = sc.DeleteSchedule(it.iHandle );
		FLOG(_L("Delete status of tasks = %d"), err);

        CleanupStack::PopAndDestroy( sc_tasks );
        CleanupStack::PopAndDestroy( sc_entries );
        }
    }
    CleanupStack::PopAndDestroy( aSchRefArray );
    CleanupStack::PopAndDestroy(&sc);
    
    FLOG(_L("CFMSServer::DeleteScheduledRemindersL <<"));
    }
Example #19
0
/**---------------------------------------------------------
 *
 * ServiceL(const RMessage& aMessage)
 *
 *----------------------------------------------------------*/
void CPKISession::ServiceL(const RMessage2& aMessage)
    {
    TInt Status = KErrNone;
    TInt count = 0;
    
    LOG_1("CPKISession::ServiceL: function = %d", aMessage.Function());

    switch(aMessage.Function())
        {                            
        case PkiService::ECancelPendingOperation:
            iWrapper->CancelPendingOperation();
            aMessage.Complete(KErrNone);
            break;
        
        case PkiService::EGetRequiredBufferSize:
            if (iRequiredBufferSize == KBufferSizeNotDefined)
                {                
                Status = iWrapper->GetRequiredBufferSizeL(aMessage);
                }
            else
                {
                TPckg<TInt> pckgSize(iRequiredBufferSize);
                aMessage.WriteL(0, pckgSize);
                aMessage.Complete(KErrNone);
                }
            break;

        case PkiService::ECertCount:        
            count = iMapper.CertCount(iWrapper->Informational());
            aMessage.Complete(count);
            break;
            
        case PkiService::EApplicableCertCount:
    		{
    		TInt aC = 0;
    		TPckg<TInt> pckgApplCount(aC);
    		aMessage.ReadL(0, pckgApplCount);

    		// Read applications
    		// Allocate list for applications
    		CBufFlat* list = CBufFlat::NewL(sizeof(TUid));
    		CleanupStack::PushL(list);
    		list->ResizeL(aC * sizeof(TUid));
    		TPtr8 ptrList = list->Ptr(0);
    		aMessage.ReadL(1, ptrList);
    		iUidArray.Close();
    		if(aC > 0)
    			{
    			TUid tempUid;
    			for (TInt i = 0; i < aC; i++)
    				{
    				list->Read(i * sizeof(TUid), (TAny*)&tempUid, sizeof(TUid));
    				iUidArray.Append(tempUid);
    				}
    			}
    		CleanupStack::PopAndDestroy(1);     // list
    		
    		TInt matchCount = iMapper.ApplicableCertCount(iUidArray);
    		aMessage.Complete(matchCount); 
    		}
    		break;
       case PkiService::EGetCertDetails:
            {
            TPckgBuf<TSecurityObjectDescriptor> secDescPtr;
            aMessage.ReadL(1, secDescPtr);
            TCertificateListEntry* resultCertInfo = new (ELeave) TCertificateListEntry;
            CleanupStack::PushL(resultCertInfo);            
            Status = iMapper.GetCertDetailsL(secDescPtr(), 
                                             iWrapper->CertStoreType(), 
                                             iWrapper->Informational(),
                                             *resultCertInfo);
		    if (Status == KErrNone)
		        {
		        TPckg<TCertificateListEntry> certDetailsPtr(*resultCertInfo);
	            aMessage.WriteL(0, certDetailsPtr);
		        }
		    aMessage.Complete(Status);
		    CleanupStack::PopAndDestroy(resultCertInfo);            
            }
		    break;
        case PkiService::EGetCertList:
		    iMapper.GetCertListL(aMessage, iWrapper->Informational());
		    aMessage.Complete(KErrNone);
		    break;

        case PkiService::EGetApplicableCertList:		
		    iMapper.GetApplicableCertListL(aMessage, iUidArray);
		    aMessage.Complete(KErrNone);
		    break;

        case PkiService::EGetKeyList:
        	{
        	PKISERVICE_ASSERT(iKeyList != NULL);
        	
	        CBufFlat* list = CBufFlat::NewL(sizeof(TKeyListEntry));
	        CleanupStack::PushL(list);
	        list->ResizeL(iKeyList->Count() * sizeof(TKeyListEntry));	        
	
	        for(TInt i = 0; i < iKeyList->Count(); i++)
	            {
	            const TKeyListEntry& keyInfo = (*iKeyList)[i];
                list->Write(i * sizeof(TKeyListEntry),
                            (TAny*)&keyInfo,
                            sizeof(TKeyListEntry));
	            }
	        TPtr8 ptrList = list->Ptr(0);
	        aMessage.WriteL(0, ptrList);	
	        CleanupStack::PopAndDestroy(list); // list
	          
	        delete iKeyList;
	        iKeyList = NULL;
            aMessage.Complete(KErrNone);
        	}
            break;
    		
        case PkiService::ECertReqCount:                    
            count = iServer.CertificateRequestStore().CertReqCountL();
            aMessage.Complete(count); 
            break;    		
    		
        case PkiService::EGetCertReqList:
            {
            CArrayFixFlat<TCertificateRequestListEntry>* certReqList =
                        iServer.CertificateRequestStore().GetCertReqListLC();
                       
            TUint bufferGranularity = sizeof(TCertificateRequestListEntry);
            if (certReqList->Count() > 0)
                {
                bufferGranularity = bufferGranularity * certReqList->Count();
                }
            CBufFlat* list = CBufFlat::NewL(bufferGranularity);            
            CleanupStack::PushL(list);                    
            
            if (certReqList->Count() > 0)
                {
                list->ResizeL(sizeof(TCertificateRequestListEntry) * certReqList->Count());
                }
                        
            for (TInt i = 0; i < certReqList->Count(); ++i)
                {
                const TCertificateRequestListEntry &certReqInfo = (*certReqList)[i];               
                list->Write(i * sizeof(TCertificateRequestListEntry),
                            &certReqInfo,
                            sizeof(TCertificateRequestListEntry));

                }
            TPtr8 ptrList = list->Ptr(0);
            aMessage.WriteL(0, ptrList);               
                        
            CleanupStack::PopAndDestroy(list);                                                            
            CleanupStack::PopAndDestroy(certReqList);                        
            
            aMessage.Complete(KErrNone);            
            }
            break;
            
        case PkiService::ESaveCertificateRequest:
            {
            TInt requestSize = aMessage.GetDesLength(0);                        
            HBufC8* request = HBufC8::NewLC(requestSize);
            TPtr8 requestPtr = request->Des();
            
            TKeyIdentifier keyId;
            
            aMessage.ReadL(0, requestPtr);
            aMessage.ReadL(2, keyId); //keyId is ignored.
            
            HBufC* certRequestRef = 
                iServer.CertificateRequestStore().SaveCertRequestLC(*request);
            
            aMessage.WriteL(1, *certRequestRef);
            
            CleanupStack::PopAndDestroy(certRequestRef);
            CleanupStack::PopAndDestroy(request);
                    
            aMessage.Complete(KErrNone);
            }
            break;
            
        case PkiService::EReadCertificateRequest:
            {
            TInt certRequestRefSize = aMessage.GetDesLength(0);
            HBufC *certRequestRef = HBufC::NewLC(certRequestRefSize);                     
            TPtr certRequestRefPtr = certRequestRef->Des();
            
            aMessage.ReadL(0, certRequestRefPtr);
            
            if (certRequestRef->Length() == 0)
                {
                User::Leave(KErrNotFound);
                }
                
            HBufC8* certificateRequest = 
                iServer.CertificateRequestStore().ReadCertRequestLC(*certRequestRef);
            
            if (aMessage.GetDesMaxLength(1) >= certificateRequest->Length())
                {
                aMessage.WriteL(1, *certificateRequest);
                aMessage.Complete(KErrNone);
                }
            else
                {          
                iRequiredBufferSize = certificateRequest->Length();       
                aMessage.Complete(KPKIErrBufferTooShort);
                }            
            
            CleanupStack::PopAndDestroy(certificateRequest);
            CleanupStack::PopAndDestroy(certRequestRef);            
            
            }
            break;
            
        case PkiService::EDeleteCertificateRequest:
            {
            TInt certRequestRefSize = aMessage.GetDesLength(0);
            HBufC *certRequestRef = HBufC::NewLC(certRequestRefSize);                     
            TPtr certRequestRefPtr = certRequestRef->Des();
            
            aMessage.ReadL(0, certRequestRefPtr);
            
            iServer.CertificateRequestStore().DeleteCertRequestL(*certRequestRef);
            
            CleanupStack::PopAndDestroy(certRequestRef);
            aMessage.Complete(KErrNone);                        
            }
            break;
        case PkiService::ESetCertStoreType:        
            iWrapper->SetCertStoreType(static_cast<TPkiServiceStoreType>(aMessage.Int0()));
            aMessage.Complete(KErrNone);
            break;

        case PkiService::ESetKeyStoreType:  
            SetKeyStoreL(static_cast<TPkiServiceStoreType>(aMessage.Int0()));
            aMessage.Complete(KErrNone);
            break;

        case PkiService::ESetStoreType:
            iWrapper->SetCertStoreType(static_cast<TPkiServiceStoreType>(aMessage.Int0()));
            SetKeyStoreL(static_cast<TPkiServiceStoreType>(aMessage.Int1()));
            aMessage.Complete(KErrNone);
            break;

		case PkiService::EGetCertStoreType:
			{
			Status = iWrapper->CertStoreType();
			aMessage.Complete(Status);
			break;
			}

		case PkiService::EGetKeyStoreType:
			{
			Status = KeyStore();
			aMessage.Complete(Status);
			break;
			}			
			
        case PkiService::ESetInformational:
            {
            iWrapper->SetInformational(aMessage.Int0());
            aMessage.Complete(KErrNone);
            }
            break;
            
        case PkiService::EInitialize://falls through
        case PkiService::EKeyCount: //falls through    		                
        case PkiService::EGetKeyDetails: //falls through    		
        case PkiService::EDecrypt: //falls through    		
        case PkiService::ESignWithKeyId: //falls through    		
        case PkiService::ESignWithCert: //falls through    		
        case PkiService::EReadPublicKey: //falls through    		
        case PkiService::ELogon: //falls through    		
        case PkiService::ELogoff: //falls through    		
        case PkiService::EChangePassword: //falls through    		
        case PkiService::ERemoveKeypair: //falls through    		
        case PkiService::EGenerateKeypair: //falls through    		
        case PkiService::EStoreKeypair: //falls through    		
            iKeyOperationQueue.AddOperationL(*this, aMessage,
                                             iUsedKeyStore, iWrapper->CertStoreType());
            break;  
        default:      
            iRequiredBufferSize = KBufferSizeNotDefined;
            iWrapper->InitOperation(aMessage);
            break;
        }
    }
Example #20
0
RPointerArray<CX509Certificate> PkiUtil::GetCaCertListL(RPKIServiceAPI& aPkiService,
        const CArrayFixFlat<TCertInfo*>& aIkeCAList)
{

    __ASSERT_ALWAYS(aIkeCAList.Count() > 0, User::Invariant());
    _LIT8(KEmptyString, "");

    RPointerArray<CX509Certificate> certificateArray;
    ResetAndDestroyPushL(certificateArray);

    RArray<TUid> applUidArray;
    CleanupClosePushL(applUidArray);

    for (TInt i = 0; i < aIkeCAList.Count(); ++i)
    {
        const TCertInfo* certInfo = aIkeCAList[i];
        switch(certInfo->iFormat)
        {
        case CA_NAME:
        {
            // Reserve enough space for UTF-8
            TInt len = 3*( certInfo->iData.Length() );
            HBufC8* caName = HBufC8::NewLC(len);
            TPtr8 caNamePtr(caName->Des());

            if (CnvUtfConverter::ConvertFromUnicodeToUtf8(caNamePtr, certInfo->iData) != 0)
            {
                User::Leave(KErrCorrupt);
            }

            CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                     KEmptyString,
                                     *caName,
                                     KEmptyString,
                                     EPKICACertificate);

            User::LeaveIfError(certificateArray.Append(cert));
            CleanupStack::Pop(cert);
            CleanupStack::PopAndDestroy(caName);
        }
        break;
        case KEY_ID:
        {
            TPKIKeyIdentifier keyId(NULL);

            for (TInt j = 0; j < certInfo->iData.Length(); j += 2)
            {
                TPtrC hexByte(certInfo->iData.Mid(j, 2));
                TLex lex(hexByte);
                TUint8 value;
                User::LeaveIfError(lex.Val(value, EHex));
                keyId.Append(&value, 1);
            }

            CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                     keyId);
            User::LeaveIfError(certificateArray.Append(cert));
            CleanupStack::Pop(cert);
        }
        break;
        case APPL_UID:
        {
            TLex lex(certInfo->iData);
            TUint32 value;
            User::LeaveIfError(lex.Val(value, EHex));
            TUid id = { value };
            User::LeaveIfError(applUidArray.Append(id));
        }
        break;
        default:
            User::Leave(KErrArgument);
            break;
        }
    }

    if (applUidArray.Count() > 0)
    {
        CArrayFix<TCertificateListEntry>* certListArray = NULL;;
        aPkiService.ListApplicableCertificatesL(applUidArray, certListArray);

        CleanupStack::PushL(certListArray);
        if (certListArray->Count() == 0)
        {
            User::Leave(KErrNotFound);
        }

        for (TInt i = 0; i < certListArray->Count(); ++i)
        {
            TCertificateListEntry entry = (*certListArray)[i];
            if (entry.iOwnerType == EPKICACertificate)
            {
                CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                         KEmptyString,
                                         entry.iIdentitySubjectName,
                                         KEmptyString,
                                         EPKICACertificate);
                User::LeaveIfError(certificateArray.Append(cert));
                CleanupStack::Pop(cert);
            }
        }
        CleanupStack::PopAndDestroy(certListArray);
    }

    CleanupStack::PopAndDestroy(); //applUidArray

    CleanupStack::Pop();
    return certificateArray;
}
void CHuiRasterizedTextMesh::DoBuildL(TInt aRasterizeFlags)
    {
    if(iUsingPreRasterizedMesh)
        {
        return;
        }

    TSize extents(0, 0);
    
    HUI_DEBUG(_L("CHuiRasterizedTextMesh::BuildL() - Updating rasterized text."));

    // This is never NULL during BuildL().
    const TDesC& text = *Text();
    
    // Retrieve the text style used when rasterizing this text mesh.
    THuiTextStyle* textStyle = CHuiStatic::Env().TextStyleManager().TextStyle(iTextStyleId);

    // Retrieve the CFont object used when rasterizing this text mesh.
    CFont* font = textStyle->Font().NearestFontL(iTextMeshScale);

    // Maximum width of a text line in pixels.
    TInt maxWidth = MaxLineWidth();

    TInt startIndex = 0;
    TInt index = 0;
    TInt lineCount = 0;

    CArrayFixFlat<TPtrC>* linePtrs = new (ELeave) CArrayFixFlat<TPtrC>(KLineArrayGranularity);
    CleanupStack::PushL(linePtrs);

    while(startIndex < text.Length())
        {
        /// @todo What is the Symbian way to determine line break chars?
#define HUI_IS_LINE_BREAK(aChar) (aChar == '\n')

        // Find the next logical line.
        while(index < text.Length() && !HUI_IS_LINE_BREAK(text[index]))
            {
            index++;
            }

        TPtrC logicalLine = text.Mid(startIndex, index - startIndex);
        ++index; // Skip the line break.
        startIndex = index;

        switch(LineMode())
            {
            case ELineModeTruncate:
                {
                ++lineCount; // there's always one line created per logical line
                HBufC* buf = logicalLine.AllocLC();
                TPtr ptr = buf->Des();
                // truncate line
                CHuiStatic::ConvertToVisualAndClipL(ptr, *font, maxWidth, maxWidth);
                // create the line entry if not already existing
                
                if (aRasterizeFlags != ERasterizeNone)
                	{
                    if (iLines.Count() < lineCount)
                        {
                        SRasterizedLine line;
                        line.iTexture = NULL;
                        line.iGap = 0;
                        iLines.AppendL(line);
                        
                        if (iPictographInterface)
                            {
                            SRasterizedLine pictographline;
                            pictographline.iTexture = NULL;
                            pictographline.iGap = 0;
                            iPictographLines.AppendL(pictographline);                                
                            }
                        }                	
                        
                	TInt currentLine = lineCount-1;
    	            if (aRasterizeFlags & ERasterizeText)
    	                {
    	                // rasterize a single line (updates texture in iLines[0].iTexture)
        	            RasterizeLineL(ptr, iLines[currentLine]);	                    
    	                }

    	            if (aRasterizeFlags & ERasterizePictographs && iPictographInterface)
    	                {
                        // Rasterize pictographs if needed
        	            RasterizePictographLineL(ptr, font, iPictographLines[currentLine]);
    	                }

    	            // Get extents from the texture we just created
                    CHuiTexture* tex = iLines[currentLine].iTexture;
                    extents.iHeight += iLines[currentLine].iGap;
                    if(tex)
                        {
                        extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                        extents.iHeight += tex->Size().iHeight;
                        }	                
                	}
                else
                    {
                    // Don't rasterise or create textures, just get the extents of this text.
                    TSize lineExtents = textStyle->LineExtentsL(ptr);
                    extents.iWidth = Max(extents.iWidth, lineExtents.iWidth);
                    extents.iHeight += lineExtents.iHeight;                    
                    }

                	
        	    CleanupStack::PopAndDestroy(buf);
                break;
                }

            case ELineModeWrap:
                {
                // wrap lines to array
                HBufC* buf = CHuiStatic::ConvertToVisualAndWrapToArrayL(
                    logicalLine, maxWidth, *font, *linePtrs);
                CleanupStack::PushL(buf);

                // one line may create several wrapped lines
                lineCount += linePtrs->Count();

                if (aRasterizeFlags != ERasterizeNone)
                  	{    

                    // create new entries..
                    while (iLines.Count() < lineCount)
                        {
                        SRasterizedLine line;
                        line.iTexture = NULL;
                        line.iGap = 0;
                        iLines.AppendL(line);

                        if (iPictographInterface)
                            {
                            SRasterizedLine pictographline;
                            pictographline.iTexture = NULL;
                            pictographline.iGap = 0;
                            iPictographLines.AppendL(pictographline);                                
                            }
                        }
                    
                   	// Do rasterisation if we want to render to texture.
                    for(TInt i = 0; i < linePtrs->Count(); ++i)
                        {
                        TInt currentLine = (lineCount - linePtrs->Count()) + i;   
          	   	                
    	                if (aRasterizeFlags & ERasterizeText)
    	                    {
                            // rasterize a single line (updates texture in iLines[i].iTexture)
                            RasterizeLineL(linePtrs->At(i), iLines[currentLine]);
    	                    }
    	                    
	                    if (aRasterizeFlags & ERasterizePictographs && iPictographInterface)
	                        {
                            // Rasterize pictographs if needed
                            RasterizePictographLineL(linePtrs->At(i), font, iPictographLines[currentLine]);                                                                 	                            
	                        }
           	                // Get extents from the texture we just created
                            CHuiTexture* tex = iLines[i].iTexture;
                            extents.iHeight += iLines[i].iGap;
                            
                            if(tex)
                                {
                                extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                                extents.iHeight += tex->Size().iHeight;
                                }    
                            	                                                         
    	                TBool moreAvailable = (currentLine + 1 < MaxLineCount());
                        if (!moreAvailable)
          	                {
       	                    // Maximum number of lines reached.
       	                    break;
       	                    }
                        }
                  	}
   	            else
   	                {
                    // Don't rasterise or create textures, just get the extents of this text.   	                    
                    for(TInt i = 0; i < linePtrs->Count(); ++i)
                        {  
                        TSize lineExtents = textStyle->LineExtentsL(linePtrs->At(i));
                        extents.iWidth = Max(extents.iWidth, lineExtents.iWidth);
                        extents.iHeight += lineExtents.iHeight;                                                              
                        }
       	            }
                	
                linePtrs->Reset();
                CleanupStack::PopAndDestroy(buf);
                break;
                }

            default:
                break;
            }

        // If we have reached the maximum number of lines, stop building.
        if(IsMaxLineCountReached())
            {
            break;
            }
        }

    HUI_DEBUG(_L("CHuiRasterizedTextMesh::BuildL() - Finished rasterizing text."));

    CleanupStack::PopAndDestroy(linePtrs); linePtrs = 0;

    if (iPictographBitmap)
        {
        iPictographBitmap->Resize(TSize(0, 0));
        }

    HUI_DEBUG(_L("CHuiRasterizedTextMesh::BuildL() - Updating text extents.."));
    // The extents of the mesh depend on how many lines there are.
    SetExtents(extents);

    HUI_DEBUG(_L("CHuiRasterizedTextMesh::BuildL() - Done!"));

    }
TPtrC16 CContextMediaArrayImpl::MdcaPoint(TInt aIndex) const
{
	CALLSTACKITEM_N(_CL("CContextMediaArrayImpl"), _CL("MdcaPoint"));

	if (aIndex>iPostArray->Count()) {
		User::Leave(KErrArgument);
	}

	if (!iStandAlone) {
		// ----- case first item in list ---------
		if (aIndex == 0) {
			if (iItem == EUseVCode) {
				iBuf->Des().Zero();
				iBuf->Des().AppendFormat(_L("%d\t"), KUseCodeIconIndex);
				iBuf->Des().Append(*iUseCode);
				iBuf->Des().Append(_L("\t\t\t"));
				return iBuf->Des();
			} else if (iItem == EAddReply) {
				iBuf->Des().Zero();
				if (iPostArray->Count()==0) {
					iBuf->Des().AppendFormat(_L("%d\t"), KReplyIconIndex);
					iBuf->Des().Append(*iFirstPost);
					iBuf->Des().Append(_L("\t\t\t"));
				} else {
					iBuf->Des().AppendFormat(_L("%d\t"), KReplyIconIndex);
					iBuf->Des().Append(*iAddReply);
					iBuf->Des().Append(_L("\t\t\t"));
				}
				return iBuf->Des();
			}
		}

	}

	// ---- normal case --------------------
	if (iOrder==CPostStorage::EDescending) {
		aIndex=MdcaCount()-aIndex-1;
	}
	if (iPostArray->At(aIndex) == 0) {
		iPostArray->At(aIndex) = iStorage.GetByPostIdL(0, iPostIdArray->At(aIndex));
	}
	
	iBuf->Des().Zero();
	const CCMPost * aPost = (*iPostArray)[aIndex];

	if (!iStandAlone) {
		TInt iconidx=aPost->GetThumbnailIndex();
		if (iconidx<0) iconidx=KUnknownIconIndex;
		
		if (aPost->iBodyText->Value().Compare(*iLoading) == 0) {
			iconidx = KUnknownIconIndex;
		} else if (aPost->iBodyText->Value().Compare(*iError)==0) {
			iconidx=KErrorIconIndex;
		}

		// First Line of the list box: icon_id, title, nb_unread
		iBuf->Des().AppendFormat(_L("%d\t"), iconidx);
	}

	// Loading indicator for thread ...
	TInt64 id = iPostIdArray->At(aIndex);
	TBool loading = ( (iNode == CPostStorage::RootId()) && 
		( (iNetwork.GetFetchStatus(id)==MNetworkStatus::EConnecting) ||
		(iNetwork.GetFetchStatus(id)==MNetworkStatus::EFetching) ) );
	if (loading) {
		if (aPost->iBodyText->Value().Length() == 0) {
			iBuf->Des().Append(*iNoTitle);
		} else {
			iBuf->Des().Append(aPost->iBodyText->Value().Left(15));
		}
		TTime now; now=GetTime(); 
		TInt sec = now.DateTime().Second();
		TInt dots = 6;
		TInt nb_dots = sec - ( dots*int(sec/dots));
		for (int i=0; i<=nb_dots; i++) {
			iBuf->Des().Append(_L("."));
		}
		iObserver.PostEvent(0, 0, EPostUpdated);
	} else {
		if (aPost->iBodyText->Value().Length() == 0) {
			iBuf->Des().Append(*iNoTitle);
		} else {
			iBuf->Des().Append(aPost->iBodyText->Value().Left(40));
		}
	}

	iBuf->Des().Append(_L("\t"));
	TInt unread = aPost->iUnreadCounter();
	if (unread>0) {
		iBuf->Des().AppendNum(unread );
	}

	if (! iStandAlone) {
		iBuf->Des().Append(_L("\t"));
	// Second and third Lines of the listbox
		if (aPost->iSender.iName().Compare(_L("?")) == 0) {
			iBuf->Des().Append(_L(" \t \t \t"));
		} else {
			if (iNode==CPostStorage::RootId()) {
				// second line
				iBuf->Des().Append(*iFirstBy);
				iBuf->Des().Append(_L(" "));
				iBuf->Des().Append(aPost->iSender.iName());
				iBuf->Des().Append(_L(",\t"));
				TBuf<5> time; GetTimeString(aPost->iTimeStamp(), time);
				iBuf->Des().Append(time);
				//third line
				if (aPost->LastPostAuthor().Length()==0)  {
					iBuf->Des().Append(_L("\t\t"));
				} else {
					iBuf->Des().Append(_L("\t"));
					iBuf->Des().Append(*iLastBy);
					iBuf->Des().Append(_L(" "));
					iBuf->Des().Append(aPost->LastPostAuthor());
					iBuf->Des().Append(_L(",\t"));
					GetTimeString(aPost->LastPostDate(), time);
					iBuf->Des().Append(time);
				}
			} else {
				// second line
				iBuf->Des().Append(*iBy);
				iBuf->Des().Append(_L(" "));
				iBuf->Des().Append(aPost->iSender.iName());
				iBuf->Des().Append(_L(",\t"));
				TBuf<5> time; GetTimeString(aPost->iTimeStamp(), time);
				iBuf->Des().Append(time);
				// third line
				iBuf->Des().Append(_L("\t\t"));
			}
		}
	}
#ifdef __WINS__
	RDebug::Print(iBuf->Des());
#endif
	return iBuf->Des();
}
/** This user-side method configures the passed ULogger session to output to the passed plugin (with configurations) and with filter settings as specified by the user
    and starts the session in order to output trace points.
@param aLogger is ULogger session being passed to the routine to be configured and started
@param aPluginName is the TPtrC8 passed, identifying which ULogger plugin to output to
@param aPluginConfiguration is the TPluginConfiguration passed, indicating the hardware configurations for the specified plugin
@param aTestUTraceULoggerMatch is the user-defined boolean specifying whether the Ulogger filter settings should match the (test-specific) trace points or not
@return KErrNone if command was prepared correctly and a system wide error code otherwise.
 */
TInt CUptULogger::StartGeneralL(RULogger& aLogger, const TPtrC8& aPluginName, const TPluginConfiguration& aPluginConfiguration, const TBool& aGroupIdFiltering, const TBool& aComponentIdFiltering, const TBool& aGroupIdFilterMatch, const TBool& aComponentIdFilterMatch)
	{
	TInt err=0;
	
	//connect to the ULogger session
	err=aLogger.Connect();
	
    if (err!=KErrNone)
        {
        for (TInt i=2; i<12;i++)
            {
            User::After(1000);
            err = aLogger.Connect();
            if (err==KErrNone)
                {
                break;
                }
            }
        }
	
	//clear any configurations stored in the ULogger configuration file
	CClearConfig configIni;
	configIni.ClearL(aLogger);
	
	//prepare arrays for storing the filter settings to configure ULogger (and push any heap objects on the cleanup stack)
	CArrayFixFlat<TUint8> *setPrimFilter = new (ELeave)CArrayFixFlat<TUint8>(256);
	CleanupStack::PushL(setPrimFilter);
	RArray<TUint32> setSecondFilter;
	CleanupClosePushL(setSecondFilter);
	//now configure the filtering and filter match options according to the passed parameters:
	//aGroupIdFiltering aComponentIdFiltering aGroupIdFilterMatch aComponentIdFilterMatch	

	if(aGroupIdFiltering==1)
	    {
	    //We might have previously "disabled" primary filtering by enabling all filter
	    //values, we'll disable them all here initially and then enable what we want below
        TInt i;
        for (i=0;i<=255;i++)
            {
            setPrimFilter->AppendL((TUint8)i);
            }
        TInt err=aLogger.SetPrimaryFiltersEnabled(*setPrimFilter,EFalse);
        setPrimFilter->Delete(0,setPrimFilter->Count());
	    }
		//C.A. previously this but done by default:err=aLogger.EnableGroupIdFiltering();
	else
		//C.A. previously:err=aLogger.DisableClassificationFiltering();
		//C.A.: just enable all classifications so all is allowed through
		{
		TInt i;
		for (i=0;i<=255;i++)
			{
			setPrimFilter->AppendL((TUint8)i);
			}
		TInt err=aLogger.SetPrimaryFiltersEnabled(*setPrimFilter,ETrue);
		setPrimFilter->Delete(0,setPrimFilter->Count());
		}

	err=aLogger.SetSecondaryFilteringEnabled(aComponentIdFiltering);
//	C.A. previously	
/*	if(aComponentIdFiltering==1)
		err=aLogger.EnableModuleUidFiltering();
	else
		err=aLogger.DisableModuleUidFiltering();*/
	
	if(aGroupIdFilterMatch==1)
		{
		//if the user specifies that ULogger should have classifiaction filter settings which match the test trace points, then fill the filter arrays with the test trace point identifiers accordingly
		SetFilterL(setPrimFilter);		
		}
	else
		{
		//if the user specifies that ULogger should have classifciation filter settings which dont match the test trace points, then fill the filter arrays with the trace point identifiers which differ from the test trace point identifiers
		setPrimFilter->AppendL((TGroupId)(KGroupId+1));
		}
	
	if(aComponentIdFilterMatch==1)
			{
			//if the user specifies that ULogger should have module id filter settings which match the test trace points, then fill the filter arrays with the test trace point identifiers accordingly
			setSecondFilter.Append((TComponentId) KComponentId);
			}
		else
			{
			//if the user specifies that ULogger should have module id settings which dont match the test trace points, then fill the filter arrays with the trace point identifiers which differ from the test trace point identifiers
			setSecondFilter.Append((TComponentId) (KComponentId+1));
			}

	//set the filter settings in ULogger according to the above defined filter arrays
	err=aLogger.SetPrimaryFiltersEnabled(*setPrimFilter,ETrue);//C.A. previously:err=aLogger.EnableClassifications(*setPrimFilter);
	if(err==0)
		err=aLogger.SetSecondaryFiltersEnabled(setSecondFilter,ETrue);//C.A. previously:err=aLogger.EnableModuleUids(setSecondFilter);
	
	
	if(err==0)	
		{
		//now set the ULogger session to output to the specified plugin and configuration
		err=aLogger.ActivateOutputPlugin(aPluginName);//C.A. previously:err=aLogger.SetActiveOutputPlugin(aPluginName);
	
		if((err == KErrNone)/*Added*/||(err == KErrAlreadyExists))//C.A. have to add cuz old api returns -11 if plugin already activated
			{
			err=aLogger.SetPluginConfigurations(aPluginName, aPluginConfiguration);
			if(err==0)
				{
				//given the ULogger session has successfully been configured to output to the default file, start the session
				err=aLogger.Start();//C.A. previously:err=aLogger.StartOutputting();
				}
			}
		}
	
	//cleanup any heap objects

	CleanupStack::PopAndDestroy(&setSecondFilter);	
	CleanupStack::PopAndDestroy(setPrimFilter);
	
	return err;
	}
Example #24
0
TBool Ikev2MobIke::ProcessNotifysL(CIkev2Negotiation* aNegotiation, 
                                   const CArrayFixFlat<TNotifPayloadIkev2*>& aNotifys, 
                                   TBool aRequest, TInt aExchange)
{
    __ASSERT_DEBUG(aNegotiation, User::Invariant());
	if ( !aNegotiation->iHdr.iIkeData->iUseMobIke )
	{
		return EFalse; 
	}
	 
	TInt MsgType;
	TNotifPayloadIkev2* Payload;
	TPtrC8 Cookie2(NULL,0);
	TBool  NatDetection = EFalse;
	TBool  Status        = EFalse;
	TInt   Count = aNotifys.Count();
	TInt i      = 0;

	while ( i < Count )
	{
		
		Payload = aNotifys.At(i);
		MsgType = (TInt)Payload->GetMsgType();
		// 
		//  Process possible MOBIKE Notify messages 
		//
		switch ( MsgType )
		{

			case MOBIKE_SUPPORTED:
				//
				// Remote end supports MOBIKE protocol
				//
			    aNegotiation->iHdr.iMobikeUsed  = ETrue;
			    aNegotiation->iHdr.iFloatedPort = ETrue;  // Floated port used for now 			
			    aNegotiation->iHdr.iDestinAddr.SetPort(FLOATED_IKE_PORT);			
				break;

			case ADDITIONAL_IPV4_ADDRESS:
			case ADDITIONAL_IPV6_ADDRESS:				
				//
				// Additional IP addresses Notify
				//
				if ( aNegotiation->iHdr.iMobikeUsed && (aExchange == INFORMATIONAL) )
				{
					Status = ETrue;		
				}	
				break;

			case UPDATE_SA_ADDRESS:
				//
				// Peer informs about the IP address change
				//
				if ( aNegotiation->iHdr.iMobikeUsed && aRequest && (aExchange == INFORMATIONAL) )
				{
					aNegotiation->iIkeV2PlugInSession.RemoteAddrChanged(&aNegotiation->iHdr, aNegotiation->iHdr.iDestinAddr); 		
					Status = ETrue;		
				}	
				break;

			case COOKIE2:
				//
				// Peer informs about the IP address change
				//
				if ( aNegotiation->iHdr.iMobikeUsed && aRequest && (aExchange == INFORMATIONAL) )
				{
					Cookie2.Set(Payload->NotifData(), Payload->NotifDataLength());
					Status = ETrue;		
				}	
				break;

			case NAT_PREVENTION:
				//
				// NAT Prevention Notify
				//
				if ( aNegotiation->iHdr.iMobikeUsed  )
				{
					if ( aExchange == INFORMATIONAL ) 
					   Status = ETrue;		
				}	
				break;

			case UNACCPETABLE_ADDRESSES:
			case NAT_PREVENTED:
				if ( aNegotiation->iHdr.iMobikeUsed  )
				{					
					if ( aExchange == INFORMATIONAL ) 
					   Status = ETrue;		
				}	
				break;

			case NAT_DETECTION_SOURCE_IP:
			case NAT_DETECTION_DESTINATION_IP:
				if ( aNegotiation->iHdr.iMobikeUsed && (aExchange == INFORMATIONAL))
				{
					NatDetection = ETrue;		
					Status = ETrue;		
				}	
				break;
				
			default:
				break;
		}	

		i ++;   
	}

	if ( Status && aRequest && (aExchange == INFORMATIONAL) )
	{
	    //
	    // Build informational response to MOBIKE request
	    //                
        CIkeV2Message* ikeMsg = CIkeV2Message::NewL(aNegotiation->iHdr.SpiI(),
                                                    aNegotiation->iHdr.SpiR(),
                                                    INFORMATIONAL,
                                                    aNegotiation->iHdr.iInitiator, 
                                                    ETrue,
                                                    aNegotiation->iHdr.ExpectedRequestId(),
                                                    aNegotiation->iDebug);
        
        ikeMsg->AppendEncryptedPayloadL(aNegotiation->iHdr.iCipherBlkLth);            
        
	    if ( Cookie2.Ptr() )
		{
            //
            // Peer is using COOKIE2. Return COOKIE2 payload data as such 
            //		
            ikeMsg->AppendNotifyPayloadL(IKEV2_PROTOCOL, KZeroDesc, COOKIE, Cookie2);
		}
		if ( NatDetection )
		{
		   //
		   // Peer is using NAT_DETECTION_*_IP payloads. Build corresponding response
		   //
			TBool NatDetectOk;
			TInetAddr DummyIp;
			DummyIp.SetAddress(KInetAddrNone);   // 0.0.0.0
			TUint32 NATFlags = CIkev2NatT::CheckPeerNotifysL(aNotifys, DummyIp, aNegotiation->iHdr.iDestinAddr, FLOATED_IKE_PORT,
				                                             ikeMsg->InitiatorSpi(), ikeMsg->ResponderSpi(), 
				                                             NatDetectOk);
			if ( NatDetectOk )
			{
			   aNegotiation->iHdr.iNATFlags = NATFlags;
			   aNegotiation->GetNatStatus(NatDetectOk, aNegotiation->iHdr.iDestinAddr);				   
			}	
			CIkev2NatT* NatNotify = CIkev2NatT::NewL(DummyIp, aNegotiation->iHdr.iDestinAddr, 
                                                     FLOATED_IKE_PORT, 
                                                     ikeMsg->InitiatorSpi(), ikeMsg->ResponderSpi());
			CleanupStack::PushL(NatNotify);
                       
           ikeMsg->AppendNotifyPayloadL(IKEV2_PROTOCOL, KZeroDesc, NAT_DETECTION_SOURCE_IP, 
                                        NatNotify->SourceNofify());
           ikeMsg->AppendNotifyPayloadL(IKEV2_PROTOCOL, KZeroDesc, NAT_DETECTION_DESTINATION_IP, 
                                        NatNotify->DestinNofify());
														
			CleanupStack::PopAndDestroy(NatNotify); 			 				   			   				
		}				
		
		aNegotiation->SendIkeMsgL(ikeMsg);
		aNegotiation->iIkeV2PlugInSession.UpdateIkev2SAL(&aNegotiation->iHdr, NULL);
		if ( (aNegotiation->iState != KStateIkeInfoRequest) && (aNegotiation->iState != KStateIkeDeleteRequest) && (aNegotiation->iState != KStateIkeDeleteResponse) )
		   aNegotiation->iState = KStateIkeSaCompleted;
	}
   //	
   // else
   // Currently there is no need to examine any MOBIKE Notify payloads
   // present in Informational response
   //

	return Status;
}
/**
Persist the items belonging to curent group into group table

@param aGroup referece to a contact group
*/
void CPplGroupsTable::WriteGroupMembersL(const CContactItem& aGroup)
	{
	if (aGroup.Type() != KUidContactGroup)
		{
		return;
		}

	const TContactItemId KGroupId(aGroup.Id() );

	// make sure we clear out any previous, out-of-date data
	TBool lowDiskErr(EFalse);
	DeleteItemL(KGroupId, lowDiskErr);
	if (lowDiskErr)
		{
		User::Leave(KErrDiskFull);
		}

	// build the RSqlStatement
	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
	stmnt.PrepareL(iDatabase, iInsertStmnt->SqlStringL() );
	const TInt KGroupIdIndex(KFirstIndex); 			// first parameter in query...	
	const TInt KMemberIdIndex(KGroupIdIndex + 1); 	// ...and the second parameter
	
	// copy and sort the member id array so we can see if there are duplicates
	const CContactIdArray* contactIdArray = static_cast<const CContactGroup&>(aGroup).ItemsContained();  //does not take the ownership
	
	const TInt arrayCount = contactIdArray->Count();
	CArrayFixFlat<TContactItemId>* sortedList = new(ELeave) CArrayFixFlat<TContactItemId>(KArrayGranularity);	
	CleanupStack::PushL(sortedList);
    for(TInt loop = 0;loop < arrayCount; ++loop)
    	{
    	sortedList->AppendL((*contactIdArray)[loop]);		
    	}
	TKeyArrayFix key(0,ECmpTInt);
	sortedList->Sort(key);

	// insert the group-member relationships
	const TInt KCountStmntParamIndex(KFirstIndex); // first and only parameter in query
	const TInt listLen(sortedList->Count() );
	TInt lastId(0);
	for (TInt i = 0; i < listLen; ++i)
		{
		TInt itemId((*sortedList)[i]);
		
		//check if a contact item with itemId id really exists in contact database
		RSqlStatement countStmnt;
		CleanupClosePushL(countStmnt);
		countStmnt.PrepareL(iDatabase, iCountContactsStmnt->SqlStringL() );
		User::LeaveIfError(countStmnt.BindInt(KCountStmntParamIndex, itemId) );
		TInt count = 0;
		TInt err = KErrNone;
		if((err = countStmnt.Next() ) == KSqlAtRow)
			{
			count = countStmnt.ColumnInt(iCountContactsStmnt->ParameterIndex(KSqlCount) );
			}
		else
			{
			User::LeaveIfError(err);	
			}	

		if(count == 0) 
			{
			User::Leave(KErrNotFound);	
			}
		CleanupStack::PopAndDestroy(&countStmnt);
			
		// only insert this if we haven't already seen it
		if (itemId != lastId || i == 0)
			{
			User::LeaveIfError(stmnt.BindInt(KGroupIdIndex, KGroupId) );
			User::LeaveIfError(stmnt.BindInt(KMemberIdIndex, itemId) );
			User::LeaveIfError(stmnt.Exec() );
			User::LeaveIfError(stmnt.Reset() );
			}
		lastId = itemId;
		}

	CleanupStack::PopAndDestroy(2, &stmnt); // and sortedList
	}
// Each test step must supply a implementation for doTestStepL
enum TVerdict CTestAppLoaderEndTask::doTestStepL( void )
	{
	// Printing to the console and log file
	INFO_PRINTF1(_L("TEST-> END TASK"));

	TPtrC	program;
	if ( !GetStringFromConfig(ConfigSection(), KProgram, program) )
		{
		ERR_PRINTF2(KErrMissingParameter, &KProgram());
		SetTestStepResult(EFail);
		}
	else
		{
		RApaLsSession	apaLsSession;
		User::LeaveIfError(apaLsSession.Connect());
		CleanupClosePushL(apaLsSession);
	    User::LeaveIfError(apaLsSession.GetAllApps());

		RWsSession	ws;
		User::LeaveIfError(ws.Connect());
		CleanupClosePushL(ws);
		
	    TInt					numWindowGroups = ws.NumWindowGroups();
	    CArrayFixFlat<TInt>*	windowGroupList = new(ELeave) CArrayFixFlat<TInt>(numWindowGroups);
	    CleanupStack::PushL(windowGroupList);

	    // Populate array with current group list ids
	    User::LeaveIfError(ws.WindowGroupList(windowGroupList));

	    CApaWindowGroupName*	windowGroupName = CApaWindowGroupName::NewLC(ws);

	    /* Note: we use windowGroupList->Count() instead of numWindowGroups, as in the middle of the
	     * update the list could change in length (or worse, be reduced) thus producing an out of bounds
	     * error if numWindowGroups were used
	     */
	    TBool	searching=ETrue;
	    for ( TInt i=0; (i<windowGroupList->Count()) && searching; ++i )
	    	{
	        TInt	wgId = windowGroupList->At(i);
	        windowGroupName->ConstructFromWgIdL(wgId);

	        TUid	appUid = windowGroupName->AppUid();

	        TApaAppInfo	appInfo;
	        HBufC* 		appCaption = NULL;
	        // Some applications, like midlets, may not provide any info
	        if (apaLsSession.GetAppInfo(appInfo, appUid) == KErrNone)
	        	{
	            appCaption = appInfo.iCaption.AllocL();
	        	}
	        else
	        	{
	            appCaption = windowGroupName->Caption().AllocL();
	        	}
            CleanupStack::PushL(appCaption);

	        // Only list 'visible' applications
	        if ( appCaption->Length() )
	        	{
	            TPtrC	caption=*appCaption;
		        INFO_PRINTF2(KLogTask, &caption);

		        if ( program.CompareC(caption)==0 )
		        	{
					searching=EFalse;
					TApaTask	task(ws);
					task.SetWgId(wgId);
					if (task.Exists())
						{
						task.EndTask();
						}
					else
						{
						ERR_PRINTF2(KErrTaskNotFound, &program);
						SetTestStepResult(EFail);
						}
		        	}
				}
            CleanupStack::Pop(1, appCaption); // taskEntry, appCaption
	    	}

	    if ( searching )
	    	{
			ERR_PRINTF2(KErrTaskNotFound, &program);
			SetTestStepResult(EFail);
	    	}
	    CleanupStack::PopAndDestroy(4, &apaLsSession);    // windowGroupName, windowGroupList
		}

	// test steps return a result
	return TestStepResult();
	}
Example #27
0
/**
  @SYMTestCaseID APPFWK-APPARC-0070
 
  @SYMPREQ
 
  @SYMTestCaseDesc Test whether the default app icons change with respect to the locale/language.
  This testcase checks whether BaflUtils::NearestLanguageFile is called when the locale has been changed.
 
  @SYMTestPriority High  
 
  @SYMTestStatus Implemented

  @SYMTestActions  Call User::Language() to check that the default locale is English; Call CT_LocaleStep::CheckIcons 
  to check the size of the current default icons; Call UserSvr::ChangeLocale to change the Locale to French; 
  Call CT_LocaleStep::CheckIcons to check the size of the new icons; Restore the file system and the locale 
  and check if the icons are restored.
  API Calls:\n	
  
  @SYMTestExpectedResults Returns KErrNone
 */	
void CT_LocaleStep::TestLocaleDefaultIconL()
	{
	INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL started..."));	
	
	TInt ret = 0;
		
	//first checks that language is not currently set to French (any other language except English since English is the default language
	TEST(User::Language()!=ELangFrench);

	// getappiconsizes must be called to check if the icons are the default ones
	// KUidCustomiseDefaultIconApp - uid of CustomiseDefaultIconApp_reg.RSS; this app has a localisable resource file, CustomiseDefaultIconApp_loc.RSS, that does not define any icon
	// Hence, the default icons must be picked up when the language changes to French. The default icons for French are defined in default_app_icon.m02

	CArrayFixFlat<TSize>* newIconSizes = new(ELeave) CArrayFixFlat<TSize>(3);
	CleanupStack::PushL(newIconSizes);
	TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes));
	TEST(ret==KErrNone);
	TEST(newIconSizes->Count()!=0);
	// these are the sizes of the default icons
	TSize small(24,24);
	TSize medium(32,32);
	TSize large(48,48);
	TSize fstIcon;
	TSize secIcon;
	TSize trdIcon;
	CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon);
	
	// Change the locale to French
	TRAP(ret,ChangeLocaleL(ELangFrench));
	TEST(ret==KErrNone);
	TEST(User::Language()==ELangFrench);//checks that the language has been set to French

	//Wait for a small period to let apparc receive language change notification
	User::After(KDelayForOnDemand);
	//call getappiconsizes to see if the new icons have been changed as as expected 
	// The size of the icons indicates whether the icon corresponding to French Locale has been picked up
	newIconSizes->Reset();
	TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes));
	TEST(ret==KErrNone);
	TEST(newIconSizes->Count()!=0);
	small.SetSize(25,25);
	medium.SetSize(35,35);
	large.SetSize(50,50);
	CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon);

	//have to restore the locale before exiting the testcase
	TRAP(ret,ChangeLocaleL(ELangEnglish));
	TEST(ret==KErrNone);
	TEST(User::Language()==ELangEnglish);

	//Again wait for a small period to let apparc receive language change notification
	User::After(KDelayForOnDemand);

	//call getappiconsizes to see if the new icons have been changed as as expected 
	// The size of the icons indicates whether the icon corresponding to English Locale has been picked up
	newIconSizes->Reset();
	TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes));
	TEST(ret==KErrNone);
	TEST(newIconSizes->Count()!=0);
	small.SetSize(24,24);
	medium.SetSize(32,32);
	large.SetSize(48,48);
	CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon);

	// Icon cleanup
	CleanupStack::PopAndDestroy(newIconSizes);
	newIconSizes=NULL;
	INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL finished..."));	
	}
void CMsvScheduleSend::CreateScheduleL(const TTime& aTime, const TTimeIntervalMinutes& aValidityPeriod, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef)
	{
	if( aPendingConditions )
		{
		CreateScheduleL(iScheduler, aSchConditions, aTime, aRef);
	#ifndef _MSG_NO_LOGGING
		TBuf<32> bufDate;
		aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B"));
		SCHSENDLOG(FLog(_L("\tCreated Schedule %d for pending %d conditions or %S"), aRef.iHandle, aSchConditions.Count(), &bufDate));
	#endif		
		}
	else
		{		
		CreateScheduleL(iScheduler, *iSettings, aTime, aValidityPeriod, aRef);
	#ifndef _MSG_NO_LOGGING
		TBuf<32> bufDate;
		aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B"));
		SCHSENDLOG(FLog(_L("\tCreated Schedule %d for %S"), aRef.iHandle, &bufDate));
	#endif
		}
	}
Example #29
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CMainContainer::HandlePopUpMenuSelectionL(TInt& aCommand)
{
	TBool ret(EFalse);
	
	TBool isEnable(EFalse),isDisable(EFalse),isRemove(EFalse),isaPreview(EFalse);
	ShowMenuItemsL(isEnable,isDisable,isRemove,isaPreview);
	
	if(!isRemove && !isaPreview){
		ret = ETrue;
		aCommand = EProfModify;
	}else{
	
		TBuf<100> hjelpper;
		CAknSinglePopupMenuStyleListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox;
		CleanupStack::PushL(list);
	
		CAknPopupList* popupList = CAknPopupList::NewL(list,R_AVKON_SOFTKEYS_OK_CANCEL);
		CleanupStack::PushL(popupList);
	
		list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
		list->CreateScrollBarFrameL(ETrue);
		list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
	
		CArrayFixFlat<TInt>* cmdArray = new (ELeave) CArrayFixFlat<TInt>(5);
		CleanupStack::PushL(cmdArray);
		CDesCArrayFlat* Array = new (ELeave) CDesCArrayFlat(5);
		CleanupStack::PushL(Array);

		if(isEnable){
			StringLoader::Load(hjelpper,R_CMD_ENABLE);
			Array->AppendL(hjelpper);
			cmdArray->AppendL(EProfEnable);
		}else if(isDisable){
			StringLoader::Load(hjelpper,R_CMD_DISABLE);
			Array->AppendL(hjelpper);
			cmdArray->AppendL(EProfDisable);
		}
		
		if(isaPreview && !iDimPreview){
			StringLoader::Load(hjelpper,R_CMD_MODIFY);
			Array->AppendL(hjelpper);
			cmdArray->AppendL(EProfModify);
	
			StringLoader::Load(hjelpper,R_CMD_PREVIEW);
			Array->AppendL(hjelpper);
			cmdArray->AppendL(EProfTest);		
		}

		if(isRemove){
			StringLoader::Load(hjelpper,R_CMD_DELETE);
			Array->AppendL(hjelpper);
			cmdArray->AppendL(EProfRemove);		
		}

		list->Model()->SetItemTextArray(Array);
		CleanupStack::Pop();//Array
		list->Model()->SetOwnershipType(ELbmOwnsItemArray);
	
		if (popupList->ExecuteLD())
		{
			TInt Selected = list->CurrentItemIndex();
			if(Selected >= 0 && Selected < cmdArray->Count())
			{
				ret = ETrue;
				aCommand = cmdArray->At(Selected);
			}
		}
	
		CleanupStack::PopAndDestroy(1); // cmdArray
		CleanupStack::Pop();            // popuplist
		CleanupStack::PopAndDestroy(1); // list
	}
	
	return ret;
}
    void DoBuildL(CAlfTextStyle* aTextStyle)
        {
        ResetLines();
        
        TSize extents(0, 0);
        const TDesC& text = iVisual->Text();
        
        // Retrieve the CFont object used when rasterizing this text mesh.
        CFont* font = aTextStyle->Font()->NearestFontL(1.0);

        // In wrapping mode, let the mesh know how much space there is
        // for drawing into.
        TInt maxWidth = iMaxWidth; //KMaxTInt;
        TInt lineCount = 0;

        // awkward, just to avoid warning
        CArrayFixFlat<TPtrC>* linePtrs = 0;
        HBufC* buf = 0;

        switch(iVisual->Wrapping())
            {
            case CAlfTextVisual::ELineWrapManual:
                {
                lineCount = 1;
                for (TInt i = text.Length()-2;i>=0;i--) // linebreak as last character is ignored
                    {
                    if (text[i]=='\n') // not elegant but keeps the compatibility
                        lineCount++;
                    }
                if (lineCount > 1)
                    {
                    TInt lineStart = 0;
                    TInt breakpos = 0;
                    TInt remaining = text.Length();                    
                    while(lineCount)
                        {
                        for (TInt i = lineStart; i<remaining ;i++)
                            {
                            if (text[i]=='\n') // not elegant but keeps the compatibility
                                {
                                breakpos = i;
                                break;
                                }
                            }
                            if (breakpos < lineStart) // not found
                                {
                                breakpos = remaining-1;
                                }
                                
                            HBufC* buf = text.Mid(lineStart,breakpos-lineStart).AllocLC(); // todo.. is extra space required for bidi
                            lineStart = breakpos+1;
                            TPtr ptr = buf->Des();
                            // truncate line
                            AknBidiTextUtils::ConvertToVisualAndClipL(ptr, *font, maxWidth, maxWidth);
                            // create the line entry if not already existing

                            SRasterizedLine line;
                            line.iTexture = NULL;
                            line.iGap = 0;
                            iLines.AppendL(line);
                        
                            TInt index = iLines.Count()-1;
                            // rasterize a single line (updates texture in iLines[0].iTexture)
                            RasterizeLineL(ptr, iLines[index], aTextStyle);                     

                            // Get extents from the texture we just created
                            CAlfTexture* tex = iLines[index].iTexture;
                            extents.iHeight += iLines[index].iGap;
                            if(tex)
                                {
                                extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                                extents.iHeight += tex->Size().iHeight;
                                }                   
                    
                            CleanupStack::PopAndDestroy(buf);
                            lineCount--;
                            }
                        break;
                        }
                    } // fall through with single line
            case CAlfTextVisual::ELineWrapTruncate:
                {
                lineCount = 1; // there's always one line created per logical line
                HBufC* buf = text.AllocLC(); // todo.. is extra space required for bidi
                TPtr ptr = buf->Des();
                // truncate line
                AknBidiTextUtils::ConvertToVisualAndClipL(ptr, *font, maxWidth, maxWidth);
                // create the line entry if not already existing

                SRasterizedLine line;
                line.iTexture = NULL;
                line.iGap = 0;
                iLines.AppendL(line);
                        
 	            // rasterize a single line (updates texture in iLines[0].iTexture)
        	    RasterizeLineL(ptr, iLines[0], aTextStyle);	                    

   	            // Get extents from the texture we just created
                CAlfTexture* tex = iLines[0].iTexture;
                extents.iHeight += iLines[0].iGap;
                if(tex)
                    {
                    extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                    extents.iHeight += tex->Size().iHeight;
                    }	                
                	
        	    CleanupStack::PopAndDestroy(buf);
                break;
                }

            case CAlfTextVisual::ELineWrapBreak:
                {
                // wrap lines to array
                linePtrs = new (ELeave) CArrayFixFlat<TPtrC>(KLineArrayGranularity);
                CleanupStack::PushL(linePtrs);
        
                buf = AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
                    text, maxWidth, *font, *linePtrs);
                CleanupStack::PushL(buf);

              	// Do rasterisation
                for(TInt i = 0; i < linePtrs->Count();i++)
                    {
                    SRasterizedLine line;
                    line.iTexture = NULL;
                    line.iGap = 0;
                    iLines.AppendL(line);
                        
                    // rasterize a single line (updates texture in iLines[i].iTexture)
                    RasterizeLineL(linePtrs->At(i), iLines[i], aTextStyle);
                    CAlfTexture* tex = iLines[i].iTexture;
                    extents.iHeight += iLines[i].iGap;
                            
                    if(tex)
                        {
                        extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                        extents.iHeight += tex->Size().iHeight;
                        }    
                            	                                                         
                    if (i == iVisual->MaxLineCount()-1)
          	            {
       	                // Maximum number of lines reached.
       	                break;
       	                }
                    }
                CleanupStack::PopAndDestroy(buf);
                CleanupStack::PopAndDestroy(linePtrs);
                break;
                }
                
            default:
                break;
            }
            
        // Extents needs to be updated in order to make alignment 
        // work properly.
        iExtents = extents;

        UpdateDescriptorL();
        }