// start run a test case
void CTestExecutor::RunTestCaseL()
	{
	RSemaphore smphF;
	smphF.CreateLocal(0);
	RSemaphore smphN;
	smphN.CreateLocal(0);
		
	RArray<RThread> notiThreads; // list of handles of notification threads
	RPointerArray<CTimerLogger> loggerList;
	
	TUint16 count = 0;
	TUint16 option = iTestSetting.iOption;
	while (count < iTestSetting.iNumCli)
		{
		test(count < 16);
		iTestSetting.iOption = (TUint16)(option + count); // Put Thread ID in option
		
		TThreadParam param;
		param.iSetting = iTestSetting;
		param.iSmphFT = &smphF;
		param.iSmphNT = &smphN;
			
		TFileName logName;
		logName.FillZ();
		
		if (gPerfMeasure)
		    {
            logName.Append(gLogFilePath);
            if (iTestSetting.iNumCli == 1)
                logName.Append(_L("SingleClient"));
            else
                logName.AppendFormat(_L("MultiClient%02d"), count);
            
            logName.Append(gLogPostFix);
		    }
		
		CTimerLogger* logger = CTimerLogger::NewL(logName);
		CleanupStack::PushL(logger);
		
		param.iLogger = logger;
		param.iLoggerArray = NULL;
		
		TUint operation = *iTestSetting.iOperationList;
		TBool numFilesVaries = EFalse; 
		
		if (operation == EOpManyFiles || operation == EOpManyChanges || operation == EOpMixed)
			{
			numFilesVaries = ETrue;
			}
		logger->LogSettingDescription(iTestSetting.iNumFiles, iTestSetting.iNumCli, iTestSetting.iOption, numFilesVaries);
		
		loggerList.AppendL(logger);
		
		TBuf<20> threadName;
		threadName.AppendFormat(_L("NotificationThread%02d"), count);

		RThread notifyOp;
		notifyOp.Create(threadName, NotificationOperationThread, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, &param);
		
		notiThreads.AppendL(notifyOp);
		
		notifyOp.Resume();
		
		smphF.Wait();	// Wait for the parameters being properly passed
		
		CleanupStack::Pop(logger);
		count++;
		}
	
	gNotiThreads = notiThreads;
	
	if (iTestSetting.iNumCli == 0)	// no notification
		{
		TFileName logName;
		logName.Append(gLogFilePath);
		logName.Append(_L("SingleClient"));
		logName.Append(gLogPostFix);
	
		CTimerLogger* logger = CTimerLogger::NewL(logName);
		CleanupStack::PushL(logger);
		
		logger->LogSettingDescription(iTestSetting.iNumFiles, iTestSetting.iNumCli, iTestSetting.iOption);
		
		loggerList.AppendL(logger);
		CleanupStack::Pop(logger);
		}
	
	TThreadParam paramFileOp;
	paramFileOp.iSetting = iTestSetting;
	paramFileOp.iSmphFT = &smphF;
	paramFileOp.iSmphNT = &smphN;
	paramFileOp.iLogger = NULL;
	paramFileOp.iLoggerArray = &loggerList;
	
	RThread fileOp;
	fileOp.Create(_L("FileOperationThread"), FileOperationThread, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, &paramFileOp);	
	gFileThread = fileOp;
	
	fileOp.Resume();
	
	TInt err;
	
	TRequestStatus status;
	fileOp.Logon(status);
	User::WaitForRequest(status);
	err = fileOp.ExitReason();
	test(err == KErrNone);
		
	count = 0;
	while(count < notiThreads.Count())
		{
		notiThreads[count].Logon(status);
		User::WaitForRequest(status);
		err = notiThreads[count].ExitReason();
		test(err == KErrNone);
		count++;
		}
	
	CLOSE_AND_WAIT(fileOp);
	
	count = 0;
	while(count < notiThreads.Count())
		{
		RThread thread = notiThreads[count];
		CLOSE_AND_WAIT(thread);
		count++;
		}
	
	for (TInt i = 0; i < loggerList.Count(); i++)
		{
		loggerList[i]->LogAndPrint(_L("===================================================="));
		}
	
	smphN.Close();
	smphF.Close();
	loggerList.ResetAndDestroy();
	loggerList.Close();
	notiThreads.Reset();
	notiThreads.Close();
	}
Esempio n. 2
0
void CTzDbRuleSet::CompleteRulesAndAddToCollectionL(
					CTzRules& aTzRules, 
					const RArray<TTzRuleDefinition*>& aRuleDefs, 
					const RArray<TTzRuleUse*>& aRuleUses, 
					TInt aUtcOffset, TInt aInitialLocalTimeOffset,
					TDateTime aStart, TDateTime aEnd) const
	{
	TInt count = aRuleDefs.Count();
	if (count != aRuleUses.Count())
		{
		User::Leave(KErrCorrupt);
		}
	
	TTimeWithReference startOfAlignment(aStart,ETzUtcTimeReference);
	TTimeWithReference endOfAlignment(aEnd,ETzUtcTimeReference);

	//Keep track of changes to UTC offset
	// even if there are no DST rules.
	TTzRule trule(	
				startOfAlignment, startOfAlignment,
				(TUint16)aInitialLocalTimeOffset, (TUint16)aInitialLocalTimeOffset, EJanuary, ETzFixedDate,
				0, 0, 
				ETzUtcTimeReference, 
				0);
	aTzRules.AddRuleL(trule);		
	//Calculate the new and old offsets for each rule.
	TInt prevOffset = 0;
	TInt maxOffset = 0;
	for (TInt i = 0; i < count; i++)
		{
		TInt oldOffset = aInitialLocalTimeOffset;
		TInt dstOffset = aRuleDefs[i]->iStdTimeOffset;
		TInt newOffset = aUtcOffset + dstOffset;
		//newoffset and oldoffset should always have a difference of dstoffset.
		if (newOffset <= oldOffset )
			{
			//there are cases when dstoffset in the set of rules is same for few continuous rules
			//in such cases, newoffset and oldoffset would have a difference of maxoffset.
			if(prevOffset == dstOffset)
				{
				oldOffset =	aUtcOffset + maxOffset;		
				}
			else
				{
				oldOffset =	aUtcOffset + prevOffset;		
				}				
			}
		else
			//newoffset is more than oldoffset so maintain the difference with dstoffset.
			{
			oldOffset =	newOffset - dstOffset;							
			}
		prevOffset = dstOffset;		
		//store maximum offset, to handle cases in which dstoffset in the set of rules
		//is same for few continuous rules
		if(dstOffset > maxOffset)
			{
			maxOffset = dstOffset;
			}
			
		TUint16 timeOfChange = aRuleDefs[i]->iTimeOfChange;
		TTzTimeReference timeReference = 
			static_cast<TTzTimeReference>(aRuleDefs[i]->iTimeReference);

		//

		// Find the intersection of the date ranges:
		//  use latest start year, earliest end year
		TDateTime start = aStart;
		TDateTime end = aEnd;
		if(aRuleUses[i]->iFromYear > start.Year())
			{
			start = TDateTime(aRuleUses[i]->iFromYear,EJanuary,0,0,0,0,0);
			}
			
		if(aEnd.Year() > aRuleUses[i]->iUntilYear)
			{
			end = TDateTime(aRuleUses[i]->iUntilYear,EDecember,30,23,59,59,0);
			}
			
		TTimeWithReference startOfRule(start,ETzUtcTimeReference);
		TTimeWithReference endOfRule(end,ETzUtcTimeReference);
		if(endOfRule.iTime >= startOfRule.iTime)
			{
			TTzRule trule(	
						startOfRule, endOfRule,
						(TUint16)oldOffset, (TUint16)newOffset, (TMonth)aRuleDefs[i]->iMonth, (TTzRuleDay)aRuleDefs[i]->iDayRule,
						aRuleDefs[i]->iDayOfMonth, aRuleDefs[i]->iDayOfWeek, 
						timeReference, timeOfChange);				 

			aTzRules.AddRuleL(trule);
	
			}
		}	
	}
QList<XQCentralRepositorySettingsKey> XQCentralRepositoryUtilsPrivate::findKeys(const XQCentralRepositorySearchCriteria& criteria)
{
    long int repositoryUid = criteria.repositoryUid();
    CCentralRepositoryHandler* handler = m_settingsManagerPrivate.cenRepHandlerInstance(repositoryUid);
    if (!handler)
    {
        m_settingsManagerPrivate.iError = XQSettingsManager::UnknownError;
        return QList<XQCentralRepositorySettingsKey>();
    }

    QList<XQCentralRepositorySettingsKey> keys;

    TRAP(m_settingsManagerPrivate.iError,
        RArray<TUint32> foundKeys;
        CleanupClosePushL(foundKeys);
        if (criteria.value().isNull())
        {
            User::LeaveIfError(handler->findKeyL(criteria.partialKey(), criteria.bitMask(),
                foundKeys));
        }
        else
        {
            switch (criteria.value().type())
            {
                case QVariant::Int:
                {
                    User::LeaveIfError(handler->findKeyL(criteria.partialKey(), criteria.bitMask(),
                        criteria.value().toInt(), criteria.negativeCriteria(), foundKeys));
                    break;
                }
                case QVariant::Double:
                {
                    User::LeaveIfError(handler->findKeyL(criteria.partialKey(), criteria.bitMask(),
                        criteria.value().toDouble(), criteria.negativeCriteria(), foundKeys));
                    break;
                }
                case QVariant::String:
                {
                    TPtrC16 stringValue(reinterpret_cast<const TUint16*>(criteria.value().toString().utf16()));
                    User::LeaveIfError(handler->findKeyL(criteria.partialKey(), criteria.bitMask(),
                        stringValue, criteria.negativeCriteria(), foundKeys));
                    break;
                }
                case QVariant::ByteArray:
                {
                    TPtrC8 byteArrayValue((TUint8*)(criteria.value().toByteArray().constData()));
                    User::LeaveIfError(handler->findKeyL(criteria.partialKey(), criteria.bitMask(),
                        byteArrayValue, criteria.negativeCriteria(), foundKeys));
                    break;
                }
                default:
                {
                    User::Leave(KErrArgument);
                    break;
                }
            }
        }
        for (int i = 0; i < foundKeys.Count(); ++i)
        {
            XQCentralRepositorySettingsKey key(repositoryUid, foundKeys[i]);
            keys.append(key);
        }

        CleanupStack::PopAndDestroy(&foundKeys);
    )
    return keys;
// ---------------------------------------------------------------------------
// CAtSmsStoreReadAll::ParseResponseL
// other items were commented in a header
// ---------------------------------------------------------------------------
void CAtSmsStoreReadAll::ParseResponseL(const TDesC8& /*aResponseBuf*/)
	{
	/**
	* Response:+CMGR:<stat>,[<alpha>],<length><CR><LF><pdu>
	*/
	iError = KErrNone;	
	RArray<TPtrC8> array;
	CleanupClosePushL(array);
	iParser->ParseRespondedBuffer(array,Buffer());
	if(array[0].MatchF(KAnyATCommand)!=KErrNotFound)
		{
		array.Remove(0);
		}
	TInt count = array.Count();
#ifdef _DEBUG
	for( TInt i=0;i<count;i++ )
		{
        LOGTEXT3(_L8("CAtSmsStoreReadAll::ParseResponseL\tarray[%d]=%S"),i,&array[i]);  
		}
#endif   
	if (count <= 1)
		{
		CleanupStack::PopAndDestroy();
		iError = KErrNotFound;
		return;
		}
	if(array[0].MatchF(KCMGRResponseString)==KErrNotFound)
		{
		LOGTEXT(_L8("CAtSmsStoreReadAll::ParseResponseL\tFound +CMGR String!"));
		CleanupStack::PopAndDestroy();
		iError = KErrNotFound;
		return;
		}
	// parse the message status
	TLex8 lex(array[1]);
	TUint16 val;
	TInt ret=lex.Val(val,EDecimal);
	if(ret!=KErrNone)
		{
		CleanupStack::PopAndDestroy();
		iError = ret;
		return;
		}
	iSmsData.iMessageStatus = val;
	
	//parse the message length
	TLex8 lex1(array[3]);
	TUint msgLength;
	ret=lex1.Val(msgLength,EDecimal);
	if(ret!=KErrNone)
		{
		CleanupStack::PopAndDestroy();
		iError = ret;
		return;
		}
	LOGTEXT2(_L8("CAtSmsStoreReadAll::ParseResponseL\tMessage Length=%d"),msgLength);
	TBuf8<KMaxAsciiPduLength>  pdu;	   //Binary Message pdu
	SmsAtUtil::ConvertAsciiToBinary(array[4],pdu);
	TPtrC8 pduPtr(pdu);
	
	RMobilePhone::TMobileAddress gsmServiceCentre;   //messages's SCA
	if (msgLength*2 < array[4].Length())
		{
		// There is an SCA prepended so remove this and store it in iGsmServiceCentre
		SmsAtUtil::ReadAndRemoveAddressFromPdu(pduPtr,gsmServiceCentre);
		}
	iSmsData.iSmsMsg = pduPtr;
	iSmsData.iServiceCentre = gsmServiceCentre.iTelNumber;
	iSmsData.iMobileScNPI = gsmServiceCentre.iNumberPlan;
	iSmsData.iMobileScTON = gsmServiceCentre.iTypeOfNumber;
	LOGTEXT2(_L8("CAtSmsStoreReadAll::ParseResponseL\tMessage Status=%d"),
			                          iSmsData.iMessageStatus);
	LOGTEXT3(_L8("CAtSmsStoreReadAll::ParseResponseL\tSmsMsg=%S, ServiceCentre=%S"), 
			                          &iSmsData.iSmsMsg, &iSmsData.iServiceCentre);
	CleanupStack::PopAndDestroy(&array);
	}
Esempio n. 5
0
// ------------------------------------------------
// NotifyModified
// ------------------------------------------------
//
void CMdSNotifier::NotifyModifiedL(const RArray<TItemId>& aObjectIds,
                                                         CMdSManipulationEngine* aMEngine)
	{
	if (aObjectIds.Count() == 0)
    	{
    	return;
    	}

    TBool allUrisFetched( EFalse );
    RPointerArray<HBufC> allUrisArray;
    CleanupResetAndDestroyPushL( allUrisArray );

    for( TInt i = iEntries.Count() - 1; i >=0; i-- )
        {
        TEntry& e = iEntries[i];

        if( e.iType & (EObjectNotifyModify | EObjectNotifyModifyWithUri) )
            {
            // collect matching object IDs
            RArray<TItemId> matchingObjectIdArray;
			CleanupClosePushL( matchingObjectIdArray );
		    RPointerArray<HBufC> uriArray;
		    CleanupResetAndDestroyPushL( uriArray );

            const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(), 
            		aObjectIds, matchingObjectIdArray );

			// check is there any matches
			if( allMatches || matchingObjectIdArray.Count() > 0 )
            	{
            	if(e.IsPending())
            		{
	            	// Match found. Trigger notifier entry.
	            	TInt err( KErrNone );

	            	if( allMatches )
	            		{
	            		// all matches so send whole object ID array
	            		if( e.iType & EObjectNotifyModifyWithUri )
	            		    {
	            		    if( !allUrisFetched )
	            		        {
	            		        aMEngine->GetObjectUrisByIdsL( aObjectIds, allUrisArray );
	            		        allUrisFetched = ETrue;
	            		        }
	                        TRAP( err, e.TriggerL( EObjectNotifyModifyWithUri, 
	                                 aObjectIds, allUrisArray ) );
	            		    }
	            		else
	            		    {
                            TRAP( err, e.TriggerL( EObjectNotifyModify, 
                                     aObjectIds, uriArray ) );
	            		    }
	            		}
	            	else
	            		{
                        if( e.iType & EObjectNotifyModifyWithUri )
                            {
                            aMEngine->GetObjectUrisByIdsL( matchingObjectIdArray, uriArray );
                            TRAP( err, e.TriggerL( EObjectNotifyModifyWithUri, 
                                    matchingObjectIdArray, uriArray ) );
                            }
                        else
                            {
                            TRAP( err, e.TriggerL( EObjectNotifyModify, 
                                    matchingObjectIdArray, uriArray ) );
                            }
	            		}
	            	if( err != KErrNone )
		            	{
		            	e.TriggerError( err );
	    	        	}
            		}
            	else
            		{
					if( allMatches )
	            		{
                        // all matches so send whole object ID array
                        if( e.iType & EObjectNotifyModifyWithUri )
                            {
                            if( !allUrisFetched )
                                {
                                aMEngine->GetObjectUrisByIdsL( aObjectIds, allUrisArray );
                                allUrisFetched = ETrue;
                                }
                            TRAP_IGNORE( e.CacheL( EObjectNotifyModifyWithUri, 
                                     aObjectIds, allUrisArray ) );
                            }
                        else
                            {
                            TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
                                     aObjectIds, uriArray ) );
                            }
	            		}
	            	else
	            		{
                        if( e.iType & EObjectNotifyModifyWithUri )
                            {
                            aMEngine->GetObjectUrisByIdsL( matchingObjectIdArray, uriArray );
                            TRAP_IGNORE( e.CacheL( EObjectNotifyModifyWithUri, 
                                    matchingObjectIdArray, uriArray ) );
                            }
                        else
                            {
                            TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
                                    matchingObjectIdArray, uriArray ) );
                            }
	            		}
            		}
            	}
			CleanupStack::PopAndDestroy( 2, &matchingObjectIdArray ); // matchingObjectIdArray, uriArray
            }
        }
    CleanupStack::PopAndDestroy( &allUrisArray );
	}
Esempio n. 6
0
void CFdfTest::MndeoDeviceEvent()
	{
	iManager.Write(_L8("CFdfTest::MndeoDeviceEvent"));
	iManager.Write(KNullDesC8());
	iManager.Write(_L8("CFdfTest::MndeoDeviceEvent"));

	// Apologies for the squashed-up output this gives, but this text is no
	// good if it scrolls off the top of the target board's screen.
	iManager.Write(_L8("Raw data:"));
	iManager.Write(_L8("device ID = %d, event type = %d, error = %d, driver load status = %d, vid = 0x%04x, pid = 0x%04x"),
		iDeviceEventInformation.iDeviceId,
		iDeviceEventInformation.iEventType,
		iDeviceEventInformation.iError,
		iDeviceEventInformation.iDriverLoadStatus,
		iDeviceEventInformation.iVid,
		iDeviceEventInformation.iPid);

	iManager.Write(_L8("Interpretation:"));

	_LIT8(KAttachment, "Attachment");
	_LIT8(KDriverLoad, "Driver load");
	_LIT8(KDetachment, "Detachment");
	TFixedArray<const TDesC8*, 3> eventType;
	eventType[EDeviceAttachment] = &KAttachment();
	eventType[EDriverLoad] = &KDriverLoad();
	eventType[EDeviceDetachment] = &KDetachment();

	_LIT8(KSuccess, "Success");
	_LIT8(KPartialSuccess, "Partial success");
	_LIT8(KFailure, "Failure");
	TFixedArray<const TDesC8*, 3> driverLoadStatus;
	driverLoadStatus[EDriverLoadSuccess] = &KSuccess();
	driverLoadStatus[EDriverLoadPartialSuccess] = &KPartialSuccess();
	driverLoadStatus[EDriverLoadFailure] = &KFailure();

	switch ( iDeviceEventInformation.iEventType )
		{
	case EDeviceAttachment:
		{
		iManager.Write(_L8("%S | device %d | error %d"),
			eventType[iDeviceEventInformation.iEventType],
			iDeviceEventInformation.iDeviceId,
			iDeviceEventInformation.iError);
		}
		break;
	case EDriverLoad:
		iManager.Write(_L8("%S | device %d | %S | error %d"),
			eventType[iDeviceEventInformation.iEventType],
			iDeviceEventInformation.iDeviceId,
			driverLoadStatus[iDeviceEventInformation.iDriverLoadStatus],
			iDeviceEventInformation.iError);
		break;
	case EDeviceDetachment:
		iManager.Write(_L8("%S | device %d"),
			eventType[iDeviceEventInformation.iEventType],
			iDeviceEventInformation.iDeviceId);
		break;
	default:
		iManager.Write(_L8("INVALID iEventType"));
		return;
		}

	if ( iDeviceEventInformation.iEventType == EDeviceAttachment && iDeviceEventInformation.iError == KErrNone )
		{
		iManager.Write(_L8("VID: 0x%04x, PID: 0x%04x"),
			iDeviceEventInformation.iVid,
			iDeviceEventInformation.iPid);

		RArray<TUint> langIds;
		TInt err = iUsbHostStack.GetSupportedLanguages(iDeviceEventInformation.iDeviceId, langIds);
		if ( err == KErrNone )
			{
			const TUint count = langIds.Count();
			iManager.Write(_L8("there is/are %d supported language(s)"), count);
			for ( TUint ii = 0 ; ii < count ; ++ii )
				{
				iManager.Write(_L8("using langid %d (index %d)"), langIds[ii], ii);

				TName string;

				TInt err = iUsbHostStack.GetManufacturerStringDescriptor(iDeviceEventInformation.iDeviceId, langIds[ii], string);
				if ( err == KErrNone )
					{
					TBuf8<256> buf;
					buf.Copy(string);
					iManager.Write(_L8("manufacturer string descriptor = \"%S\""), &buf);
					}
				else
					{
					iManager.Write(_L8("GetManufacturerStringDescriptor returned %d"), err);
					}

				err = iUsbHostStack.GetProductStringDescriptor(iDeviceEventInformation.iDeviceId, langIds[ii], string);
				if ( err == KErrNone )
					{
					TBuf8<256> buf;
					buf.Copy(string);
					iManager.Write(_L8("product string descriptor = \"%S\""), &buf);
					}
				else
					{
					iManager.Write(_L8("GetProductStringDescriptor returned %d"), err);
					}
				}
			}
		else
			{
			iManager.Write(_L8("GetSupportedLanguages returned %d"), err);
			}
		langIds.Close();

		}
	}
TVerdict CTestCalInterimApiDEF064928Step::doTestStepL()
	{
	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
	CleanupStack::PushL(scheduler);  
	CActiveScheduler::Install(scheduler);

	iSession  = CCalSession::NewL();
	
	CTestCalInterimApiCallbackForAlarms* alarmCallback = CTestCalInterimApiCallbackForAlarms::NewL(this);
	CleanupStack::PushL(alarmCallback); 

	OpenSessionFileL();
	iEntryView = CCalEntryView::NewL(*iSession,*alarmCallback);
	
	SetTestStepResult(EFail);
	
	CActiveScheduler::Add(alarmCallback);
	CActiveScheduler::Start();
	
	TUint seqNo = 1;
	HBufC8* pGUID1= KAlarmExportTestGUID1().AllocLC();
	CCalEntry* entry1 = CCalEntry::NewL(CCalEntry::EAppt, pGUID1,
	                                    CCalEntry::EMethodAdd, seqNo);
	CleanupStack::Pop(pGUID1); // entry takes ownership
	CleanupStack::PushL(entry1);                                   

	TDateTime entryStart1(2006, EJuly, 6, 15, 0, 0, 0);
	TCalTime  calStart1;
	calStart1.SetTimeLocalL(entryStart1);
	TDateTime entryStop1(2006, EJuly, 6, 16, 0, 0, 0);
	TCalTime calStop1;
	calStop1.SetTimeLocalL(entryStop1);
	entry1->SetStartAndEndTimeL(calStart1, calStop1);

	TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EDaily);
	CleanupStack::PushL(rpt); 

	rpt->SetInterval(1);
	TCalTime startTime;
	startTime.SetTimeLocalL(TDateTime(2006, EJuly, 6, 0, 0, 0, 0));
	rpt->SetDtStart(startTime);
	TCalTime endTime;
	endTime.SetTimeLocalL(TDateTime(2006, EJuly, 10, 0, 0, 0, 0));
	rpt->SetUntil(endTime);
	entry1->SetRRuleL(*rpt); // doesn't take ownership

	CleanupStack::PopAndDestroy(rpt); 
	
	SaveToAgendaL(entry1, EFalse);

	seqNo++;
	HBufC8* pGUID2= KAlarmExportTestGUID2().AllocLC();
	TDateTime entryTime2(2006, EJuly, 9, 15, 0, 0, 0);
	TCalTime  calTime2;
	calTime2.SetTimeLocalL(entryTime2);
	CCalEntry* entry2 = CCalEntry::NewL(CCalEntry::EAppt, pGUID2,
	                                    CCalEntry::EMethodAdd, seqNo, calTime2, 
	                                    CalCommon::EThisOnly);
	CleanupStack::Pop(pGUID2); // entry takes ownership
	CleanupStack::PushL(entry2);                                   

	CreateExceptionDateL(entry2, entry1);

	RArray<TCalTime> exDateList1;
	CleanupClosePushL(exDateList1);
	entry1->GetExceptionDatesL(exDateList1);
	TESTL(exDateList1[0].TimeLocalL() == calTime2.TimeLocalL());
	CleanupStack::PopAndDestroy();

	//build the CCalDataExchange object and Export
	RFs   fs;
	fs.Connect();
	CleanupClosePushL(fs);
	
	CCalDataExchange* dataExchange = CCalDataExchange::NewL(*iSession);
	CleanupStack::PushL(dataExchange); 
	RFile outFile;
	CleanupClosePushL(outFile);
	TInt err = outFile.Replace(fs, KEntryExportFile, EFileWrite);
	RFileWriteStream writeStream(outFile);
	CleanupClosePushL(writeStream);
	
	INFO_PRINTF1(KExporting);
	RPointerArray<CCalEntry> firstEntryArray;
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &firstEntryArray));
	iEntryView->FetchL(entry1->UidL(), firstEntryArray);
		
	dataExchange->ExportL(KUidVCalendar, writeStream, firstEntryArray);
	
	writeStream.CommitL();
	
	// check that the exception date was stored correctly
	CCalEntry *fetchedEntry = firstEntryArray[0];
	RArray<TCalTime> exDateList2;
	fetchedEntry->GetExceptionDatesL(exDateList2);
	CleanupClosePushL(exDateList2);
	TESTL(exDateList2[0].TimeLocalL() == calTime2.TimeLocalL());
	
	CleanupStack::PopAndDestroy();
	CleanupStack::PopAndDestroy();
	CleanupStack::PopAndDestroy(&writeStream); // writeStream.Close()
	CleanupStack::PopAndDestroy(&outFile); // outFile.Close()
	
	//Internalize the entries from the file we just wrote
	RFile inFile;
	CleanupClosePushL(inFile);
	TInt errR = inFile.Open(fs, KEntryExportFile, EFileRead);
	RFileReadStream readStream(inFile);
	CleanupClosePushL(readStream);
	
	RPointerArray<CCalEntry> secondEntryArray;
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray));
	
	INFO_PRINTF1(KImporting);
	dataExchange->ImportL(KUidVCalendar, readStream, secondEntryArray);
	
	CleanupStack::Pop(&secondEntryArray);
	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&inFile);
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray));
	
	// check the imported alarm
	TESTL(secondEntryArray.Count() == 1);
	CCalEntry* entry = secondEntryArray[0];
	RArray<TCalTime> importedExDate;
	entry->GetExceptionDatesL(importedExDate);
	TESTL(importedExDate.Count() == 1);
	TESTL(importedExDate[0].TimeLocalL() == calTime2.TimeLocalL());

	CleanupStack::PopAndDestroy(7, scheduler);
	SetTestStepResult(EPass);
	return TestStepResult();
	}
TVerdict CRepositoryCheckStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL()
 * did not leave. That being the case, the current test result value will be
 * EPass.
 * Check for the absence and presence of repository settings as specified in
 * the config file.
 */
    {
    SetTestStepResult(EPass);    

    // See if we just want to wait for a bit. Bit of a strange place
    // to put this, but convenient..
    TInt pause=0;
    TInt bRet = GetIntFromConfig(ConfigSection(), KPause, pause);
    if(bRet == 1)
        {
        pause *= ipauseincrement;
        User::After(KDefaultEvictionTimeout + pause);
        }

    // Get the key for the repository we're interested in. Return if absent.
    TInt reposkey=0;
    bRet = GetHexFromConfig(ConfigSection(), KRepositoryKey, reposkey );
    if(bRet!=1)
        {
        SetTestStepResult(EFail);    
        INFO_PRINTF1(HTML_RED);
        ERR_PRINTF1(_L("Repository key not specified in .ini file."));
        INFO_PRINTF1(HTML_RED_OFF);
        return TestStepResult();
        }
    INFO_PRINTF2(_L("Repository key: 0x%x"), reposkey );

    // Get the flag the indicates whether this repository should exist.
    // We might be checking for absence.. If this isn't given, assume the
    // repository is expected to be present.
    TBool repwanted=ETrue;
    bRet = GetIntFromConfig(ConfigSection(),KRepositoryPresent, repwanted);
    if(bRet != 1) repwanted = ETrue;
    INFO_PRINTF2(_L("Repository wanted: %d"), repwanted );

    // Create the repository object.
    // We have to TRAP here for the case where the repository does not
    // exist. This may be wanted or not.
    TInt leavecode;
    CRepository* repository=NULL;
    TRAP(leavecode, repository = CRepository::NewL(TUid::Uid(reposkey)) );
    if(repository != NULL) CleanupStack::PushL(repository);

    // This is not necessarily an error..
    if(leavecode != KErrNone)
        INFO_PRINTF2(_L("Leave code: %d"), leavecode );
    if(repository == NULL) 
        INFO_PRINTF1(_L("Repository is NULL"));
    else
        INFO_PRINTF1(_L("Repository is not NULL"));
    if(leavecode == KErrAlreadyExists)
        {
        INFO_PRINTF1(HTML_RED);
        ERR_PRINTF1(_L("Leavecode is KErrAlreadyExists. Perhaps there's a duplicate key in a keyspace file?"));
        INFO_PRINTF1(HTML_RED_OFF);
        SetTestStepResult(EFail);    
        }

    if(repwanted)
        {
        if(leavecode == KErrNotFound)
            {
            SetTestStepResult(EFail);    
            INFO_PRINTF1(HTML_RED);
            ERR_PRINTF1(_L("Required Repository does not exist"));
            INFO_PRINTF1(HTML_RED_OFF);

            return TestStepResult();
            }
        else if(leavecode == KErrNone)
            {
            INFO_PRINTF1(_L("Required Repository exists (correctly)."));
        // Drop through.
            }
        else
            {
            INFO_PRINTF1(HTML_RED);
            ERR_PRINTF2(_L("Unexpected leave '%d' creating repository."), leavecode);
            INFO_PRINTF1(HTML_RED_OFF);

            if(repository != NULL)
                CleanupStack::PopAndDestroy(repository);
            SetTestStepResult(EFail);
            return TestStepResult();
            }
        }
    else // !repwanted
        {
        if(leavecode == KErrNone)
            {
            SetTestStepResult(EFail);
            INFO_PRINTF1(HTML_RED);
            ERR_PRINTF1(_L("Repository exists when it should not."));
            INFO_PRINTF1(HTML_RED_OFF);
            CleanupStack::PopAndDestroy(repository);
            }
        else
            {
            INFO_PRINTF1(_L("Repository is absent (correctly)."));
            // The following should not be possible.
            if(leavecode != KErrNotFound)
                {
                INFO_PRINTF1(HTML_RED);
                ERR_PRINTF2(_L("Failure to create repository, but error code is not KErrNotFound! Err=%d"), leavecode);
                SetTestStepResult(EFail);
                INFO_PRINTF1(HTML_RED_OFF);
                }
            }
        return TestStepResult();
        }
    // The only way to this point is to have a repository that is wanted.
    // Must remember to pop the cleanupstack later!

    // Look for the expected total number of settings in this repository.
    TInt expectednumsettings;
    bRet = GetIntFromConfig(ConfigSection(), KExpectedNumSettings, expectednumsettings );
    // If bRet is not set then the user isn't interested in the number of
    // settings, which is ok.
    if(bRet == 1)
        {
        RArray<TUint32> foundIds;
        TInt r = KErrNone;
        leavecode = KErrNone;
        INFO_PRINTF2(_L("Looking for number of settings: %d"), expectednumsettings);
        TRAP(leavecode, r = repository->FindL(0, 0, foundIds));
        if(leavecode != KErrNone)
            r = leavecode;
        if(r!=KErrNone)
            SetTestStepResult(EFail);
        INFO_PRINTF2(_L("Number of repository ids: %d"), foundIds.Count());
        if(foundIds.Count() != expectednumsettings)
            {
            INFO_PRINTF1(HTML_RED);
            ERR_PRINTF2(_L("Failure: Expected number of keys: %d"), expectednumsettings);
            INFO_PRINTF1(HTML_RED_OFF);
            SetTestStepResult(EFail);
            }
        }

    // Look for settings in the repository which should be absent.
    TInt nabsent;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryAbsent, nabsent );
    // If bRet is not set then the number of absent settings hasn't been
    // specified, which is ok.
    if(bRet == 1)
        {
        // Careful if the prefix here changes, we don't want to
        // blow this buffer. Also note the 'Delete' a few lines hence.
        TBuf<REPCHECKCREATE_ABSBUFLEN> abs(KAbsentPrefix);
        TInt len = abs.Length();
        for( TInt count=0 ; count < nabsent ; count++ )
            {
            abs.AppendNum(count);            // e.g "Absent27"
            TInt absentkey;
            // All keys from "Absent0" through "Absent<N-1>" MUST be defined
            // in the config file...
            bRet = GetHexFromConfig(ConfigSection(), abs, absentkey );
            if(bRet != 1)
                {
                INFO_PRINTF1(HTML_RED);
                ERR_PRINTF1(_L("Failed to get absent key from config file."));
                INFO_PRINTF1(HTML_RED_OFF);
                SetTestStepResult(EFail);
                }

            // .. but must not exist in the repository.
            TInt vali;
            TReal valr;
            TBuf<REPCHECKCREATE_MAXSTRINGLEN> vals;
            TInt ri = repository->Get( absentkey, vali );
            TInt rr = repository->Get( absentkey, valr );
            TInt rs = repository->Get( absentkey, vals );
            if( (ri==KErrNone) || (rr==KErrNone) || (rs==KErrNone))
                {
                INFO_PRINTF1(HTML_RED);
                ERR_PRINTF2(_L("FAILURE: Repository has key 0x%x which should be absent."), absentkey );
                if(!ri) ERR_PRINTF3(_L("Intrc: %d, Value: 0x%x"), ri, vali );
                if(!rr) ERR_PRINTF3(_L("Realrc: %d, Value: %f"), rr, valr );
                if(!rs) ERR_PRINTF3(_L("Stringrc: %d, Value: %S"), rs, &vals );
                INFO_PRINTF1(HTML_RED_OFF);
                SetTestStepResult(EFail);
                }
            abs.Delete(len, REPCHECKCREATE_ABSBUFLEN);  // Strip the number..
            }
        }

    // Look for settings in the repository which should be present. Integers
    // first..
    TInt nints;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumInts, nints );
    if(bRet == 1)
        {
        CheckRepositoryIntegerSettings(repository, nints);
        }

    // Look for settings in the repository which should be present. Now reals.
    TInt nreals;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumReals, nreals );
    if(bRet == 1)
        {
        CheckRepositoryRealSettings(repository, nreals);
        }

    // Look for settings in the repository which should be present. Now strings.
    TInt nstrings;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumStrings, nstrings );
    if(bRet == 1)
        {
        CheckRepositoryStringSettings(repository, nstrings);
        }

    CleanupStack::PopAndDestroy(repository);
    
    return TestStepResult();
    }
void CT_KeypadDriverData::DoCmdTestMultipleKeysL(const TDesC& aSection, const TInt aAsyncErrorIndex)
/**
 * Tests multiple key combinations by verifying their scancodes against expected values
 *
 * @param aSection			The section in the ini containing data for the command
 *
 * @return					void
 *
 * @leave					System wide error
 */
 	{
	iCombinationStrStore.Reset();
	iExpectedStore.Reset();
	iActualStore.Reset();
	iCombinationKeyCount = 0;
	iConsole.ClearScreen();

	RArray<TInt>	keyStore;
	RArray<TPtrC>	keyStrStore;

	keyStore.Reset();
	keyStrStore.Reset();

	TIniDataName	setStore;
	TIniDataName	strStore;
	TIniDataName	fullStore;
	TPtrC			scanCodeStr;
	TInt			scanCode;

	TInt	setIndex=0;
	TBool	moreSets=ETrue;
	while ( moreSets )
		{
		++setIndex;

		keyStore.Reset();
		keyStrStore.Reset();

		setStore.Format(KSet(), setIndex);
		setStore.Append(_L("_"));

		TInt	index	=0;
		TBool	moreData=ETrue;
		while ( moreData )
			{
			++index;

			fullStore 	= _L("");
			strStore.Format(KScanCodeString(), index);
			fullStore.Append(setStore);
			fullStore.Append(strStore);

			moreData=GetStringFromConfig(aSection, fullStore, scanCodeStr);
			if ( moreData )
				{
				fullStore = _L("");
				strStore.Format(KScanCode(), index);
				fullStore.Append(setStore);
				fullStore.Append(strStore);

				if (!GetEnumFromConfig(aSection, fullStore, iEnumTableScanCodes, scanCode))
					{
					ERR_PRINTF2(_L("Invalid scancode value: %d"), scanCode);
					SetBlockResult(EFail);
					}
				else
					{
					keyStrStore.AppendL(scanCodeStr);
					keyStore.AppendL(scanCode);
					}
				++index;
				}
			else
				{
				if (index == 1)
					{
					moreSets = EFalse;
					}
				}
			}

		if (moreSets)
			{
			TInt	keyCount=keyStore.Count();
			for ( TInt event=0; event<iEventStore.Count(); ++event )
				{
				for ( TInt key=0; key<keyCount; ++key )
					{
					iExpectedStore.AppendL(iEventStore[event]);
					iExpectedStore.AppendL(keyStore[key]);
					}
				}

			TIniDataName	tempStrArray;
			for ( TInt key=0; key<keyCount; ++key )
				{
				if (tempStrArray == _L(""))
					{
					tempStrArray.Append(keyStrStore[key]);
					}
				else
					{
					tempStrArray.Append(_L(" + "));
					tempStrArray.Append(keyStrStore[key]);
					}
				}

			iCombinationStrStore.Append(tempStrArray);
			}
		}

	keyStore.Reset();
	keyStore.Close();
	keyStrStore.Reset();
	keyStrStore.Close();

	if (iExpectedStore.Count() > 0)
		{//end of setup and start testcase
		iConsole.Write(_L("Keyboard layout test.\n"));
		iConsole.Write(_L("Press the following keys in the sequence as displayed:\n"));
		iConsole.Write(iCombinationStrStore[0]);
		iConsole.Write(_L("\n"));
		iConsole.Write(_L("and release them in the same sequence."));

		iConsole.Read(iKey, iActiveCombination->iStatus);
		iActiveCombination->Activate( aAsyncErrorIndex );
		IncOutstanding(); 	// request an event
		}
	else
		{
		INFO_PRINTF1(_L("No multiple key sets available"));
		}
	}
// -----------------------------------------------------------------------------
// CSisxUIStartupFile::ReadStartupItemsL
// Get all startup items from the given resource file.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CSisxUIStartupFile::ReadNewStartupItemsL( RArray<TStartupTaskParam>& aStartupItems,
                                               const RPointerArray<HBufC>& aFiles )
    {
    RResourceFile resource;
    CleanupClosePushL( resource );
    resource.OpenL( iFileSession, *iNewFile );
  
    TInt index( 0 );    

    // Read resources
    for ( index = 1; resource.OwnsResourceId( index ); index++ )
        {
        // Create the reader
        HBufC8* resBuffer = resource.AllocReadLC( index );
        TResourceReader reader;
        reader.SetBuffer( resBuffer );
 
        // Read version byte
        TInt version = reader.ReadUint8();        
     
        // Read actual parameters
        TStartupTaskParam item;
        item.iFileName.Copy( reader.ReadTPtrC() );        
        item.iRecoveryPolicy = (TStartupExceptionPolicy) reader.ReadUint16();
        
        aStartupItems.Append( item );

        CleanupStack::PopAndDestroy( resBuffer );
        }   

    // Validate the array. Each and every executable to be added to the 
    // startup list must also be installed by this package.
    for ( index = 0; index < aStartupItems.Count(); index++ ) 
        {
        // Sanity check
        if ( !aStartupItems[index].iFileName.Length() )
            {
            continue;
            }        
             
        TBool entryFound( EFalse );        
        TInt j( 0 );        
        iTemp = aStartupItems[index].iFileName;
        iTemp.Delete( 0, 1 );        
        iTemp.Fold();        

        for ( j = 0; j < aFiles.Count(); j++ )
            {            
            if ( aFiles[j]->FindF( iTemp ) >= 0 )
                {
                entryFound = ETrue;
                // Replace the possible ! with correct drive
                if ( aStartupItems[index].iFileName[0] == '!' )
                    {
                    TBuf<1> temp;
                    temp.Append( (*aFiles[j])[0] );                    
                    aStartupItems[index].iFileName.Replace(0, 1, temp );                    
                    }
                
                break;                
                }            
            }

        if ( !entryFound )
            {
            aStartupItems.Remove( index );
            index--;            
            }        
        }    

    CleanupStack::PopAndDestroy(); // resource
    }
// ---------------------------------------------------------------------------
// CNATFWStunSettings::ReadSettingsL
// ---------------------------------------------------------------------------
//  
void CNATFWStunSettings::ReadSettingsL( TUint32 aDomainKey,
    const CNATFWCenRepHandler& aRepHandler )
    {
    __NATSETTINGS( "CNATFWStunSettings::ReadSettingsL" )
     
    RArray<TUint32> serverKeys;
    CleanupClosePushL( serverKeys );
    
    TBool sharedSecretNotEnabled;
    TBool sharedSecretEnabled;
    
    // read sharedsecret enabled
    if ( KErrNone != aRepHandler.Read( KUNSAFProtocolsDomainSharedSecretNotSupported |
        aDomainKey, sharedSecretNotEnabled ) )
        {
        sharedSecretEnabled = KNATFWDefaultUseSharedSecret;
        }
    else
        {
        sharedSecretEnabled = !sharedSecretNotEnabled;
        }
        
    // read server settings
    TInt err = aRepHandler.FindServerKeys(
        KUNSAFProtocolsSTUNServerTableMask | aDomainKey, serverKeys );
        
    TInt serverCount = serverKeys.Count();
    
    if ( KErrNone == err && serverCount > 0 )
        {
        for( TInt i( 0 ); i < serverCount; i++ )
            {
            CNATFWServerSettings* serverSettings = CNATFWServerSettings::NewLC(
                KNullDesC8,
                KNATFWDefaultSTUNServerPort,
                KNullDesC8,
                KNullDesC8,
                sharedSecretEnabled );

            TUint32 key = serverKeys[i] | aDomainKey;
            serverSettings->ReadSettingsL( key, aRepHandler );
            iServerArray->AppendL( serverSettings );
            CleanupStack::Pop( serverSettings );
            }
        }
    else
        {
        if ( KErrNotFound == err )
            {
             __NATSETTINGS( "Server settings not found" )
            }
        else
            {
            User::Leave( err );
            }
        }
    CleanupStack::PopAndDestroy( &serverKeys );
    
    // read LatestConnectedStunServerAddress and possible port
    TInt port = 0;
    HBufC8* tempBufPointer = NULL;
    
    tempBufPointer = aRepHandler.ReadL(
        KUNSAFProtocolsLatestConnectedSTUNServerAddressMask | aDomainKey );
    if ( tempBufPointer ) 
        {
        CleanupStack::PushL( tempBufPointer );
        HBufC8* addr = TNATFWSettingsParser::ParseAddressLC(
            *tempBufPointer, port );
        SetLatestConnectedServerAddrL( *addr );
        SetLatestConnectedServerPort( port );
        CleanupStack::PopAndDestroy( addr );
        CleanupStack::PopAndDestroy( tempBufPointer );
        }
    else
        {
        SetLatestConnectedServerAddrL( KNullDesC8 );
        SetLatestConnectedServerPort( port );
        }
    
    // Read LatestConnectedStunServerPort, replaces previous data if found
    if ( KErrNone == aRepHandler.Read( KUNSAFProtocolsLatestConnectedSTUNServerPortMask |
        aDomainKey, port ) )
        {
        SetLatestConnectedServerPort( port );
        }
    
    // read retransmission timeout
    if ( KErrNone != aRepHandler.Read( KUNSAFProtocolsStunRetransmissionTimeoutMask |
        aDomainKey, iRto ) )
        {
        iRto = KNATFWDefaultRtoValue;
        }
    }
Esempio n. 12
0
CPolicyPatchInfoList* CPolicyImporter::BuildPolicyPatchInfoListL()
    {
    LOG_("-> CPolicyImporter::BuildPolicyPatchInfoListL()");
    CPolicyPatchInfoList* patchInfoList = new (ELeave) CPolicyPatchInfoList(2);
    CleanupStack::PushL(patchInfoList);
    HBufC8* subjectName;
    // First, append the CA certs to patch list...
    for (TInt i = 0; i < iCurrCaCertList->Count(); i++)
        {

        CPolicyPatchInfo* patchInfo = new (ELeave) CPolicyPatchInfo();
        CleanupStack::PushL(patchInfo);

        TParse fileNameParser;
        fileNameParser.Set(iCurrCaCertList->At(i), NULL, NULL);

        patchInfo->iCertFileName.Copy(fileNameParser.NameAndExt());
        subjectName = CertSubjectNameL(iCurrCaCertList->At(i));
        CleanupStack::PushL(subjectName);
        if ( iCurrOtherCaCertList->Count()>1 && iCurrCaCertList->Count()==1 ) //if other than basic CA certificate exists
            {
            // Set original intermediate CA untrusted. . 
            HBufC8* certData = iFileUtil.LoadFileDataL(iCurrCaCertList->At(0));
            CleanupStack::PushL(certData);
            CX509Certificate* tempCert = CX509Certificate::NewLC(*certData);
            RArray<TUid> appArray;
            CleanupClosePushL(appArray);
            const TPtrC8* serialNumber = tempCert->DataElementEncoding(
                  CX509Certificate::ESerialNumber);
            const TPtrC8* issuername = tempCert->DataElementEncoding(
                  CX509Certificate::EIssuerName);

            iPkiService.SetApplicabilityL(
                       *issuername,
                       *serialNumber,
                       appArray);

            CleanupStack::PopAndDestroy(3); // appArray, tempcert
            
              //get CA from chain
            TFileName rootCAFile=GetCAFromFileListL(*subjectName, iCurrOtherCaCertList);
            CleanupStack::PopAndDestroy(subjectName);
            subjectName=NULL;
            subjectName = CertSubjectNameL(rootCAFile);
            CleanupStack::PushL(subjectName);
            
            //Set highest CA as trusted
            certData = iFileUtil.LoadFileDataL(rootCAFile);
            CleanupStack::PushL(certData);
            tempCert = CX509Certificate::NewLC(*certData);
            CleanupClosePushL(appArray);
            appArray.AppendL(TUid::Uid(KUidVpnManager));
            serialNumber = tempCert->DataElementEncoding(
                  CX509Certificate::ESerialNumber);
            issuername = tempCert->DataElementEncoding(
                  CX509Certificate::EIssuerName);

            iPkiService.SetApplicabilityL(
                       *issuername,
                       *serialNumber,
                       appArray);
 
            CleanupStack::PopAndDestroy(3); // appArray, tempcert, certData
            }
        patchInfo->SetCertSubjectNameL(*subjectName);

        patchInfoList->AppendL(patchInfo);
        CleanupStack::PopAndDestroy(subjectName);
        subjectName=NULL;
        CleanupStack::Pop(patchInfo); // patcInfo (now owned by the list)
        }

    // ... then, append also the user certificates.
    for (TInt i = 0; i < iCurrUserCertList->Count(); i++)
        {
        TInt keySize = 0;
        HBufC8* subjectName = CertInfoL(iCurrUserCertList->At(i), keySize);
        CleanupStack::PushL(subjectName);

        CPolicyPatchInfo* patchInfo = new (ELeave) CPolicyPatchInfo();
        CleanupStack::PushL(patchInfo);

        TParse fileNameParser;
        fileNameParser.Set(iCurrUserCertList->At(i), NULL, NULL);

        patchInfo->iCertFileName.Copy(fileNameParser.NameAndExt());
        patchInfo->SetCertSubjectNameL(*subjectName);
        patchInfo->SetUserCertKeyLen(keySize);

        patchInfoList->AppendL(patchInfo);

        CleanupStack::Pop(); // patchInfo (now owned by the list)
        CleanupStack::PopAndDestroy(); // subjectName
        }

    CleanupStack::Pop(); // patchInfoList, ownership transferred

    LOG_("<- CPolicyImporter::BuildPolicyPatchInfoListL()");
    return patchInfoList;
    }
void CAccPolAudioUnitBase::CopyL ( const CAccPolAudioUnitBase& aAudioUnitBaseObject )
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::operator() - Enter" );
    // Copy base	
    CAccPolObjectBase::operator=( ( CAccPolObjectBase& )aAudioUnitBaseObject );

    //Copy Unit id
    iUnitId = aAudioUnitBaseObject.UnitId();
    RArray<TInt> sourceIds;
    CleanupClosePushL( sourceIds );
    
    //Copy source Ids
    aAudioUnitBaseObject.GetSourceIds( sourceIds );

    for( TInt i = 0; i < sourceIds.Count(); i++ )
        {
        iSourceId.AppendL( sourceIds.operator[]( i ) );
        }

    //Copy previous unit id
    iPreUnitId = aAudioUnitBaseObject.PreviousUnitId();

    //Copy audio controls.
    RPointerArray<CAccPolAudioControlBase> audioControls;
    CleanupClosePushL( audioControls );
    
    aAudioUnitBaseObject.GetAudioControlsL( audioControls );
    
    for( TInt j = 0; j < audioControls.Count(); j++ )
        {
        TUint8 objectType;
        objectType = audioControls.operator[]( j )->ObjectType();

        switch( objectType )
            {
            case EAccPolAudioVolumeControlObject:
                {
                CAccPolVolumeControl *volumeControl =
                    CAccPolVolumeControl::NewL();
                CleanupStack::PushL( volumeControl );
                *volumeControl
                    = *( CAccPolVolumeControl* )audioControls.operator[]( j );
                iAudioControls.AppendL( volumeControl );
                CleanupStack::Pop();
                }
                break;

            case EAccPolAudioMuteControlObject:
                {
                CAccPolMuteControl *muteControl = CAccPolMuteControl::NewL();
                CleanupStack::PushL( muteControl );
                *muteControl
                    = *( CAccPolMuteControl* )audioControls.operator[]( j );
                iAudioControls.AppendL( muteControl );
                CleanupStack::Pop();
                }
                break;

            case EAccPolAudioInputControlObject:
                {
                CAccPolInputControl *inputControl = CAccPolInputControl::NewL();
                CleanupStack::PushL( inputControl );
                *inputControl
                    = *( CAccPolInputControl* )audioControls.operator[]( j );
                iAudioControls.AppendL( inputControl );
                CleanupStack::Pop();
                }
                break;

            default:
                {
                User::Leave( KErrNotSupported );
                }
                break;
            }
        }

    CleanupStack::PopAndDestroy (); //audioControls...dont use ResetAndDestroy on this!
    CleanupStack::PopAndDestroy (); //sourceIds
        
    
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::operator() - Return" );
    }
void CMMAAudioRecorderFactory::MediaIdsL(RArray<TUid>& aMediaIds)
{
    User::LeaveIfError(aMediaIds.Append(KUidMediaTypeAudio));
}
void QMLBackendTriggerChangeAO::RunL()
{
    switch (iStatus.Int()) {
        case KErrNone :
#if 0
            //implementation takes the updation, deletion into consideration
            //from the UI, which is'nt possible with the current UI for LBT.
            //The same should be considered once made availbale as part of the UI
            //check for Multiple trigger change events
            if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventMultiple) {
                CMonitorTriggerInfo* triggerInfo1 = NULL;

                CMonitorTriggerInfo* triggerInfo2 = NULL;

                CMonitorTriggerInfo* triggerInfo3 = NULL;

                TInt i = 0, count = 0;

                RPointerArray < CLbtTriggerInfo > trigInfoList;

                CLbtTriggerEntry* entry = NULL;

                //retrieve the list of triggers created by the client
                iLbt.GetTriggersL(trigInfoList);

                CleanupClosePushL(trigInfoList);

                count = trigInfoList.Count();

                //get the header of the linked list holding the information
                //of the trigger
                triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo();

                while (triggerInfo1) {
                    for (i = 0; i < count; i++) {
                        //get the trigger entryinfo
                        entry = trigInfoList[i]->TriggerEntry();

                        //if the triggerinfo retrieved matches the trigInfoList
                        //id break
                        if (triggerInfo1->iTriggerID == entry->Id())
                            break;
                    }

                    triggerInfo2 = triggerInfo1->next;

                    if (i == count)   //if the triggerinfo1->triggerid not found
                        //in the trigger list of the LBT server,
                        //remove the triggerinfo from the linked list
                    {
                        iTriggerMonitorInfo->removeMonitorTriggerInfo(
                            triggerInfo1->iTriggerID);
                    } else {

                        //if triggerinfo1->triggerid is found in the trigger list,
                        //and if it is an entry trigger, search for the corresponding
                        //exit trigger in the linked list
                        if (triggerInfo1->iType == EntryTrigger)
                            triggerInfo3 = iTriggerMonitorInfo->getMonitorTriggerInfo(
                                               triggerInfo1->iParent , ExitTrigger);

                        //if triggerinfo1->triggerid is found in the trigger list,
                        //and if it is an entry trigger, search for the corresponding
                        //entry trigger in the linked list
                        else if (triggerInfo1->iType == ExitTrigger)
                            triggerInfo3 = iTriggerMonitorInfo->getMonitorTriggerInfo(
                                               triggerInfo1->iParent, EntryTrigger);

                        //callback called for the notification change event of the trigger
                        if (triggerInfo3) {

                            (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, trigInfoList[i],
                                    triggerInfo3->iTriggerID);
                        } else {
                            (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, trigInfoList[i],
                                    NULL);
                        }

                    }
                    triggerInfo3 = NULL;

                    triggerInfo1 = triggerInfo2;
                }

                CleanupStack::Pop(1);

                //cloae the trigInfoList, holding the list of trigger
                //info
                trigInfoList.Close();

            }
            //check for trigger delete event
            else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventDeleted) {
                //delete the entry from the linked list,corresponding to the
                //iTriggerChangeEvent.iTriggerId
                iTriggerMonitorInfo->removeMonitorTriggerInfo(
                    iTriggerChangeEvent.iTriggerId);
            }
            //check for trigger updation event
            else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventUpdated) {
                CLbtTriggerInfo *info = NULL;

                //get the triggerinfo from the linked list corresponding
                //to the iTriggerChangeEvent.iTriggerId
                CMonitorTriggerInfo* triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo(
                                                        iTriggerChangeEvent.iTriggerId);

                if (!triggerInfo1)
                    break;

                //get the triggerinfo of trigger with id - iTriggerChangeEvent.iTriggerId
                //from the LBT server
                info = iLbt.GetTriggerLC(iTriggerChangeEvent.iTriggerId);

                if (info == NULL)
                    break;

                //change in one-trigger,must update the corresponding entry/exit
                //trigger
                if (triggerInfo1) {
                    CMonitorTriggerInfo* triggerInfo2 = NULL;

                    //if the trigger updated is EntryTrigger, get the information
                    //of the corresponding ExitTrigger if any,from the
                    //linked list
                    if (triggerInfo1->iType == EntryTrigger)
                        triggerInfo2 = iTriggerMonitorInfo->getMonitorTriggerInfo(
                                           triggerInfo1->iParent, ExitTrigger);

                    //if the trigger updated is ExitTrigger, get the information
                    //of the corresponding EntryTrigger if any,fro mthe
                    //linked list
                    else if (triggerInfo1->iType == ExitTrigger)
                        triggerInfo2 = iTriggerMonitorInfo->getMonitorTriggerInfo(
                                           triggerInfo1->iParent, EntryTrigger);

                    //callback called for the notification change event for the trigger
                    if (triggerInfo2) {
                        (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, info,
                                triggerInfo2->iTriggerID);
                    } else {
                        (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, info,
                                NULL);
                    }
                }

                //pop and destroy the triggerinfo retrived from GetTriggerLC()
                CleanupStack::PopAndDestroy(info);
            }
#endif
            if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventMultiple) {

                CMonitorTriggerInfo* triggerInfo1 = NULL;

                CMonitorTriggerInfo* triggerInfo2 = NULL;

                TInt i = 0, count = 0;

                RArray < TLbtTriggerId > triggerIdList;


                //retrieve the list of trigger IDs created by the client
                TRAPD(ret, iLbt.ListTriggerIdsL(triggerIdList));

                if (ret != KErrNone) {
                    break;
                }

                CleanupClosePushL(triggerIdList);

                count = triggerIdList.Count();

                //get the header of the linked list holding the information
                //of the trigger
                triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo();

                while (triggerInfo1) {
                    for (i = 0; i < count; i++) {
                        //if the triggerinfo retrieved matches the triggerIdList
                        //id break
                        if (triggerInfo1->iTriggerID == triggerIdList[i])
                            break;
                    }

                    triggerInfo2 = triggerInfo1->next;

                    if (i == count)   //if the triggerinfo1->triggerid not found
                        //in the trigger list of the LBT server,
                        //remove the triggerinfo from the linked list
                    {
                        iTriggerMonitorInfo->removeMonitorTriggerInfo(
                            triggerInfo1->iTriggerID);
                    }

                    triggerInfo1 = triggerInfo2;
                }

                CleanupStack::Pop(1);

                //close the trigInfoList, holding the list of trigger
                //info
                triggerIdList.Close();
            }

            //check for trigger delete event
            else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventDeleted) {
                //delete the entry from the linked list,corresponding to the
                //iTriggerChangeEvent.iTriggerId
                iTriggerMonitorInfo->removeMonitorTriggerInfo(
                    iTriggerChangeEvent.iTriggerId);
            }
            break;

        default :
            break;
    }

    //request for the notification of any notification change events
    NotifyChangeEvent();
}
Esempio n. 16
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::Render( )
//
//  Description:		Draws the selection rect and handles
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RSingleSelection::Render( RDrawingSurface& drawingSurface, const R2dTransform& transform, const RIntRect& rcRender, BOOLEAN fRenderIfLocked ) const
	{
	// Get the component attributes
	const		RComponentAttributes& componentAttributes = m_pSelectedObject->GetComponentAttributes( );
	BOOLEAN	fIsLocked = componentAttributes.IsLocked( );

	if( fRenderIfLocked || !fIsLocked )
		{
		// Set surface attributes
		drawingSurface.SetPenWidth( kSelectionOutlineWidth );
		drawingSurface.SetPenStyle( kSolidPen );
		
		RRealRect			resizeHandleRect;

		// Draw the resize handles
		if( componentAttributes.IsResizable( FALSE ) )
			{
			RArray<RRealRect>					rectList;
			RRealSize	scaleFactor( kDummyScale, kDummyScale );
			scaleFactor = m_pSelectedObject->ApplyResizeConstraint( scaleFactor );

			GetResizeSelectionHandle( resizeHandleRect, transform, kTopLeftResizeHandle, TRUE );
			rectList.InsertAtEnd( resizeHandleRect );

			GetResizeSelectionHandle( resizeHandleRect, transform, kTopRightResizeHandle, TRUE );
			rectList.InsertAtEnd( resizeHandleRect );

			GetResizeSelectionHandle( resizeHandleRect, transform, kBottomRightResizeHandle, TRUE );
			rectList.InsertAtEnd( resizeHandleRect );

			GetResizeSelectionHandle( resizeHandleRect, transform, kBottomLeftResizeHandle, TRUE );
			rectList.InsertAtEnd( resizeHandleRect );

			if ( !AreFloatsEqual( scaleFactor.m_dy, kConstrainedScale ) )
				{
				GetResizeSelectionHandle( resizeHandleRect, transform, kBottomResizeHandle, TRUE );
				rectList.InsertAtEnd( resizeHandleRect );

				GetResizeSelectionHandle( resizeHandleRect, transform, kTopResizeHandle, TRUE );
				rectList.InsertAtEnd( resizeHandleRect );
				}

			if ( !AreFloatsEqual( scaleFactor.m_dx, kConstrainedScale ) )
				{
				GetResizeSelectionHandle( resizeHandleRect, transform, kRightResizeHandle, TRUE );
				rectList.InsertAtEnd( resizeHandleRect );

				GetResizeSelectionHandle( resizeHandleRect, transform, kLeftResizeHandle, TRUE );
				rectList.InsertAtEnd( resizeHandleRect );
				}

			RArray<RRealRect>::YIterator	iterator		= rectList.Start( );
			RArray<RRealRect>::YIterator	iteratorEnd = rectList.End( );
			if( fIsLocked )
				{
				while ( iterator != iteratorEnd )
					drawingSurface.FrameRectangle( *iterator++ );
				}
			else
				{
				while ( iterator != iteratorEnd )
					drawingSurface.FillRectangle( *iterator++ );
				}
			}

		// Draw the rotate line and handle
		if( componentAttributes.IsRotatable( ) )
			DrawRotateHandle( drawingSurface, transform, rcRender );

		// Draw the selection frame
		m_pSelectedObject->DrawSelectionFrame( drawingSurface, transform );
		}
	}
// -----------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::SaveL
// -----------------------------------------------------------------------------
void CNSmlDsProvisioningAdapter::SaveL(TInt aItem)
	{
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): begin");
	TPckgBuf<TUint32> uid;
	
	RSyncMLDataSyncProfile profile;
	TBool ret = EFalse;
	
	if(iProfiles[aItem]->iServerId != NULL)
	{
	RSyncMLDataSyncProfile ProfileToSearch;
	RArray<TSmlProfileId> arr;
    iSession.ListProfilesL( arr, ESmlDataSync );
    
    TInt ProfileId = KErrNotFound;
    CleanupClosePushL(arr);   	
	for ( TInt index = 0; index < arr.Count(); index++ )
		{
	    TRAPD( error, ProfileToSearch.OpenL(iSession, arr[index], ESmlOpenRead ) );
	    if ( error == KErrNone )
	        {	            	            	        
    	        if ( ( iProfiles[aItem]->iServerId->Des()).Compare(ProfileToSearch.ServerId() ) == 0 )
    	            {
    	            
                    ret = ETrue;                    
                    ProfileId = (TInt)arr[index];
                    ProfileToSearch.Close();
                    break;
                    }	            		    
	        }
	      ProfileToSearch.Close();  
		}
    CleanupStack::PopAndDestroy( &arr );
	
	if( ret )
		{
		profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite );	
		}
	else
		{
	profile.CreateL( iSession );
		}
	CleanupClosePushL( profile );	
	}
	else
	{
		
		profile.CreateL( iSession );
		CleanupClosePushL( profile );	
	}
	
	// ui needs this to be set 0
	profile.SetCreatorId(0);//iProfiles[aItem]->iProfile.SetCreatorId(0);
	profile.SetSanUserInteractionL( iProfiles[aItem]->iServerAlertedAction );
	
	if ( iProfiles[aItem]->iDisplayName )
	    {
	    profile.SetDisplayNameL( iProfiles[aItem]->iDisplayName->Des() );    
	    }
	
	if ( iProfiles[aItem]->iServerId )
	    {
	    profile.SetServerIdL( iProfiles[aItem]->iServerId->Des() );    
	    }
	    
	if ( iProfiles[aItem]->iUsername )   
	    {
	    profile.SetUserNameL( iProfiles[aItem]->iUsername->Des() );    
	    }
	
	if ( iProfiles[aItem]->iPassword )
	    {
	    profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() );    
	    }
	    
	// creates profile -> must be done before opening the connection
	profile.UpdateL();
		
	RSyncMLConnection connection;
	connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid );
	CleanupClosePushL( connection );
		
    if ( (iProfiles[aItem]->iVisitParameter
            && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() )
            || iToNapIDInternetIndicator)
		{
        TUint apId = 0;
        TInt ERROR = KErrNone;
        TInt err1 = KErrNone;

        if (iToNapIDInternetIndicator)
            {
            //Get Access Point from DB or SNAP
            TRAP(err1, apId = WPAdapterUtil::GetAPIDL());
            }

        else
            {
            uid.Copy(iProfiles[aItem]->iVisitParameter->Data() );

            RCmManagerExt  cmmanagerExt;
		    cmmanagerExt.OpenL();
		    CleanupClosePushL(cmmanagerExt);
		    RCmConnectionMethodExt cm;
		    cm = cmmanagerExt.ConnectionMethodL( uid());
		    CleanupClosePushL( cm );

            TRAP( ERROR, apId = cm.GetIntAttributeL(CMManager::ECmIapId) );
            CleanupStack::PopAndDestroy(2); //cmmanager,cm
            }

        //Get default access point in failure of getting AP
        if (ERROR != KErrNone || err1 != KErrNone)
			{
			apId = GetDefaultIAPL();
			}
		
		HBufC8* iapBuf = HBufC8::NewLC( 8 );
		TPtr8 ptrBuf = iapBuf->Des();
		ptrBuf.Num( apId );
		
		connection.SetPropertyL( KNSmlIAPId, *iapBuf );
			
        CleanupStack::PopAndDestroy(); //iapBuf	
		}
		
	if( iProfiles[aItem]->iHostAddress )
		{
		// see if address contains also port
		TBool portFound = EFalse;
		TInt startPos(0);
		if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTP)==0)
		    {
		    startPos=KNSmlDsProvisioningHTTP().Length();		    		    
		    }
		else if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTPS)==0)
		    {
		    startPos=KNSmlDsProvisioningHTTPS().Length();		    		    
		    }
		TPtrC uriPtr = iProfiles[aItem]->iHostAddress->Mid(startPos);
		
		if(uriPtr.Locate(KNSmlDMColon)!=KErrNotFound)
		    {
			portFound = ETrue;
		    }
	
		if( portFound == EFalse )
			{
			HBufC *uri = 0;
			// port not found from URI -> see if it is given separately				
			if( iProfiles[aItem]->iPort )
				{
				// parse address and port into URI
			
				if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(),
							  iProfiles[aItem]->iPort->Des(), uri ) == KErrNone )
					{
					if(iProfiles[aItem]->iHostAddress)
					{
						delete iProfiles[aItem]->iHostAddress;
						iProfiles[aItem]->iHostAddress = NULL;
					}
					iProfiles[aItem]->iHostAddress = uri->Des().AllocL();
					}
				CleanupStack::PopAndDestroy(); // uri		  
				}
			else
				{
				// use default port
				if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(),
							  KNSmlDsDefaultPort(), uri ) == KErrNone )
					{
					if(iProfiles[aItem]->iHostAddress)
					{
						delete iProfiles[aItem]->iHostAddress;
						iProfiles[aItem]->iHostAddress = NULL;
					}
					iProfiles[aItem]->iHostAddress = uri->Des().AllocL();
					}
				CleanupStack::PopAndDestroy(); // uri		  
				}
			}
		

		connection.SetServerURIL( ConvertTo8LC( iProfiles[aItem]->iHostAddress->Des() ) );
		CleanupStack::PopAndDestroy(); // ConvertTo8LC
		}
		
	// set authtype, HTTPUserName, HTTPPassword
	if( iProfiles[aItem]->iHTTPUserName ||
	    iProfiles[aItem]->iHTTPPassword )
		{
		connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal );
		
		if( iProfiles[aItem]->iHTTPUserName )
			{
			connection.SetPropertyL( KNSmlHTTPUsername, iProfiles[aItem]->iHTTPUserName->Des() );
			}
		if( iProfiles[aItem]->iHTTPPassword )
			{
			connection.SetPropertyL( KNSmlHTTPPassword, iProfiles[aItem]->iHTTPPassword->Des() );
			}
		}
	else
		{
		connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal );
		}
		
	connection.UpdateL();
	CleanupStack::PopAndDestroy(); // connection
	
	
		
	
	
	if(iProfiles[aItem]->iProtocolVersion == ESmlVersion1_1_2 || 
			iProfiles[aItem]->iProtocolVersion == ESmlVersion1_2 )
	{
		profile.SetProtocolVersionL(iProfiles[aItem]->iProtocolVersion);
	}

	
	
	
	
		
	TInt iDataProvElementCount = iProfiles[aItem]->iDataProvElement.Count();
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: before Start");
	for ( TInt i = 0; i < iDataProvElementCount; i++ )
		{
        _DBG_FILE(
                "CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: In");
		RSyncMLDataProvider dataProvider;

        TRAPD(error, dataProvider.OpenL(iSession,
                iProfiles[aItem]->iDataProvElement[i]->iUid));
		if (!error)
		    {
		    CleanupClosePushL(dataProvider);
            if (ret)
                {
                RArray<TSmlTaskId> providers;
                profile.ListTasksL(providers);
                TInt dataprovcount = providers.Count();

                for (TInt i = 0; i < dataprovcount; i++)
                    {
                    TSmlTaskId taskID = providers[i];
                    RSyncMLTask task;
                    task.OpenL(profile, taskID);
                    CleanupClosePushL(task);

                    if (dataProvider.Identifier() == task.DataProvider())
                        {
                        profile.DeleteTaskL(taskID);
                        CleanupStack::PopAndDestroy();
                        break;
                        }

                    CleanupStack::PopAndDestroy();

                    }
                providers.Reset();
                providers.Close();

                }
            HBufC* localDB = dataProvider.DefaultDataStoreName().AllocLC();
            _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): DB value");
            DBG_ARGS(
                    iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des().Ptr());

            RSyncMLTask task;
            task.CreateL(
                    profile,
                    iProfiles[aItem]->iDataProvElement[i]->iUid,
                    iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des(),
                    localDB->Des());
            CleanupClosePushL(task);
            TRAPD(err, task.UpdateL());
            if (err != KErrAlreadyExists && err != KErrNone)
                {
                User::Leave(err);
                }
            CleanupStack::PopAndDestroy(3); // task, localDB, dataProvider
		    }
		
		}
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: after End");
				
	profile.UpdateL();
	iProfiles[aItem]->iProfileId = profile.Identifier();
	CleanupStack::PopAndDestroy( &profile );
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): end");
	}
Esempio n. 18
0
void CEmTubeSearchView::HandleCommandL( TInt aCommand )
	{
	TInt which = CurrentToActual();

	switch(aCommand)
		{
		case EMTVSendViaBluetoothCommand:
			{
			CSendUi* sendUi = CSendUi::NewLC();
			CMessageData* mdata = CMessageData::NewLC();
			mdata->AppendAttachmentL( iAppUi->SearchEntries()[ which ]->SavedFileName() );
			sendUi->CreateAndSendMessageL( KSenduiMtmBtUid, mdata );
			CleanupStack::PopAndDestroy( mdata );
			CleanupStack::PopAndDestroy( sendUi );
			}
		break;

		case EMTVSearchViewDownloadCommand:
			{
//			iAppUi->CancelDownloadImageL();
			iContainer->DownloadL( );
			}
		break;

		case EMTVAddToPlaylistCommand:
			{
			RArray<TInt> indices;
			CleanupClosePushL( indices );
			CAknSinglePopupMenuStyleListBox* plist = new(ELeave) CAknSinglePopupMenuStyleListBox;
			CleanupStack::PushL(plist);

		    CAknPopupList* popupList = CAknPopupList::NewL( plist, R_AVKON_SOFTKEYS_MENU_LIST, AknPopupLayouts::EPopupSNotePopupWindow);
		    CleanupStack::PushL(popupList);

		    plist->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
		    plist->CreateScrollBarFrameL(ETrue);
		    plist->ScrollBarFrame()->SetScrollBarVisibilityL(
		                               CEikScrollBarFrame::EOff,
		                               CEikScrollBarFrame::EAuto);

		    MDesCArray* itemList = plist->Model()->ItemTextArray();
		    CDesCArray* items = (CDesCArray*) itemList;

		    popupList->SetTitleL( KNullDesC() );

		    HBufC* txt = StringLoader::LoadLC( R_PLAYLIST_CREATE_NEW_TXT );
		    indices.Append( -1 );
		    items->AppendL( *txt );
		    CleanupStack::PopAndDestroy( txt );

		    TInt count = iManager->PlaylistsCount();
			for(TInt i=0;i<count;i++)
				{
				CEmTubePlaylist* pl = iManager->Playlist( i );
				if( pl->Editable() )
					{
					indices.Append( i );
			    	items->AppendL( pl->Name() );
					}
			    }

		    TInt popupOk = popupList->ExecuteLD();
		    if(popupOk)
		        {
		        TInt idx = indices[ plist->CurrentItemIndex() ];
				if( idx == -1 )
		        	{
					TBuf<64> name;
					CAknTextQueryDialog* dlg = new(ELeave)CAknTextQueryDialog( name, CAknQueryDialog::ENoTone );
					dlg->SetPredictiveTextInputPermitted( ETrue );
					TInt ret = dlg->ExecuteLD( R_EMTV_ADD_PLAYLIST_DIALOG );
					if( ret )
						{
						iManager->AddPlaylistL( name, CEmTubePlaylist::EPlaylistUserDefined );
						idx = iManager->PlaylistsCount() - 1;
						}
		        	}

				if( idx >= 0 )
					{
					CEmTubePlaylist* pl = iManager->Playlist( idx );
					CVideoEntry* e = iAppUi->SearchEntries()[ which ];
					if( iAppUi->SearchDisplayMode() == CEmTubeAppUi::ESearchDisplaySearchEntries ||
							iAppUi->SearchDisplayMode() == CEmTubeAppUi::ESearchDisplayFavEntries )
						pl->AddEntryL( e->Url(), e->MediaTitle(), CEmTubePlaylistEntry::EPlaylistEntryRemote );
					else
						pl->AddEntryL( e->SavedFileName(), e->MediaTitle(), CEmTubePlaylistEntry::EPlaylistEntryLocal );
					}
		        }
		    CleanupStack::Pop( popupList );
		    CleanupStack::PopAndDestroy( plist );
		    CleanupStack::PopAndDestroy( &indices );
			}
		break;

		case EMTVSearchViewAddToFCommand:
			{
			iContainer->AddCurrentItemToFavsL();
			}
		break;

		case EMTVSearchViewRemoveFromFCommand:
			{
			iContainer->RemoveCurrentItemFromFavsL();
			}
		break;

		case EMTVSearchCommand:
			{
			if( iAppUi->SearchDialogL() )
				{
// TODO: when displaying featured (for example), new search (from menu) - change navi pane text
//				if(no tabs, one plugin)
//					iContainer->SetNaviPaneTextL();

				StartProgressBarL( EFalse );
				}
			}
		break;

		case EMTVSearchViewPlayCommand:
			{
			if( which != KErrNotFound )
				{
				iAppUi->CancelDownloadImageL();
				if( iAppUi->SearchDisplayMode() == CEmTubeAppUi::ESearchDisplaySavedEntries )
					iAppUi->OpenFileL( iAppUi->SearchEntries()[ which ]->SavedFileName(), iAppUi->SearchEntries()[ which ]->MediaTitle() );
				else
					iAppUi->OpenFileL( iAppUi->SearchEntries()[ which ] );
				}
			}
		break;

		case EMTVDeleteClipCommand:
			{
			iContainer->DeleteSavedClipL();
			}
		break;

		case EMTVRenameClipCommand:
			{
			iContainer->RenameSavedClipL();
			}
		break;

		case EMTVShowRelatedCommand:
			{
			if( which != KErrNotFound )
				{
				iAppUi->CancelDownloadImageL();
				CVideoEntry* e = iAppUi->SearchEntries()[ which ];
				iAppUi->SearchString().Copy( e->RelatedUrl() );
				StartProgressBarL( EFalse );
				iAppUi->ClearSearchResults();
				iAppUi->SearchL( ERelatedClips, ERelevance, EPeriodIrrelevant );
				}
			}
		break;

		case EMTVShowUserCommand:
			{
			if( which != KErrNotFound )
				{
				iAppUi->CancelDownloadImageL();
				CVideoEntry* e = iAppUi->SearchEntries()[ which ];
				iAppUi->SearchString().Copy( e->AuthorVideosUrl() );
				StartProgressBarL( EFalse );
				iAppUi->ClearSearchResults();
				iAppUi->SearchL( EUserClips, EUpdated, EPeriodIrrelevant );
				}
			}
		break;

		case EMTVSearchViewDetailsCommand:
			{
			iContainer->ShowToolbar( EFalse );
			CEmTubeDetailsDialog::RunDialogL( iAppUi->SearchEntries()[ which ] );
			iContainer->ShowToolbar( ETrue );
			}
		break;

		case EMTVSearchViewBackCommand:
			{
			iContainer->ClearToolbar();
			iAppUi->CancelDownloadImageL();
			iAppUi->HandleCommandL( EMTVActivateMainViewCommand );
			}
		break;

		case EMTVProgressDialogCancel:
			{
			iAppUi->CancelDownloadImageL();
			if( iAppUi->SearchEntries().Count() )
				iContainer->CancelProgressL();
			else
				iAppUi->HandleCommandL( EMTVActivateMainViewCommand );
			}
		break;

		default:
			{
			iAppUi->HandleCommandL(aCommand);
			}
		break;
		}
	}
// ----------------------------------------------------------------------------
// Message dispatcher
// ----------------------------------------------------------------------------
//
void CMPXPlaybackSession::DispatchMessageL( const RMessage2& aMessage, TInt& aMsgHandleResult )
    {
    aMsgHandleResult = KErrNone;
    //
    // All methods apart from the player creation methods, require a player
    //
    TInt op=aMessage.Function();
    if (op != EPbsSetMode)
        {
        CheckPlayerL();
        }
    MPX_DEBUG3("-->CMPXPlaybackSession::DispatchMessageL %d, this 0x%08x",
            op, this);
    switch(op)
        {
        case EPbsSetMode:
            {
            SetModeL(aMessage);
            break;
            }
        case EPbsGetClients:
            {
            RArray<TProcessId> procArray;
            ::CopyArrayL<TProcessId>(
                iPlayer->ClientList()->ClientProcessList(),
                procArray );
            TProcessId lastPid = static_cast<CMPXPlaybackServer*>(
                         const_cast<CServer2*>(Server()))->LastActiveProcessId();

            TInt index( procArray.Find( lastPid ));
            if ( KErrNotFound != index && index )
                {
                procArray.Remove( index );
                procArray.Insert( lastPid, 0 );
                }
            ::CreateBufferL<TProcessId>(
                            procArray.Array(),
                            iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            procArray.Close();
            break;
            }
        case EPbsGetSyncBuffer:
            {
            aMessage.WriteL(0,iSyncBuffer->Ptr(0));
            delete iSyncBuffer;
            iSyncBuffer = NULL;
            break;
            }
        case EPbsGetAsyncBuffer:
            {
            //In case of other application leaving, causing us to leave
            //we could have a task that does not get removed from the top of the queue
            //but the data for that task has been deleted.
            //When the task runs again, there will be no data causing a panic - leave if this occurs
            User::LeaveIfNull(iAsyncBuffer);                         
            aMessage.WriteL(0,iAsyncBuffer->Ptr(0));
            delete iAsyncBuffer;
            iAsyncBuffer = NULL;       
            break;                            
            }
        case EPbsInitFromCollection:
            {
            MPXUser::CreateBufferL(aMessage, 0, iSyncBuffer);
            CMPXCollectionPlaylist* p = NULL;
            ::NewFromBufferL(*iSyncBuffer, p);
            delete iSyncBuffer;
            iSyncBuffer = NULL;
            CleanupStack::PushL(p);
            iPlayer->InitL(*p,aMessage.Int1());
            CleanupStack::PopAndDestroy(p);
            }
            break;
        case EPbsInitFromUri:
            {
            CBufBase* buf0(NULL);
            MPXUser::CreateBufferL(aMessage,0,buf0);
            CleanupStack::PushL(buf0);

            // Type parameter is optional
            if ( aMessage.GetDesLength( 1 ) > 0 )
                {
                CBufBase* buf1(NULL);
                MPXUser::CreateBufferL(aMessage,1,buf1);
                CleanupStack::PushL(buf1);
                iPlayer->InitL(MPXUser::Ptr(buf0->Ptr(0)), buf1->Ptr(0));
                CleanupStack::PopAndDestroy(buf1);
                }
            else
                {
                MPX_DEBUG2("CMPXPlaybackSession::DispatchMessageL %d: Type is empty", op);
                iPlayer->InitL( MPXUser::Ptr( buf0->Ptr(0) ), KNullDesC8 );
                }
            CleanupStack::PopAndDestroy(buf0);
            }
            break;
        case EPbsInitFromFile:
            {
            InitFromFileL(aMessage);
            break;
            }
        case EPbsInitStreamingFromUri:
            {            
            CBufBase* buf0(NULL);
            MPXUser::CreateBufferL(aMessage,0,buf0);
            CleanupStack::PushL(buf0);

            // Type parameter is optional
            if ( aMessage.GetDesLength( 1 ) > 0 )
                {
                CBufBase* buf1(NULL);
                MPXUser::CreateBufferL(aMessage,1,buf1);
                CleanupStack::PushL(buf1);
                iPlayer->InitStreamingL(MPXUser::Ptr(buf0->Ptr(0)), buf1->Ptr(0), aMessage.Int2());
                CleanupStack::PopAndDestroy(buf1);
                }
            else
                {
                MPX_DEBUG2("CMPXPlaybackSession::DispatchMessageL %d: Type is empty", op);
                iPlayer->InitStreamingL( MPXUser::Ptr( buf0->Ptr(0) ), KNullDesC8, aMessage.Int2() );
                }
            CleanupStack::PopAndDestroy(buf0);
            break;                          
            }
         case EPbsInitStreamingFromFile:
            {
            RFile file;
            User::LeaveIfError(file.AdoptFromClient(aMessage,0,1));
            iPlayer->InitStreamingL(file, aMessage.Int2());
            file.Close();
            break;
            }            
        case EPbsCancelRequest:
            {
            CancelRequests();
            break;
            }
        case EPbsGetState:
            {
            aMsgHandleResult = iPlayer->State();
            break;
            }
        case EPbsSetProperty:
            {
            iPlayer->SetL(static_cast<TMPXPlaybackProperty>(aMessage.Int0()),
                          aMessage.Int1());
            break;
            }
        case EPbsGetProperty:
            {
            SetAsync(aMessage);
            iPlayer->PropertyL(
                    static_cast<TMPXPlaybackProperty>(aMessage.Int0()),*this);
            break;
            }
        case EPbsGetPlayerTypes:
            {
            RArray<TMPXPlaybackPlayerType> pluginTypes;
            CleanupClosePushL(pluginTypes);
            RArray<TInt> types;
            CleanupClosePushL(types);
            iPlayer->PluginHandler()->GetPluginTypes(types);
            for (TInt i=0; i< types.Count(); ++i)
                {
                pluginTypes.AppendL(
                        static_cast<TMPXPlaybackPlayerType>(types[i]));
                }
            CleanupStack::PopAndDestroy(&types);
            ::CreateBufferL<TMPXPlaybackPlayerType>(
                                    pluginTypes.Array(),
                                    iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            CleanupStack::PopAndDestroy(&pluginTypes);
            break;
            }
        case EPbsGetPlayerTypeDisplayName:
            {
            const TDesC& playerName = iPlayer->PluginHandler()->PlayerName(
                        static_cast<TMPXPlaybackPlayerType>(aMessage.Int0()));
            aMsgHandleResult = 0;
            if (playerName.Length()>0)
                {
                MPXUser::CreateBufferL(playerName, iSyncBuffer);
                aMsgHandleResult = iSyncBuffer->Size();
                }
            break;
            }
        case EPbsGetAllPlayersUids:
            {
            RArray<TUid> uids;
            CleanupClosePushL(uids);
            iPlayer->PluginHandler()->GetPluginUids(uids);

            ::CreateBufferL<TUid>(
                    uids.Array(),
                    iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            CleanupStack::PopAndDestroy(&uids);
            break;
            }
        case EPbsGetPlayersUidsForType:
            {
            aMsgHandleResult = CreatePlayerUidsBufferL(aMessage);
            break;
            }
        case EPbsGetSubPlayerNamesByUid:
            {
            SetAsync(aMessage);
            iPlayer->SubPlayerNamesL(TUid::Uid(aMessage.Int0()),*this);
            break;
            }
        case EPbsSelectPlayerByType:
            {
            iPlayer->PluginHandler()->SelectPlayersL(
                         static_cast<TMPXPlaybackPlayerType>(aMessage.Int0()));
            break;
            }
        case EPbsSelectPlayerByUid:
            {
            iPlayer->PluginHandler()->SelectPlayerL(TUid::Uid(aMessage.Int0()));
            break;
            }
        case EPbsSelectSubPlayer:
            {
            iPlayer->PluginHandler()->SelectSubPlayerL(
                                  TUid::Uid(aMessage.Int0()),aMessage.Int1());
            break;
            }
        case EPbsClearPlayerSelection:
            {
            iPlayer->PluginHandler()->ClearSelectPlayersL();
            break;
            }
        case EPbsGetSelection:
            {
            GetSelectionL(aMessage);
            break;
            }
        case EPbsPlayerFound:
            {
            aMsgHandleResult = iPlayer->PluginHandler()->PlayerFound();
            break;
            }
        case EPbsGetPlayerType:
            {
            aMsgHandleResult = iPlayer->PluginHandler()->PluginType();
            break;
            }
        case EPbsGetTypeName:
            {
            MPXUser::CreateBufferL(iPlayer->PluginHandler()->PlayerName(),
                                   iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            break;
            }
        case EPbsGetSubPlayerIndex:
            {
            aMsgHandleResult = iPlayer->PluginHandler()->SubPlayer();
            break;
            }
        case EPbsGetPlayerUid:
            {
            TPckgC<TInt> uidPkg((iPlayer->PluginHandler()->PluginUid()).iUid);
            aMessage.Write(0,uidPkg);
            break;
            }
        case EPbsGetCollectionPlaylist:
            {
            aMsgHandleResult = 0;
            if (iPlayer->Playlist())
                {
                ::CreateBufferL<CMPXCollectionPlaylist>(*(iPlayer->Playlist()),
                                                        iSyncBuffer);
                aMsgHandleResult = iSyncBuffer->Size();
                }
            break;
            }
        case EPbsGetFile:
            {
            const RFile& file = iPlayer->File();
            if (file.SubSessionHandle())
                {
                aMsgHandleResult = file.TransferToClient(aMessage,0); //message completed
                }
            else
                {
                TPckgC<TInt> handle(KErrNotFound);
                aMessage.Write(0, handle);
                }
            break;
            }
        case EPbsGetUri:
            {
            aMsgHandleResult=0;
            if (iPlayer->Uri().Length()>0)
                {
                MPXUser::CreateBufferL(iPlayer->Uri(),iSyncBuffer);
                aMsgHandleResult = iSyncBuffer->Size();
                }
            break;
            }
        case EPbsGetMedia:
            {
            SetAsync( aMessage );
            CMPXCommand* cmd( CMPXCommand::NewL( aMessage.Int1() ) );
            CleanupStack::PushL( cmd );
            iPlayer->MediaL( *this, *cmd );
            CleanupStack::PopAndDestroy( cmd );
            break;
            }
        case EPbsGetSupportedMimeTypes:
            {
            CDesCArray* mimeTypes =
               iPlayer->PluginHandler()->SupportedMimeTypesL();
            CleanupStack::PushL(mimeTypes);
            MPXUser::CreateBufferL((const MDesCArray*)mimeTypes, iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            CleanupStack::PopAndDestroy(mimeTypes);
            }
            break;
        case EPbsGetSupportedExtensions:
            {
            CDesCArray* exts =
              iPlayer->PluginHandler()->SupportedExtensionsL();
            CleanupStack::PushL(exts);
            MPXUser::CreateBufferL((const MDesCArray*)exts, iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            CleanupStack::PopAndDestroy(exts);
            }
            break;
        case EPbsGetSupportedSchemas:
            {
            CDesCArray* schemas =
                 iPlayer->PluginHandler()->SupportedSchemasL();
            CleanupStack::PushL(schemas);
            MPXUser::CreateBufferL((const MDesCArray*)schemas, iSyncBuffer);
            aMsgHandleResult = iSyncBuffer->Size();
            CleanupStack::PopAndDestroy(schemas);
            }
            break;
        case EPbsGetNextMessage:
            {
            ASSERT(iMessageQueue);
            iMessageQueue->SendNext(aMessage);
            iCompleteRequest=EFalse;
            break;
            }
        case EPbsCancelGetMessage:
            {
            ASSERT(iMessageQueue);
            iMessageQueue->Reset();
            break;
            }
        case EPbsCommand:
            {
            CMPXCommand* cmd( NULL );
            ::NewFromMessageL<CMPXMedia>(aMessage, 1, cmd);
            CleanupStack::PushL(cmd);
            iPlayer->CommandL(*cmd, *iMessageQueue);
            CleanupStack::PopAndDestroy(cmd);
            break;
            }
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
        case EPbsInitFromFile64:
            {
            RFile64 file;
            User::LeaveIfError(file.AdoptFromClient(aMessage,0,1));
            iPlayer->Init64L(file);
            file.Close();
            break;
            }
        case EPbsInitStreamingFromFile64:
            {
            RFile64 file;
            User::LeaveIfError(file.AdoptFromClient(aMessage,0,1));
            iPlayer->InitStreaming64L(file, aMessage.Int2());           
            file.Close();
            break;
            }
        case EPbsGetFile64:
            {
            const RFile64& file = iPlayer->File64();
            if (file.SubSessionHandle())
                {
                aMsgHandleResult = file.TransferToClient(aMessage,0); //message completed
                }
            else
                {
                TPckgC<TInt> handle(KErrNotFound);
                aMessage.Write(0, handle);
                }
            break;
            }
#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
        case EPbsSetPrimaryClient:
            {
            aMsgHandleResult = iPlayer->ClientList()->SetPrimaryClient(*iMessageQueue);            
            break;
            }
        default:
            {
            PanicClient(aMessage,KErrNotSupported);
            break;
            }
        }
    MPX_DEBUG1("<---CMPXPlaybackSession::DispatchMessageL");
    }
Esempio n. 20
0
// ---------------------------------------------------------
// CPosTp141::TestInvalidPositionFieldsL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp141::TestInvalidPositionFieldsL()
	{
	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
	RArray<TUint> arr;
	CleanupClosePushL(arr);
	textCriteria->GetPositionFieldsToSearchL(arr);	
	textCriteria->SetTextL(_L("*"));
	textCriteria->SetPositionFieldsToSearchL(arr);

	// Search with empty positionfields list, should find all landmarks
	iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria);
    ExecuteAndDeleteLD(iOperation);
    TInt nr = iLandmarkSearch->NumOfMatches();
    TBuf<100> buf;
    buf.Format(_L("Found %d nr of matches when searching in empty position fields list"), nr);
    iLog->Log(buf);
    
    	
		
	User::LeaveIfError(arr.Append(1));
	User::LeaveIfError(arr.Append(2));
	User::LeaveIfError(arr.Append(3));
	
	textCriteria->SetPositionFieldsToSearchL(arr);
    textCriteria->GetPositionFieldsToSearchL(arr);	
	TBuf<100> buf1;
	for(TInt i=0;i< arr.Count();i++)
	    {
	    buf1.Format(_L(" %d position fields--%d- "),i, arr[i]);
	    iLog->Log(buf1); 
	    }
	
	
    //Clears the position fields list used in a search
    textCriteria->ClearPositionFieldsToSearch();
	textCriteria->GetPositionFieldsToSearchL(arr);
	if(arr.Count()==0)
	{
	    iLog->Log(_L("ClearPositionFieldsToSearch()-Cleared the position fields list used in a search."));
	}
	
	
    
    iLog->Log(_L("Sets the position fields list used in a search"));
	User::LeaveIfError(arr.Append(0));
	User::LeaveIfError(arr.Append(50));
	User::LeaveIfError(arr.Append(500));
	
	textCriteria->SetPositionFieldsToSearchL(arr);
	textCriteria->GetPositionFieldsToSearchL(arr);
	TBuf<100> buf2;
    for(TInt i=0;i< arr.Count();i++)
	    {
	    buf2.Format(_L(" %d position fields--%d- "),i, arr[i]);
	    iLog->Log(buf2); 
	    }
	

	// Search with invalid positionfields list, should NOT find any landmarks
	iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria);
    ExecuteAndDeleteLD(iOperation);
    nr = iLandmarkSearch->NumOfMatches();

    buf.Format(_L("Found %d nr of matches when searching in invalid position fields"), nr);
    iLog->Log(buf);
    
    AssertTrueSecL(nr == 0, _L("We should not find any matches"));
    textCriteria->ClearPositionFieldsToSearch();
    CleanupStack::PopAndDestroy(&arr);
    CleanupStack::PopAndDestroy(textCriteria);
	}
// ---------------------------------------------------------------------------
// Constructor for CLbtContainerFilter
//
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//                     
void CLbtContainerFilter::ConstructL(CLbtContainerFilter* aFilter)
    {
    FUNC_ENTER("CLbtContainerFilter::ConstructL");
    
    if(!aFilter)
    	{
    	return;
    	}

    TInt i;
    // Copy hysterisis array
    RArray<TReal> hystArray;
    aFilter->GetHystRadiusArrayL(&hystArray);
    
    for(i=0;i<hystArray.Count();++i)
    	{
    	iHystRadiusArray.AppendL(hystArray[i]);
    	}
    hystArray.Close();
    
    // Copy trigger rect array
    RArray<CLbtExtendedTriggerInfo::TLbtTriggerRectArea> triggerRectAreaArray;
    aFilter->GetRectAreaArrayL(&triggerRectAreaArray);
    
    for(i=0;i<triggerRectAreaArray.Count();++i)
    	{
    	iTriggerRectAreaArray.AppendL(triggerRectAreaArray[i]);
    	}
    triggerRectAreaArray.Close();
    
    // Copy trigger fired array
    RArray<TBool> triggerFiredArray;
    aFilter->GetTriggerFiredArrayL(&triggerFiredArray);
    
    for(i=0;i<triggerFiredArray.Count();++i)
    	{
    	iTriggerFiredArray.AppendL(triggerFiredArray[i]);
    	}
    triggerFiredArray.Close();
    
    // Copy SID array
    RArray<TSecureId> sidArray;
    aFilter->GetSidArrayL(&sidArray);
    
    for(i=0;i<sidArray.Count();++i)
    	{
    	iSidArray.AppendL(sidArray[i]);
    	}
    sidArray.Close();
    
    // Copy fire on creation array
    RArray<TBool> triggerFireOnCreationArray;
    aFilter->GetTriggerFireOnCreationArrayL(&triggerFireOnCreationArray);
    
    for(i=0;i<triggerFireOnCreationArray.Count();++i)
    	{
    	iTriggerFireOnCreationArray.AppendL(triggerFireOnCreationArray[i]);
    	}
    triggerFireOnCreationArray.Close();
    
    // Copy the startup process array
    RArray<TFileName> triggerstartupProcessArray;
    aFilter->GetStartupProcessArrayL(&triggerstartupProcessArray);
    
    for(i=0;i<triggerstartupProcessArray.Count();++i)
    	{
    	iStartupProcessArray.AppendL(triggerstartupProcessArray[i]);
    	}
    triggerstartupProcessArray.Close();
    }
TVerdict CTestSetSecondaryFltStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
{
	RArray<TUint32> *setfilters = new (ELeave)RArray<TUint32>(10);
	RArray<TUint32> *getfilters = new (ELeave)RArray<TUint32>(10);

	if (TestStepResult()==EPass)
	{
		setfilters->AppendL(KSecondaryFlt);

		/**************First set primary filter*************/

		iSession->Connect();
		TInt iErrCode = iSession->SetSecondaryFiltersEnabled(*setfilters, ETrue);

		if( iErrCode == KErrNone )
		{
			INFO_PRINTF2(_L("Secondary filter has been set with single filter, %d, check log"), (*setfilters)[0]);

			setfilters->Reset();

			iSession->GetSecondaryFiltersEnabled(*setfilters);

			if( setfilters->Count() > 0 )
			{
				if( (*setfilters)[0] == KSecondaryFlt )
				{
					INFO_PRINTF1(_L("Get secondary filter successful"));	
					SetTestStepResult(EPass);
				}
				else
				{
					INFO_PRINTF1(_L("Get secondary filter value does not match with set value"));
					SetTestStepResult(EFail);;
				}
			}
			else
			{
				INFO_PRINTF1(_L("GetFilter() Failed, can not varify the test output"));
				SetTestStepResult(EFail);
			}
		}
	}

	if(TestStepResult() == EPass)
	{
		//prepare test
		getfilters->Reset();
		iSession->GetSecondaryFiltersEnabled(*getfilters);
		iSession->SetSecondaryFiltersEnabled(*getfilters, EFalse);
		setfilters->Reset();
		getfilters->Reset();

		for(TInt i = 0; i < 4096 ; i++ )
		{
			setfilters->AppendL((TUint32)(i));
		}

		TRAPD(err, iSession->SetSecondaryFiltersEnabled(*setfilters, ETrue));
		if( KErrNone == err )
		{
			INFO_PRINTF1(_L("Secondary filter has been set with multiple filters,from 0 to 4095"));
			SetTestStepResult(EPass);
		}
		else
		{
			INFO_PRINTF2(_L("Multiple secondary filters have not been set succesfully, error code %d"), err);
			SetTestStepResult(EFail);
		}

		//Now get the primary filter set above
		iSession->GetSecondaryFiltersEnabled(*getfilters);

		if( getfilters->Count() == setfilters->Count() )
		{	
			INFO_PRINTF1(_L("setfilter and getfilter have the same count"));
			for(TInt i = 0; i < getfilters->Count(); i++)
			{
				for(TInt j = 0; j < setfilters->Count(); j++)
				{
					if( (*getfilters)[i] == (*setfilters)[j] )
						SetTestStepResult(EPass);
					else
						SetTestStepResult(EFail);
				}
			}
		}	
		else
		{
			INFO_PRINTF1(_L("setfilter and getfilter have different counts"));
			INFO_PRINTF2(_L("setfilter has %d"), setfilters->Count());
			INFO_PRINTF2(_L("getfilter has %d"), getfilters->Count());
			SetTestStepResult(EFail);
		}
	}

	setfilters->Close();
	getfilters->Close();

	if(setfilters)
	{
		delete setfilters;
		setfilters=NULL;
	}

	if(getfilters)
	{
		delete getfilters;
		getfilters=NULL;
	}

	return TestStepResult();
}
void CWritableEntryMethodsStep::PrintWritableEntryContents(Swi::RSisRegistryWritableEntry &aEntry)
	{
	INFO_PRINTF1(_L("-------------------------------------\n")); 
	// get the vendor; package name 
	HBufC* vendor = aEntry.UniqueVendorNameL();
	CleanupStack::PushL(vendor);
	HBufC* package = aEntry.PackageNameL();
	CleanupStack::PushL(package);
	INFO_PRINTF3(_L("Package: %S from Vendor: %S"), package, vendor); 
	CleanupStack::PopAndDestroy(package);
	CleanupStack::PopAndDestroy(vendor);

	// get the localised vendor name 
	HBufC* vendorLocal = aEntry.LocalizedVendorNameL();
	CleanupStack::PushL(vendorLocal);
	INFO_PRINTF2(_L("Localised Vendor Name: %S"), vendorLocal); 
	CleanupStack::PopAndDestroy(vendorLocal);

	// get uid
	TUid uid = aEntry.UidL();
	INFO_PRINTF3(_L("Package Uid: %d 0x%08x"), uid.iUid, uid.iUid);
	
	// get the version
	TVersion packageVersion = aEntry.VersionL(); 
	INFO_PRINTF4(_L("Version  %d %d %d"), packageVersion.iMajor, packageVersion.iMinor, packageVersion.iBuild );
	
	// get sids	
	RArray<TUid> sids;
	CleanupClosePushL(sids);
	aEntry.SidsL(sids);
	if (sids.Count() <= 0)
		{
		INFO_PRINTF1(_L("No sids installed!"));
		}
	else 
		{
		for (TInt index = 0; index < sids.Count(); index++)
			{
			INFO_PRINTF2(_L("Sid: 0x%08x was found!"), sids[index]);
			}
		}
	CleanupStack::PopAndDestroy(&sids);

	// get language
	TLanguage language = aEntry.LanguageL();
	INFO_PRINTF3(_L("Package Language: %d 0x%08x"), language, language);

	// get property
	TInt32 propertyKey = 10;
	TInt32 propertyValue = aEntry.PropertyL(propertyKey);
	INFO_PRINTF3(_L("Package property: key %d  value %d"), propertyKey, propertyValue);

	// is present - currenty relies on default value
	TBool isPresent = aEntry.IsPresentL();
	INFO_PRINTF2(_L("Package present is  %d"), isPresent);
  	
  	// is signed
	TBool isSigned = aEntry.IsSignedL();
	INFO_PRINTF2(_L("Package signed is  %d"), isSigned);

	if (isSigned)
		{
		RPointerArray<HBufC8> certChains;
		CleanupResetAndDestroy<RPointerArray<HBufC8> >::PushL(certChains);
		aEntry.CertificateChainsL(certChains);
		INFO_PRINTF2(_L("Package signed with %d chains"), certChains.Count());
		CleanupStack::PopAndDestroy(&certChains);
		}
		
		// check Trust
		switch(aEntry.TrustL())
			{
			case ESisPackageUnsignedOrSelfSigned:
				INFO_PRINTF1(_L("Packaged Trust: Unsigned or self signed"));
				break;
			case ESisPackageCertificateChainNoTrustAnchor:
				INFO_PRINTF1(_L("Packaged Trust: Certificate Chain has no trust anchor in Cert store"));
				break;
			case ESisPackageCertificateChainValidatedToTrustAnchor:
				INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated to Trust Anchor in Cert store"));
				break;
			case ESisPackageChainValidatedToTrustAnchorOCSPTransientError:
				INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Transient Error"));
				break;
			case ESisPackageChainValidatedToTrustAnchorAndOCSPValid:
				INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Valid"));
				break;
			case ESisPackageBuiltIntoRom:
				INFO_PRINTF1(_L("Packaged Trust: Built into ROM"));
				break;
			case ESisPackageValidationFailed:
				INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validation Failed"));
				break;
			default:
				INFO_PRINTF1(_L("Packaged Trust: Unknown"));
				break;
			};
  
	// Time at which the trust was established
  	TTime timeStamp = aEntry.TrustTimeStampL();
  	TBuf <32> dateTimeText;
	TRAP_IGNORE(timeStamp.FormatL(dateTimeText, _L("%H%:1%T%:2%S on %1%/1%2%/2%3")));
	INFO_PRINTF2(_L("Package Trust Established: %S"), &dateTimeText);


    // is in rom
	TBool inRom = aEntry.IsInRomL();
	INFO_PRINTF2(_L("Package inRom is  %d"), inRom);

    // is an augmentation
	TBool isAug = aEntry.IsAugmentationL();
	INFO_PRINTF2(_L("Package isAug is  %d"), isAug);
  	// is preinstalled
	/*  	
    Sis::TInstallType installType = aEntry.InstallTypeL();
	INFO_PRINTF3(_L("Package type is  %d %S"), 
							installType, &installTypeNames[installType]);
	*/
  	// get list of files
  	RPointerArray<HBufC> files;
  	CleanupResetAndDestroy<RPointerArray<HBufC> >::PushL(files);
  	aEntry.FilesL(files);
 	INFO_PRINTF2(_L("Package has %d files"), files.Count());
 	for (TInt i=0; i<files.Count(); i++)
	 	{
	 	INFO_PRINTF3(_L("File %d - file path %S"), i+1, files[i]);	
	 	}
			  	
  	CleanupStack::PopAndDestroy(&files);
  	
    // get the drive selected by the user
 	TChar setDrive = aEntry.SelectedDriveL();
	TUint setdrive(setDrive);
	INFO_PRINTF2(_L("User selected drive is %c"), setdrive); 
	
	INFO_PRINTF1(_L("-------------------------------------\n")); 
	}	
// ---------------------------------------------------------
// CProcessorPacketData::AddLingerL
// ---------------------------------------------------------
//
void CProcessorPacketData::AddLingerL( const TInt aIapId, const TInt aLingerInterval)
    {
    TInt    err( KErrNone );
    
    // Open repository
    CRepository* repository = CRepository::NewLC( KCRUidPDPContextManager );
    
    // Find if an entry for "iapId" already exists in CentRep 
    RArray< TUint32 > foundKeys;
    foundKeys.Reset();
    
    err = repository->FindEqL( KIapColumn,       // partial key
                               KColumnMask,      // key mask
                               aIapId,           // value
                               foundKeys );      // found keys
    
    if ( err == KErrNone || err == KErrNotFound )
        {
        if ( foundKeys.Count() == 0 )
            {
            // Add a new entry
            TInt arrayCount( 0 );
            
            // Get number of iapId&linger entries in Centrep
            err = repository->Get( KPdpContextManagerLingerArrayCount, 
                                   arrayCount );
        
            if ( err == KErrNone )
                {
                arrayCount++;
                
                err = repository->Create( ( KIapColumn | arrayCount ), aIapId ); 
                
                if ( err == KErrNone )
                    {
                    err = repository->Create( ( KLingerColumn | arrayCount ), 
                                               aLingerInterval );     
                    }
                
                if ( err == KErrNone )
                    {
                    // Update number of iapId&linger entries in Centrep
                    err = repository->Set( KPdpContextManagerLingerArrayCount, 
                                           arrayCount );
                    }
                }
            }
        else
            {
            // Update existing entry on current row
            TInt32 row = foundKeys[ 0 ] & KRowMask;
            
            err = repository->Set( ( KLingerColumn | row ), aLingerInterval ); 
            }         
        }
        
    foundKeys.Close();
    CleanupStack::PopAndDestroy( repository );
    
    User::LeaveIfError( err );
    }
Esempio n. 25
0
// ------------------------------------------------
// NotifyRemoved
// ------------------------------------------------
//
void CMdSNotifier::NotifyRemovedL(CMdCSerializationBuffer& aSerializedItemIds, 
								  TBool aItemIsConfidential,
								  RPointerArray<HBufC>& aRemovedItemUriArray,
								  CMdSManipulationEngine* aMEngine )
    {
	aSerializedItemIds.PositionL( KNoOffset );

	const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( aSerializedItemIds );

    RArray<TItemId> objectIdArray;
	CleanupClosePushL( objectIdArray );
    RArray<TItemId> eventIdArray;
	CleanupClosePushL( eventIdArray );
    RArray<TItemId> relationIdArray;
	CleanupClosePushL( relationIdArray );

    //get removed item IDs
	if( itemIds.iObjectIds.iPtr.iCount > 0 )
		{
		aSerializedItemIds.PositionL( itemIds.iObjectIds.iPtr.iOffset );

    	objectIdArray.ReserveL( itemIds.iObjectIds.iPtr.iCount );
    	for( TUint32 i = 0; i < itemIds.iObjectIds.iPtr.iCount; i++ )
    		{
    		TItemId objectId;
    		aSerializedItemIds.ReceiveL( objectId );
    		if ( objectId != KNoId )
    			{
    			objectIdArray.Append( objectId );
    			}
    		}
		}
	if( itemIds.iEventIds.iPtr.iCount > 0 )
		{
		aSerializedItemIds.PositionL( itemIds.iEventIds.iPtr.iOffset );

    	eventIdArray.ReserveL( itemIds.iEventIds.iPtr.iCount );
    	for( TUint32 i = 0; i < itemIds.iEventIds.iPtr.iCount; i++ )
    		{
    		TItemId eventId;
    		aSerializedItemIds.ReceiveL( eventId );
    		if ( eventId != KNoId )
    			{
    			eventIdArray.Append( eventId );
    			}
    		}
		}
	if( itemIds.iRelationIds.iPtr.iCount > 0 )
		{
		aSerializedItemIds.PositionL( itemIds.iRelationIds.iPtr.iOffset );

    	relationIdArray.ReserveL( itemIds.iRelationIds.iPtr.iCount );
    	for( TUint32 i = 0; i < itemIds.iRelationIds.iPtr.iCount; i++ )
    		{
    		TItemId relationId;
    		aSerializedItemIds.ReceiveL( relationId );
    		if ( relationId != KNoId )
    			{
    			relationIdArray.Append( relationId );
    			}
    		}
		}

	const TInt objectCount( objectIdArray.Count() );
	const TInt eventCount( eventIdArray.Count() );
	const TInt relationCount( relationIdArray.Count() );
	if( objectCount != 0 
			|| eventCount != 0 
			|| relationCount != 0 )
		{
		for( TInt i = iEntries.Count() - 1; i >=0; i-- )
	        {
	        TEntry& e = iEntries[i];
	        
	        // if namespace definition IDs don't match skip listener entry
	        if( e.NamespaceDefId() != itemIds.iNamespaceDefId )
	        	{
	        	continue;
	        	}

	        if(aItemIsConfidential && !e.AllowConfidential())
	        	{
	        	continue;	
	        	}

	        RPointerArray<HBufC> uriArray;
	        CleanupResetAndDestroyPushL( uriArray );
	        
	        if( e.iType & EObjectNotifyRemove && objectCount > 0 )
	            {
	            // collect matching object IDs
	            RArray<TItemId> matchingObjectIdArray;
				CleanupClosePushL( matchingObjectIdArray );
	
	            const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(),
	            		objectIdArray, matchingObjectIdArray );
	
				// check is there any matches
				if( allMatches || matchingObjectIdArray.Count() > 0 )
	            	{
	            	if(e.IsPending())
	            		{
		            	// Match found. Trigger notifier entry.
		            	TInt err( KErrNone );
		            	
		            	if( allMatches )
		            		{
		            		// all matches so send whole object ID array
		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
		            				objectIdArray, uriArray ) );
		            		}
		            	else
		            		{
		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
		            				matchingObjectIdArray, uriArray ) );
		            		}
	
		            	if( err != KErrNone )
			            	{
			            	e.TriggerError( err );
		    	        	}
	            		}
	            	else
	            		{
						if( allMatches )
		            		{
		            		// all matches so send whole object ID array
	            			TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
	            					objectIdArray, uriArray ) );
		            		}
		            	else
		            		{
		            		TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
		            				matchingObjectIdArray, uriArray ) );
		            		}
	            		}
	            	}
	
				CleanupStack::PopAndDestroy( &matchingObjectIdArray );
				}
	        else if( e.iType & EObjectNotifyRemoveWithUri && objectCount > 0 )
                {
                // collect matching object IDs
                RArray<TItemId> matchingObjectIdArray;
                CleanupClosePushL( matchingObjectIdArray );
    
                const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(),
                        objectIdArray, matchingObjectIdArray );
    
                // check is there any matches
                if( allMatches || matchingObjectIdArray.Count() > 0 )
                    {
                    if(e.IsPending())
                        {
                        // Match found. Trigger notifier entry.
                        TInt err( KErrNone );
                        
                        if( allMatches )
                            {
                            // all matches so send whole object ID array
                            TRAP( err, e.TriggerL( EObjectNotifyRemoveWithUri, 
                                    objectIdArray, aRemovedItemUriArray ) );
                            }
                        else
                            {
                            aMEngine->GetObjectUrisByIdsL( objectIdArray, uriArray );
                            TRAP( err, e.TriggerL( EObjectNotifyRemoveWithUri, 
                                    matchingObjectIdArray, uriArray ) );
                            }
    
                        if( err != KErrNone )
                            {
                            e.TriggerError( err );
                            }
                        }
                    else
                        {
                        if( allMatches )
                            {
                            // all matches so send whole object ID array
                            TRAP_IGNORE( e.CacheL( EObjectNotifyRemoveWithUri, 
                                    objectIdArray, aRemovedItemUriArray ) );
                            }
                        else
                            {
                            aMEngine->GetObjectUrisByIdsL( objectIdArray, uriArray );
                            TRAP_IGNORE( e.CacheL( EObjectNotifyRemoveWithUri, 
                                    matchingObjectIdArray, uriArray ) );
                            }
                        }
                    }
    
                CleanupStack::PopAndDestroy( &matchingObjectIdArray );
                }
	        else if( ( e.iType & EEventNotifyRemove ) 
	        		&& eventCount > 0 )
            	{
				// event condition can't contain ID conditions, 
            	// so get all IDs
	        	if(e.IsPending())
	        		{
	            	// Match found. Trigger notifier entry.
	            	TRAPD( err, e.TriggerL( EEventNotifyRemove, 
	            			eventIdArray, uriArray ) );
	            	if( err != KErrNone )
		            	{
		            	e.TriggerError( err );
	    	        	}
	        		}
	        	else
	        		{
	        		TRAP_IGNORE( e.CacheL( EEventNotifyRemove, 
	        				eventIdArray, uriArray ) );
	        		}
            	}
	        else if( ( e.iType & ERelationNotifyRemove ) 
	        		&& relationCount > 0 )
            	{
	            // relation condition can't contain ID conditions, 
            	// so get all IDs
	        	if(e.IsPending())
	        		{
	            	// Match found. Trigger notifier entry.
	            	TRAPD( err, e.TriggerL( ERelationNotifyRemove, 
	            			relationIdArray, uriArray ) );
	            	if( err != KErrNone )
		            	{
		            	e.TriggerError( err );
	    	        	}
	        		}
	        	else
	        		{
	        		TRAP_IGNORE( e.CacheL( ERelationNotifyRemove, 
	        				relationIdArray, uriArray ) );
	        		}
            	}
	        CleanupStack::PopAndDestroy( &uriArray );
	        }
		}
	CleanupStack::PopAndDestroy( 3, &objectIdArray ); // relationIdArray, eventIdArray, objectIdArray
    }
/**
 * Test CJavaRegistrySuiteEntry::MIDletUidsL() method.
 * 1. Test one embedded application.
 * 2. Test three embedded applications.
 */
TEST(TestSuiteEntry, TestMIDletUids)
{
    LOG(EJavaStorage, EInfo, "+TestMIDletUidsL");

    MJavaRegistry* registry = MJavaRegistry::CreateL();
    CHECK(registry != NULL);

    JavaStorageApplicationEntry_t suite1;
    JavaStorageEntry attr;
    attr.setEntry(PACKAGE_NAME, L"TestMIdletUids");
    suite1.insert(attr);

    string tableName = APPLICATION_PACKAGE_TABLE;
    Uid suite1Uid(L"[e1230043]");
    attr.setEntry(ID, suite1Uid.toString());
    suite1.insert(attr);

    attr.setEntry(MEDIA_ID, L"-124614446");
    suite1.insert(attr);

    js->open();
    js->startTransaction();
    CHECK(jtu->populate(*js, tableName, suite1));

    JavaStorageApplicationEntry_t midlet1;
    attr.setEntry(NAME, L"MyMIDlet1");
    midlet1.insert(attr);

    attr.setEntry(PACKAGE_ID, suite1Uid.toString());
    midlet1.insert(attr);

    string appTableName = APPLICATION_TABLE;
    Uid midlet1Uid(L"[e12a0077]");
    attr.setEntry(ID, midlet1Uid.toString());
    midlet1.insert(attr);

    CHECK(jtu->populate(*js, appTableName, midlet1));
    js->commitTransaction();

    TUid suiteUid;
    uidToTUid(suite1Uid, suiteUid);

    // 1. Test one embedded application.
    MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid);
    CHECK(suiteEntry != NULL);
    RArray<TUid> embeddedUids;
    suiteEntry->MIDletUidsL(embeddedUids);
    CHECK(embeddedUids.Count() == 1);

    TUid midletUid;
    uidToTUid(midlet1Uid, midletUid);
    CHECK(embeddedUids[0] == midletUid);

    embeddedUids.Reset();
    suiteEntry->Release();

    JavaStorageApplicationEntry_t midlet2;
    attr.setEntry(NAME, L"MyMIDlet2");
    midlet2.insert(attr);

    attr.setEntry(PACKAGE_ID, suite1Uid.toString());
    midlet2.insert(attr);

    Uid midlet2Uid(L"[e12a0007]");
    attr.setEntry(ID, midlet2Uid.toString());
    midlet2.insert(attr);

    js->startTransaction();
    CHECK(jtu->populate(*js, appTableName, midlet2));
    js->commitTransaction();

    JavaStorageApplicationEntry_t midlet3;
    attr.setEntry(NAME, L"MyMIDlet3");
    midlet3.insert(attr);

    attr.setEntry(PACKAGE_ID, suite1Uid.toString());
    midlet3.insert(attr);

    Uid midlet3Uid(L"[e12a0117]");
    attr.setEntry(ID, midlet3Uid.toString());
    midlet3.insert(attr);

    js->startTransaction();
    CHECK(jtu->populate(*js, appTableName, midlet3));
    js->commitTransaction();

    // 2. Test three embedded applications.
    suiteEntry = registry->SuiteEntryL(suiteUid);
    CHECK(suiteEntry != NULL);
    suiteEntry->MIDletUidsL(embeddedUids);
    CHECK(embeddedUids.Count() == 3);

    uidToTUid(midlet1Uid, midletUid);
    CHECK(embeddedUids.Find(midletUid) >= 0);

    uidToTUid(midlet2Uid, midletUid);
    CHECK(embeddedUids.Find(midletUid) >= 0);

    uidToTUid(midlet3Uid, midletUid);
    CHECK(embeddedUids.Find(midletUid) >= 0);

    embeddedUids.Reset();
    suiteEntry->Release();
    embeddedUids.Close();

    // Clean
    js->startTransaction();
    CHECK(jtu->remove(*js, tableName, suite1));
    CHECK(jtu->remove(*js, appTableName, midlet1));
    CHECK(jtu->remove(*js, appTableName, midlet2));
    CHECK(jtu->remove(*js, appTableName, midlet3));
    js->commitTransaction();
    js->close();

    registry->Release();

    LOG(EJavaStorage, EInfo, "-TestMIDletUidsL");
}
void CPtiVariantITUT_01DataFactory::ListLanguagesL(RArray<TInt>& aResult)
    {
    aResult.AppendL(ELangEnglish);
    }
/** Create Multiple Contact Item with field and Add all contact
 *	Item to Contact database. Update the multiple contact item field value and  
 *	verify field is being updated. 
 *	aValue - field value
 *  @param aStorageType - Storage type of each field
 *	@param aContFieldUid - Uid of Contact field
 *	@param avCardMapUid - Uid of vCard 
 *	@return - void
*/		
void CTestUpdateMultipleContactsStep::CreateAndUpdateMultipleContactsL(TPtrC aValue, TInt aStorageType,TUid aContFieldUid, TUid avCardMap)
	{
	TPtrC value, updateVal, getUpdateValue;
	CContactDatabase *dBase = NULL;
   _LIT(KTestDbName, "c:contactmultiple.cdb");
   	TInt year, month, day,noOfCI;
   	TContactItemId id = 0;
   	RArray <TInt> idArray;
	CleanupClosePushL(idArray);

	//replace existing database name
	dBase = CContactDatabase::ReplaceL(KTestDbName);

	//Get the number of contact item from ini file
	GetIntFromConfig(ConfigSection(), KNoOfContactItem, noOfCI);

	//Get the int value
	GetIntFromConfig(ConfigSection(), KIniYear, year);
	GetIntFromConfig(ConfigSection(), KIniMonth, month);
	GetIntFromConfig(ConfigSection(), KIniDay, day);

    // Create contact item and add field to it
    for(TInt range=0;range<noOfCI;range++)
    	{
		CContactItem* item = CContactCard::NewLC();
		CContactItemField* field = CContactItemField::NewL(aStorageType, aContFieldUid);
		CleanupStack::PushL(field);
		field->SetMapping(avCardMap);
		if(aStorageType==KStorageTypeDateTime)
			{
			TDateTime date(year,(TMonth)month,day,0,0,0,0);
			field->DateTimeStorage()->SetTime(date);
			}
			else
			{
			field->TextStorage()->SetTextL(aValue);
			}
			item->AddFieldL(*field);
			CleanupStack::Pop(field);

		// add contact item to database
		id = dBase->AddNewContactL(*item);
		idArray.Append(id);
		CleanupStack::PopAndDestroy(item);
    	}
    dBase->CloseContactL(id);

	// Get the value from ini file for update
   	GetStringFromConfig(ConfigSection(), KIniUpdatedvalue, updateVal);
	GetIntFromConfig(ConfigSection(), KIniUpdateYear, year);
    GetIntFromConfig(ConfigSection(), KIniUpdateMonth, month);
    GetIntFromConfig(ConfigSection(), KIniUpdateDay, day);
       	
    // update multiple contact item field value
    CContactItem *readItem = NULL;
    for(TInt readContact=0;readContact<noOfCI;readContact++)
    	{
    	readItem = dBase->ReadContactLC(idArray[readContact]);
    	CContactItemFieldSet& ContactFieldSet = readItem->CardFields();
		TInt pos = ContactFieldSet.Find(aContFieldUid, avCardMap);
		if(pos != KErrNotFound)
			{
			if(aStorageType==KStorageTypeDateTime)
				{
				// update the field value
				TDateTime date(year,(TMonth)month,day,0,0,0,0);
   				ContactFieldSet[pos].DateTimeStorage()->SetTime(date);
   				ContactFieldSet.UpdateFieldL(ContactFieldSet[pos],pos);
   				
				// verify the updated field value
   				TInt upadtePos = ContactFieldSet.Find(aContFieldUid, avCardMap);
   				TDateTime result=ContactFieldSet[upadtePos].DateTimeStorage()->Time().DateTime();
   				if((result.Year() == year) && (result.Month() == (TMonth)month) && (result.Day() == day)) 
					{
					SetTestStepResult(EPass);	
					}
				else
					{
					SetTestStepResult(EFail);	
					}
				}
			else
				{
				// Update the field value
				ContactFieldSet[pos].TextStorage()->SetTextL(updateVal);
				ContactFieldSet.UpdateFieldL(ContactFieldSet[pos],pos);
		
				// verify the field is being updated 
				TInt upadtePos = ContactFieldSet.Find(aContFieldUid, avCardMap);
				getUpdateValue.Set(ContactFieldSet[upadtePos].TextStorage()->Text());
	
				//set the results
				if(getUpdateValue.Compare(updateVal)==0 )
					{
						SetTestStepResult(EPass);
					}
				else
					{
					SetTestStepResult(EFail);
					}
				}
			}
		CleanupStack::PopAndDestroy(readItem);	
    	}
    CleanupStack::PopAndDestroy(&idArray);
  	delete dBase;
	}
enum TVerdict CTest18ExhaustMidSizePools::doTestStepL(void)
	{
	//-------------- substep 1 --------------------
	INFO_PRINTF1(_L("  01 Create CMBufManager and install active scheduler:"));
    CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler );
	CActiveScheduler::Install(iActSch);


	// Create some initial pools
	// AddL(KMBuf_MBufSize, KMBuf_InitialAllocation, KMBuf_MinGrowth, KMBuf_GrowthThreshold)
	// Background memory allocation (CMBufPoolManager::RunL) is used more frequently if
	// the KMBuf_MinGrowth and the KMBuf_GrowthThreshold are similar in size
	// Synchronous allocation (AllocPool(*poolChain, growth, ETrue)) occurs when the
	// requested size (iChain.CopyIn(size)) is larger than the KMBuf_MinGrowth
	// Multiple threads attempt to grow different poolchains at the same time when there
	// are a greater variety of pool sizes to grow.
	// 16384
	TInt totalPools = 5;
	TInt poolSize = (KMBufDefaultHeapSize / 2)/totalPools;	

	RArray<TCommsBufPoolCreateInfo> createInfoArray;
	
	TCommsBufPoolCreateInfo createInfo;
	createInfo.iBufSize = 128;
	createInfo.iInitialBufs = 128;
	createInfo.iGrowByBufs = 64;
	createInfo.iMinFreeBufs = 40;
	createInfo.iCeiling = poolSize/createInfo.iBufSize;

	TCommsBufPoolCreateInfo createInfo2;
	createInfo2.iBufSize = 256;
	createInfo2.iInitialBufs = 64;
	createInfo2.iGrowByBufs = 7;
	createInfo2.iMinFreeBufs = 6;
	createInfo2.iCeiling = poolSize/createInfo.iBufSize;	

	TCommsBufPoolCreateInfo createInfo3;
	createInfo3.iBufSize = 512;
	createInfo3.iInitialBufs = 32;
	createInfo3.iGrowByBufs = 6;
	createInfo3.iMinFreeBufs = 5;
	createInfo3.iCeiling = poolSize/createInfo.iBufSize;	

	TCommsBufPoolCreateInfo createInfo4;
	createInfo4.iBufSize = 1024;
	createInfo4.iInitialBufs = 16;
	createInfo4.iGrowByBufs = 5;
	createInfo4.iMinFreeBufs = 4;
	createInfo4.iCeiling = poolSize/createInfo.iBufSize;	

	TCommsBufPoolCreateInfo createInfo5;
	createInfo5.iBufSize = 2048;
	createInfo5.iInitialBufs = 8;
	createInfo5.iGrowByBufs = 4;
	createInfo5.iMinFreeBufs = 3;
	createInfo5.iCeiling = poolSize/createInfo.iBufSize;	

	createInfoArray.Append(createInfo);
	createInfoArray.Append(createInfo2);
	createInfoArray.Append(createInfo3);
	createInfoArray.Append(createInfo4);
	createInfoArray.Append(createInfo5);

	// Create 262144
	CreateInstanceMBufMgrL(createInfoArray);
	CleanupClosePushL(iBufPond);
	createInfoArray.Close ();
	
	RMBufAllocator allocator;
	
	TInt allocTime128 = 0;
	TInt allocTime256 = 0;
	TInt allocTime512 = 0;
	TInt allocTime1024 = 0;
	TInt allocTime2048 = 0;
	
	TInt allocCount128 = 0;
	TInt allocCount256 = 0;
	TInt allocCount512 = 0;
	TInt allocCount1024 = 0;
	TInt allocCount2048 = 0;
	
	TInt allocIndex128 = 0;
	TInt allocIndex256 = 0;
	TInt allocIndex512 = 0;
	TInt allocIndex1024 = 0;
	TInt allocIndex2048 = 0;
	
	TInt failedSizeCount = 0;
	
	TInt counter = 0;
	
	TUint time;
	RMBufChain aChain, bChain;
	RMBufChain mbuf1, mbuf2, mbuf3, mbuf4, mbuf5, mbuf6;
	
	//-------------- substep 2 --------------------
	INFO_PRINTF1(_L("  02 Fill in the Des1 with a pattern:"));
	TBuf8<2500> *aDes1 = NULL;
	TRAPD(ret, aDes1 = new(ELeave) TBuf8<2500>);
	if(ret != KErrNone)
		{
        SetTestStepResult(EFail);
		return TestStepResult();
		}

	aDes1->SetLength(2500);
	FillDes(*aDes1, 0, 2500, 1, 1);
	
	//-------------- substep 3 --------------------
	INFO_PRINTF1(_L("  03 Start to allocate 500-bytes long RMBufs:"));

	time = User::FastCounter();
	ret = aChain.Alloc(500, allocator);
	time = User::FastCounter() - time;
	while (ret == KErrNone)
		{
		//Copy in Des1 into Chain
		aChain.CopyIn(aDes1->LeftTPtr(500));
		if (aChain.Length() != 500)
			{
			INFO_PRINTF1(_L("Error: Allocated RMBufChain size does not match requested:"));
			failedSizeCount++;
			}
		
		switch (aChain.First()->Size())
			{
			case 128:
				if (allocator.BytesAvailable(256) / 256 > 0)
					{
					INFO_PRINTF1(_L("Error: 256-bytes long RMBuf available, but allocated 128-bytes long RMBuf:"));
					}
				else if (allocIndex128 == 0)
					{
					counter++;
					allocIndex128 = counter;
					}
				allocCount128++;
				allocTime128 += time;
				break;
			case 256:
				if (allocator.BytesAvailable(2048) / 2048 > 0)
					{
					INFO_PRINTF1(_L("Error: 2048-bytes long RMBuf available, but allocated 256-bytes long RMBuf:"));
					}
				else if (allocIndex256 == 0)
					{
					counter++;
					allocIndex256 = counter;
					}
				allocCount256++;
				allocTime256 += time;
				break;
			case 512:
				if (allocIndex512 == 0)
					{
					counter++;
					allocIndex512 = counter;
					}
				allocCount512++;
				allocTime512 += time;
				break;
			case 1024:
				if (allocator.BytesAvailable(512) / 512 > 0)
					{
					INFO_PRINTF1(_L("Error: 512-bytes long RMBuf available, but allocated 1024-bytes long RMBuf:"));
					}
				else if (allocIndex1024 == 0)
					{
					counter++;
					allocIndex1024 = counter;
					}
				allocCount1024++;
				allocTime1024 += time;
				break;
			case 2048:
				if (allocator.BytesAvailable(1024) / 1024 > 0)
					{
					INFO_PRINTF1(_L("Error: 1024-bytes long RMBuf available, but allocated 2048-bytes long RMBuf:"));
					}
				else if (allocIndex2048 == 0)
					{
					counter++;
					allocIndex2048 = counter;
					}
				allocCount2048++;
				allocTime2048 += time;				
				break;
			}
		
		// Now grow the chain
		if (allocCount256 == 1)
			{
			mbuf1.Append(aChain);
			}
		else if (allocCount512 == 1)
			{
			mbuf2.Append(aChain);
			}
		else if (allocCount512 == 2)
			{
			mbuf3.Append(aChain);
			}
		else if (allocCount512 == 3)
			{
			mbuf4.Append(aChain);
			}
		else if (allocCount2048 == 1)
			{
			mbuf5.Append(aChain);
			}
		else if (allocCount2048 == 2)
			{
			mbuf6.Append(aChain);
			}
		else
			{
			bChain.Append(aChain);
			}
		
		time = User::FastCounter();
		ret = aChain.Alloc(500, allocator);
		time = User::FastCounter() - time;
		}

	if (allocIndex512 == 1)
		{
		_LIT(aLog1,"     Info: %d. Time to alloc %d 512-bytes long RMBuf: %d Average: %d");
		INFO_PRINTF5(aLog1, allocIndex512, allocCount512, allocTime512, allocTime512/allocCount512);
		}
	if (allocIndex1024 == 2)
		{
		_LIT(aLog2,"     Info: %d. Time to alloc %d 1024-bytes long RMBuf: %d Average: %d");
		INFO_PRINTF5(aLog2, allocIndex1024, allocCount1024, allocTime1024, allocTime1024/allocCount1024);
		}
	if (allocIndex2048 == 3)
		{
		_LIT(aLog3,"     Info: %d. Time to alloc %d 2048-bytes long RMBuf: %d Average: %d");
		INFO_PRINTF5(aLog3, allocIndex2048, allocCount2048, allocTime2048, allocTime2048/allocCount2048);
		}
	if (allocIndex256 == 4)
		{
		_LIT(aLog4,"     Info: %d. Time to alloc %d 256-bytes long RMBuf: %d Average: %d");
		INFO_PRINTF5(aLog4, allocIndex256, allocCount256, allocTime256, allocTime256/allocCount256);
		}
	if (allocIndex128 == 5)
		{
		_LIT(aLog5,"     Info: %d. Time to alloc %d 128-bytes long RMBuf: %d Average: %d");
		INFO_PRINTF5(aLog5, allocIndex128, allocCount128, allocTime128, allocTime128/allocCount128);
		}
	
	TBool firstSuccess = ETrue;
	TBool secondSuccess = ETrue;
	TBool thirdSuccess = ETrue;
	
	//-------------------substep 4-----------------------------
	INFO_PRINTF1(_L("  04 Allocate 750-byte long RMBuf after deallocating 1 256-byte and 2 512-byte long RMBufs:"));	
	mbuf1.TrimEnd(244);	// 256-byte mbuf
	mbuf2.Free();		// 512-byte mbuf	
	mbuf3.Free();		// 512-byte mbuf
	
	ret = aChain.Alloc(750, allocator);
	if (ret != KErrNone)
		{
		INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
		firstSuccess = EFalse;
		}
	else
		{
		//Copy in Des1 into Chain
		aChain.CopyIn(aDes1->LeftTPtr(750));
		if (aChain.Length() != 750)
			{
			INFO_PRINTF1(_L("Error: Allocated RMBufChain size does not match requested:"));
			firstSuccess = EFalse;
			}
		
		// 1 512-byte long RMBuf should be free
		if (allocator.BytesAvailable(512) == 512)
			{
			INFO_PRINTF1(_L("     Info: 1 512-byte long RMBuf is free:"));
			}
		else
			{
			INFO_PRINTF1(_L("Error: 1 512-byte long RMBuf should be free, but not:"));
			firstSuccess = EFalse;
			}
		}
		
	bChain.Append(aChain);
	
	//-------------------substep 5-----------------------------
	INFO_PRINTF1(_L("  05 Allocate 750-byte long RMBuf after deallocating 2 512-byte long RMBufs:"));
	mbuf4.Free();	// 512-byte mbuf
	
	ret = aChain.Alloc(750, allocator);
	if (ret != KErrNone)
		{
		INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
		secondSuccess = EFalse;
		}
	else
		{
		//Copy in Des1 into Chain
		aChain.CopyIn(aDes1->LeftTPtr(750));
		if (aChain.Length() != 750)
			{
			INFO_PRINTF1(_L("Error: Allocated RMBufChain size does not match requested:"));
			secondSuccess = EFalse;
			}
		}
		
	bChain.Append(aChain);
	
	//-------------------substep 6-----------------------------
	INFO_PRINTF1(_L("  06 Allocate 2100-byte long RMBuf after deallocating 2 2048-byte long RMBufs:"));	
	mbuf5.Free();	// 2048-byte mbuf
	mbuf6.Free();	// 2048-byte mbuf
	
	ret = aChain.Alloc(2100, allocator);
	if (ret != KErrNone)
		{
		INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
		thirdSuccess = EFalse;
		}
	else
		{
		//Copy in Des1 into Chain
		aChain.CopyIn(aDes1->LeftTPtr(2100));
		if (aChain.Length() != 2100)
			{
			INFO_PRINTF1(_L("Error: Allocated RMBufChain size does not match requested:"));
			thirdSuccess = EFalse;
			}
		}
		
	bChain.Append(aChain);
	
	mbuf1.Free();
	bChain.Free();
	
	delete aDes1;
		
	//-------------- substep 7 --------------------
	INFO_PRINTF1(_L("  07 Clean up stack:"));
    CleanupStack::PopAndDestroy();
	CActiveScheduler::Install(NULL);
	CleanupStack::PopAndDestroy(iActSch);
	
	if (ret != KErrNone || failedSizeCount > 0 || !firstSuccess || !secondSuccess || !thirdSuccess)
		{
        SetTestStepResult(EFail);
		return TestStepResult();
		}
	
    SetTestStepResult(EPass);
	return TestStepResult();
	}
/**
 *
 * Do the test step.
 * Each test step must supply an implementation for DoTestStepL.
 *
 * @return	"TVerdict"
 *			The result of the test step
 *
 * @xxxx
 * 
 */
TVerdict CTestStepPlayerBitRateWav::DoTestStepL()
	{
	// Printing to the console and log file
	INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0850-HP"));
	INFO_PRINTF1(_L("This test will read the bit rate of different wav files."));
	
	TInt err = KErrNone;
	TInt state = 0;
	TVerdict result = EPass;
	
	RArray<TPtrC> array;
	array.Append(_L("PCM8BitStereo.wav"));
	array.Append(_L("PCM 8-Bit,8000 Hz,128 Kbps,Stereo"));
	array.Append(_L("PCM8BitMono.wav"));
	array.Append(_L("PCM 8-Bit,8000 Hz,64 Kbps,Mono"));
	array.Append(_L("PCM16BitStereo.wav"));
	array.Append(_L("PCM 16-Bit,8000 Hz,256 Kbps,Stereo"));
	array.Append(_L("PCM16BitMono.wav"));
	array.Append(_L("PCM 16-Bit,8000 Hz,128 Kbps,Mono"));
	array.Append(_L("uLawStereo.wav"));
	array.Append(_L("u-Law 8000 Hz,128 Kbps,Stereo"));
	array.Append(_L("uLawMono.wav"));
	array.Append(_L("u-Law 8000 Hz,64 Kbps,Mono"));
	array.Append(_L("ALawStereo.wav"));
	array.Append(_L("A-Law 8000 Hz,128 Kbps,Stereo"));
	array.Append(_L("ALawMono.wav"));
	array.Append(_L("A-Law 8000 Hz,64 Kbps,Mono"));
	
	CMMFMdaAudioPlayerUtility* player = CMMFMdaAudioPlayerUtility::NewL(*this);

	if (player == NULL ||
		 iError != KErrNone)
		{
		 return EInconclusive;
		}
	
	// check if player openned the file successfully
	err = GetAudPlayerState(player, state);
	if ( state != CMMFMdaAudioPlayerUtility::EStopped )
		{
		return EInconclusive;
		}
		
	CleanupStack::PushL(player);
	TInt count = array.Count();
	for (TInt iter=0; iter<count; iter+=2)
		{
		TUint bitRate = 0;	
				
		TBuf<256> fileBuf;
		fileBuf.Append(KFilePath);
		// Append the file name
		fileBuf.Append(array[iter]);
		
		INFO_PRINTF2(_L("Opening file = %S"), &fileBuf);
		INFO_PRINTF2(_L("File info = %S"), &array[iter+1]);
	
		TRAP(err,player->OpenFileL(fileBuf));
		// If the opening fails, save the test result as fail and continue looping
		if (err != KErrNone)
			{
			INFO_PRINTF2(_L("Opening file %S failed"), &fileBuf);
			result = EFail;
			continue;
			}
		CActiveScheduler::Start();
		// Get the bit rate of the file being played.
		err = player->GetBitRate(bitRate);
		if (err != KErrNone)
			{
			INFO_PRINTF2(_L("Obtaining bit rate for the file %S failed"), &fileBuf);
			result = EFail;
			}
		else
			{
			INFO_PRINTF2(_L("Bit rate of the file = %d bps"), bitRate);		
			}
		
		// Close the file before opening the second file
		player->Close();
		
		err = GetAudPlayerState(player, state);
		if ( err != KErrNone ||
			 state != CMMFMdaAudioPlayerUtility::EStopped ||
		 	 iError != KErrNone)
			{
			result = EFail;
			}	
		}
	CleanupStack::PopAndDestroy(player);
	
	INFO_PRINTF1(_L("Finished with this test step"));
	// test steps return a result
	return result;
	}