// -----------------------------------------------------------------------------
// CCMSAuthenticatedData::DecodeAttributesL
// Decodes an array of attributes
// -----------------------------------------------------------------------------
CArrayPtrFlat< CCMSAttribute >* CCMSAuthenticatedData::DecodeAttributesL(
    TASN1DecGeneric* aAttributesDec ) // generic decoder for the sequence
    {
    TASN1DecSequence sequenceDecoder;
    CArrayPtr< TASN1DecGeneric >* attributes =
        sequenceDecoder.DecodeDERLC( *aAttributesDec );
    TInt attributeCount = attributes->Count();
    if( attributeCount <  1 )
        {
        User::Leave( KErrArgument );
        }
    CArrayPtrFlat< CCMSAttribute >* retVal =
        new( ELeave ) CArrayPtrFlat< CCMSAttribute >( attributeCount );
    CleanupStack::PushL( retVal );
    for( TInt i = 0; i < attributeCount; i++ )
        {
        CCMSAttribute* attribute = CCMSAttribute::NewLC();
        attribute->DecodeL( attributes->At( i )->Encoding() );
        retVal->AppendL( attribute );
        // attribute is left in cleanup stack, as retVal has not been pushed
        // with ResetAndDestroyPushL
        }
    CleanupStack::Pop( attributeCount ); // all attributes
    CleanupStack::Pop( retVal );
    CleanupStack::PopAndDestroy( attributes );
    return retVal;
    }
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::ConvertExceptionDatesL
// Inserts exceptiondates to a parser.
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::ConvertExceptionDatesL(const CArrayFix<
        TPIMDate>& aDates, CParserVCalEntity& aParser)
{
    JELOG2(EPim);
    TInt exDateCount = aDates.Count();
    if (exDateCount > 0)
    {
        CArrayPtrFlat<TVersitDateTime>* versitExDates =
            new(ELeave) CArrayPtrFlat<TVersitDateTime> (exDateCount);
        CleanupStack::PushL(versitExDates);
        CleanupResetAndDestroyPushL(*versitExDates);
        for (TInt i = 0; i < exDateCount; i++)
        {
            TVersitDateTime
            * versitDateTime =
                new(ELeave) TVersitDateTime(aDates.At(i).DateTime(), TVersitDateTime::EIsUTC);
            CleanupDeletePushL(versitDateTime);
            versitExDates->AppendL(versitDateTime);
            CleanupStack::Pop(versitDateTime); // versitDateTime
        }
        CParserPropertyValue* propertyValue =
            new(ELeave) CParserPropertyValueMultiDateTime(versitExDates);
        CleanupStack::Pop(2); // versitExDates is now owned by propertyValue
        AddPropertyToParserL(propertyValue, KVersitTokenEXDATE(), aParser);
        // Needed cleanup stack items are popped out in the AddPropretyToParserL
    }
}
Exemplo n.º 3
0
EXPORT_C CArrayPtr<MNotifierBase2>* NotifierArray()
	{
	CArrayPtrFlat<MNotifierBase2>* subjects = new (ELeave) CArrayPtrFlat<MNotifierBase2>( 2 );
	CIPSecDialogNotifier* notifier = new (ELeave) CIPSecDialogNotifier();
    CleanupStack::PushL( notifier );
    subjects->AppendL( notifier );
    CleanupStack::Pop( notifier );
    return subjects;
	}
Exemplo n.º 4
0
// Entry point for Notifiers
EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
	{
	//The notifierArray function CAN leave, despite no trailing L
	CArrayPtrFlat<MEikSrvNotifierBase2>* subjects = new (ELeave) CArrayPtrFlat<MEikSrvNotifierBase2>( 1 );
	CleanupStack::PushL(subjects);
	CCTSecurityDialogNotifier* notifier = CCTSecurityDialogNotifier::NewL();
	CleanupStack::PushL( notifier );
	subjects->AppendL( notifier );
	CleanupStack::Pop( 2,subjects);	//notifier, subjects
	return subjects;
	}
Exemplo n.º 5
0
/**
* If the certificate has decoded the members from TeletexString then the return value 
* may be incorrect because TeletexString type is not fully supported by this library.
* Instead the decode methods perform a direct conversion from 8 to 16bits by adding 
* null characters in the second byte of each character. This will work as expected 
* for cases where the string contains ASCII data.
*/
EXPORT_C CArrayPtrFlat<CX509Certificate>* CX509CertChain::DecodeCertsL(const TDesC8& aBinaryData)
	{
	CArrayPtrFlat<CX509Certificate>* temp = new(ELeave) CArrayPtrFlat<CX509Certificate> (1);
	TCleanupItem cleanupCerts(CleanupCertArray, temp);
	CleanupStack::PushL(cleanupCerts);
	TInt pos = 0;//start at the start
	while (pos < aBinaryData.Length())
		{
		CX509Certificate* cert = CX509Certificate::NewLC(aBinaryData, pos);
		temp->AppendL(cert);
		CleanupStack::Pop();
		}
	CleanupStack::Pop();//temp
	return temp;
	}
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::AllDownloadsL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
CArrayPtrFlat<CHttpDownload>* 
                        CHttpDownloadManagerServerEngine::AllDownloadsL() const
    {
    CArrayPtrFlat<CHttpDownload>* downloads = 
                                    new (ELeave) CArrayPtrFlat<CHttpDownload>(2);

    CleanupStack::PushL( downloads );

    for( TInt apps = 0; apps < iClientApps->Count(); ++apps )
        {
        CArrayPtrFlat<CHttpDownload>* allDownloads = (*iClientApps)[apps]->Downloads();

        for( TInt i = 0; i < allDownloads->Count(); ++i )
            {
            downloads->AppendL( (*allDownloads)[i] );
            }
        }
    CleanupStack::Pop( downloads );

    return downloads;
    }
// -----------------------------------------------------------------------------
// CCMSX509CertificateList::DecodeExtensionsL
// Decodes Extensions
// -----------------------------------------------------------------------------
CArrayPtrFlat<CX509CertExtension>* CCMSX509CertificateList::DecodeExtensionsL(
	const TASN1DecGeneric* aExtensions )
	{
	CArrayPtr<TASN1DecGeneric>* extens =
			 DecodeSequenceLC( aExtensions->Encoding() );
	TInt extensionCount = extens->Count();
	CArrayPtrFlat< CX509CertExtension >* tmpExtensions =
		new(ELeave)CArrayPtrFlat< CX509CertExtension >( KDefaultGranularity );
	CleanupStack::PushL( tmpExtensions );
	CleanupResetAndDestroyPushL( *tmpExtensions );
	for( TInt j = 0; j < extensionCount; j++ )
		{
		CX509CertExtension* extension =
			CX509CertExtension::NewLC( extens->At( j )->Encoding() );
		tmpExtensions->AppendL( extension );
		CleanupStack::Pop( extension );
		}
	CleanupStack::Pop( tmpExtensions ); // ResetAndDestroy
	CleanupStack::Pop( tmpExtensions ); // normal cleanup
	CleanupStack::PopAndDestroy( extens );
	return tmpExtensions;
	}
Exemplo n.º 8
0
void CValidateTest::DoPerformPostrequisite(TRequestStatus& aStatus)
	{
	TInt err = KErrNone;

	switch (iState)
		{
	case EInit:
	case EValidationStoreInitStoreManager1:
	case EValidationStoreDepopulateStore1:
	case EValidationStorePopulateStoreRoots:
	case EValidationStorePopulateStoreExtras:
	case EValidationStoreValidate:
	case EValidationStoreValidated:
	case EValidationStoreInitStoreManager2:
	case EValidationStoreDepopulateStore2:
	case EValidationStoreEnd:
		break;	//	Nothing to do, for compiler
	case EValidationSuppliedInit:
			{
			iConsole.Printf(_L("started with supplied certs...\n"));
			iOut.writeString(_L("started with supplied certs..."));
			iOut.writeNewLine();

			iState = EValidationSuppliedValidate;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			}
			break;

		case EValidationSuppliedValidate:
			{
			HBufC8* encodedCerts = ReadFilesLC(*iTestChain->iServerCerts);

			if(!encodedCerts)
				{
				TRequestStatus* status = &aStatus;
				iFinished = ETrue;
				User::RequestComplete(status, KErrNone);
				}
			else
				{
				TInt certCount = iTestChain->iRootCerts->MdcaCount();
				CArrayPtrFlat<CWTLSCertificate>* roots = 
					new(ELeave) CArrayPtrFlat<CWTLSCertificate>(1);
				TCleanupItem cleanup(CleanupCertArray, roots);
				CleanupStack::PushL(cleanup);
				for (TInt i = 0; i < certCount; i++)
					{
					// build the root certificates array including all the candidates.
					HBufC8* encCert = 
						ReadFileLC(iTestChain->iRootCerts->MdcaPoint(i));
					CWTLSCertificate* cert = CWTLSCertificate::NewLC(encCert->Des());
					roots->AppendL(cert);
					CleanupStack::Pop();	// cert
					CleanupStack::PopAndDestroy();	// encCert
					}

				__ASSERT_DEBUG(!iChain, User::Panic(_L("CValidateTest"), 1));
				iChain = CWTLSCertChain::NewL(iFs, *encodedCerts, *roots);

				CleanupStack::PopAndDestroy(2);	// encodedCerts, roots

				TDateTime dt(2000, EJuly, 0, 0, 0, 0, 0);
				if(iTestChain->iDateIssued == 1)
					{
					dt.SetYear(2002);
					}
				iTime = dt;
				
				iChain->ValidateL(*iValidationResult, iTime, aStatus);
				iState = EValidationSuppliedValidated;
				}
			}
			break;

		case EValidationSuppliedValidated:
			{
			delete iChain;
			iChain = 0;
			TWTLSValidationStatus* expectedStatus = iTestChain->iError;
			const TWTLSValidationStatus& actualStatus = iValidationResult->Error();

			iOut.writeString(_L("Expected Error = "));
			WriteError(expectedStatus->iReason);
			iOut.writeNewLine();

			iOut.writeString(_L("Actual Error = "));
			WriteError(actualStatus.iReason);
			iOut.writeNewLine();
					
			TInt wCount = iTestChain->iWarnings->Count();
			iOut.writeString(_L("Expected Warnings = "));
			iOut.writeNewLine();
			for (TInt i = 0; i < wCount; i++)
				{
				TWTLSValidationStatus warning = iTestChain->iWarnings->At(i);
				WriteError(warning.iReason);
				iOut.writeNewLine();
				}

			iOut.writeString(_L("Actual Warnings = "));
			iOut.writeNewLine();
			const CArrayFixFlat<TWTLSValidationStatus>& warnings = 
				iValidationResult->Warnings();
			wCount = warnings.Count();
			for (TInt j = 0; j < wCount; j++)
				{
				TWTLSValidationStatus warning = warnings.At(j);
				WriteError(warning.iReason);
				iOut.writeNewLine();
				}
			iOut.writeNewLine();

			if(expectedStatus->iReason != actualStatus.iReason)
				{
				iConsole.Printf(_L("FAILED!!!!\n"));
				iOut.writeString(_L("FAILED!!!!"));
				iOut.writeNewLine();
				iResult = EFalse;
				}
		
			// End of validatewith supplied
			if (err != KErrNone)
				{
				iOut.writeString(_L("Failed: leave code = "));
				iOut.writeNum(err);
				iOut.writeNewLine();
				}

			iState = EFinished;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			}
			break;

		case EFinished:
			{
			TTime end;
			end.HomeTime();
			TTimeIntervalMicroSeconds intervalMS = end.MicroSecondsFrom(iStart);
			iConsole.Printf(_L("Time taken = %d milliseconds\n"), (intervalMS.Int64()/1000));
	
			TRequestStatus* status = &aStatus;
			iFinished = ETrue;
			User::RequestComplete(status, KErrNone);
			}
			break;
		}
	}
void CreateNotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>& aNotifiers)
{
    CIconSizeNotifier* notifier1 = CIconSizeNotifier::NewLC();
    aNotifiers.AppendL(notifier1);
    CleanupStack::Pop(notifier1);
}
void CBCTestFontInputCase::TestLafEnvL()
    {
    LafEnv::Beep();
    _LIT( beep," Test Beep() " );
    AssertTrueL( ETrue,beep );

    LafEnv::ClockDllName();
    _LIT( clkName," Test ClockDllName() " );
    AssertTrueL( ETrue,clkName );

    LafEnv::CoctlResourceFile();
    _LIT( ctlResFile," Test CoctlResourceFile() " );
    AssertTrueL( ETrue,ctlResFile );

    LafEnv::CreateTextParserL( TInt( 3 ) );
    _LIT( crtTxtParser," Test CreateTextParserL() " );
    AssertTrueL( ETrue,crtTxtParser);

    LafEnv::DefaultBusyMsgCorner();
    _LIT(defBusyMsg," Test DefaultBusyMsgCorner() " );
    AssertTrueL( ETrue,defBusyMsg );

    LafEnv::IsTaskListDisabledAtInitialization();
    _LIT( isTaskInit," Test IsTaskListDisabledAtInitialization" );
    AssertTrueL( ETrue,isTaskInit );

    LafEnv::EditableControlStandardHeight( CEikonEnv::Static()->LafEnv() );
    _LIT( editHeight," Test EditableControlStandardHeight() " );
    AssertTrueL( ETrue,editHeight );

    LafEnv::IsDefaultKey( EAknSoftkeyBack );
    _LIT( isDefKey," Test IsDefaultKey() " );
    AssertTrueL( ETrue,isDefKey );

    CColorList *clrList = LafEnv::CreateColorListL( *CEikonEnv::Static() );
    _LIT(crtClrList," Test CreateColorListL() " );
    AssertTrueL( ETrue,crtClrList );

    LafEnv::UpdateColorListL( clrList );
    _LIT( upClrList," Test UpdateColorListL() " );
    AssertTrueL( ETrue, upClrList );


    TInt fId = LafEnv::LoadPrivResFileL( *CEikonEnv::Static() );
    _LIT( ldResFile," Test LoadPrivResFileL() " );
    AssertTrueL( ETrue,ldResFile );
    CEikonEnv::Static()->DeleteResourceFile( fId );

    fId = LafEnv::LoadCoreResFileL( *CEikonEnv::Static() );
    CEikonEnv::Static()->DeleteResourceFile( fId );
    _LIT( cResFile," Test LoadCoreResFileL() " );
    AssertTrueL( ETrue,cResFile );

    CArrayPtr<CLafSystemFont> *ftArray = new (ELeave)
        CArrayPtrSeg<CLafSystemFont>(10);
    LafEnv::CreateSystemFontsL( *CEikonEnv::Static(),*ftArray );
    _LIT( crtSysFont," Test CreateSystemFontsL() " );
    AssertTrueL( ETrue,crtSysFont );

    LafEnv::UpdateSystemFontsL( CEikonEnv::Static(),*ftArray );
    _LIT( upSysFont," Test UpdateSystemFontsL() " );
    AssertTrueL( ETrue,upSysFont );

	LafEnv::ReleaseSystemFonts(*ftArray);
    delete ftArray;
    CArrayPtrFlat<CFbsBitmap> *arBitmaps = new
        CArrayPtrFlat<CFbsBitmap>(16);
    LafEnv::CreateSystemBitmapsL( *CEikonEnv::Static(), *arBitmaps);
    _LIT( crtSysBitmap," Test CreateSystemBitmapsL() " );
    AssertTrueL( ETrue,crtSysBitmap );

    LafEnv::UpdateSystemBitmapsL(*CEikonEnv::Static() , *arBitmaps,*clrList );
    _LIT( upSysBitmap," Test UpdateSystemBitmapsL() " );
    AssertTrueL( ETrue,upSysBitmap );

    delete clrList;
    delete arBitmaps;
     
    MEikBusyMsgWin *msgWin = LafEnv::NewBusyMsgWinL( *CCoeEnv::Static());
    msgWin->Release();
    _LIT( newMsgWin," Test NewBusyMsgWinL() " );
    AssertTrueL( ETrue,newMsgWin );
      
    RWindowGroup rWinGrup = CCoeEnv::Static()->RootWin();
    MEikInfoMsgWin* infMsgWin = LafEnv::NewInfoMsgWinL( *CCoeEnv::Static(),
                                                          rWinGrup );
    _LIT( newinfMsgWinGrup," Test NewInfoMsgWinL() " );
    AssertTrueL( ETrue,newinfMsgWinGrup); 
     
    infMsgWin->Release(); 
         
    infMsgWin = LafEnv::NewInfoMsgWinL( *CCoeEnv::Static() );
    _LIT( newinfMsgWin," Test NewInfoMsgWinL() " );
    AssertTrueL( ETrue,newinfMsgWin );
    infMsgWin->Release(); 
         
    LafEnv::DefaultLineSpacingInTwips();
    _LIT( defLnSpaTwip," Test DefaultLineSpaceingInTwinps() " );
    AssertTrueL( ETrue,defLnSpaTwip );
     
    TCharFormat charFormat;
    TCharFormatMask charFormatMask;
     
    LafEnv::PrepareCharFormatAndMask( charFormat,charFormatMask );
    _LIT( preCharFormat," Test PrepareCharFormatAndMask() " );
    AssertTrueL( ETrue,preCharFormat );
     
    TGulBorder tBorder;
    TRect tRect;
    TGulBorder::TColors bColors;
    LafEnv::DrawLogicalBorder( tBorder,CCoeEnv::Static()->SystemGc(),tRect,bColors);
    _LIT( drawLogBoder," Test DrawLogicalBorder()" );
    AssertTrueL( ETrue,drawLogBoder );

    TBuf<32> fPath;
    TUid apUid = { 0x101F84F3 };
    RApaLsSession *rLsSession = new ( ELeave ) RApaLsSession();
    LafEnv::GetDefaultPath( fPath,apUid,*rLsSession,*CCoeEnv::Static() );
    delete rLsSession;

    _LIT(msg1," Alert 1 " );
    _LIT(msg2," Alert 2 " );
    _LIT(disAlert, " Test DisplayAlertAsNotifier() " );
    LafEnv::DisplayAlertAsNotifier( msg1,msg2 );
    AssertTrueL( ETrue,disAlert );
    
    CFbsBitmap* bmp1 = new( ELeave ) CFbsBitmap();
    CleanupStack::PushL( bmp1 );
    CFbsBitmap* bmp2 = new( ELeave ) CFbsBitmap();
    CleanupStack::PushL( bmp2 );
    const TDesC& fileName = AknIconUtils::AvkonIconFileName();
    bmp1->Load( fileName, EMbmAvkonQgn_indi_battery_strength ); 
    bmp2->Load( fileName, EMbmAvkonQgn_prop_battery_icon );
    CArrayPtrFlat<CFbsBitmap>* bmpArray = new( ELeave ) 
        CArrayPtrFlat<CFbsBitmap>( 2 );
    CleanupStack::PushL( bmpArray );
    bmpArray->AppendL( bmp1 );
    bmpArray->AppendL( bmp2 );  
    TUid matchUid = TUid::Uid( KLafUidEikonGrayVal );
    CFbsBitmap* bmp = LafEnv::MatchBitmap( *bmpArray, matchUid );
    _LIT( KMatchBitmap, "LafEnv::MatchBitmap" );
    AssertNotNullL( bmp, KMatchBitmap );    
    CleanupStack::PopAndDestroy( 3 ); // are bmp1, bmp2 and bmpArray
    }
Exemplo n.º 11
0
CArrayPtr<MEikSrvNotifierBase2>* DoCreateNotifierArrayL()
{
    CArrayPtrFlat<MEikSrvNotifierBase2>* subjects =
        new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(KArrayGranularity);

    CleanupStack::PushL(TCleanupItem(CleanupArray, subjects));

    // ----------------------------
    // Key lock notifier.
    // ----------------------------
    CAknKeyLockNotifierSubject* keyLockNotifier = CAknKeyLockNotifierSubject::NewL();

    CleanupStack::PushL(keyLockNotifier);
    subjects->AppendL(keyLockNotifier);
    CleanupStack::Pop(keyLockNotifier);

    // ----------------------------
    // Global note notifier.
    // ----------------------------
    CAknGlobalNoteSubject* globalNoteSubject = CAknGlobalNoteSubject::NewL(keyLockNotifier);

    CleanupStack::PushL(globalNoteSubject);
    subjects->AppendL(globalNoteSubject);
    CleanupStack::Pop(globalNoteSubject);

    // ----------------------------
    // Soft note notifier.
    // ----------------------------
    CAknSoftNotificationSubject* softNotificationSubject = CAknSoftNotificationSubject::NewL(
                keyLockNotifier,
                globalNoteSubject);

    CleanupStack::PushL(softNotificationSubject);
    subjects->AppendL(softNotificationSubject);
    CleanupStack::Pop(softNotificationSubject);

    // ----------------------------
    // Popup notifier.
    // ----------------------------
    CAknPopupNotifierSubject* popupNotifierSubject = CAknPopupNotifierSubject::NewL();

    CleanupStack::PushL(popupNotifierSubject);
    subjects->AppendL(popupNotifierSubject);
    CleanupStack::Pop(popupNotifierSubject);

    // =========================================================================
    // Notifiers using CAknMediatorEvent.
    // =========================================================================
    CAknMediatorEvent* aknEvent = new (ELeave) CAknMediatorEvent();
    CleanupStack::PushL(aknEvent);

#ifdef __COVER_DISPLAY
    aknEvent->iImpl = CMediatorEventProvider::NewL();
#endif

    // ----------------------------
    // Signal notifier.
    // ----------------------------
    CAknSignalNotifierSubject* signalNotifierSubject = CAknSignalNotifierSubject::NewL(aknEvent);

    CleanupStack::PushL(signalNotifierSubject);
    subjects->AppendL(signalNotifierSubject);
    CleanupStack::Pop(signalNotifierSubject);

    // ----------------------------
    // Battery notifier.
    // ----------------------------
    CAknBatteryNotifierSubject* batteryNotifierSubject = CAknBatteryNotifierSubject::NewL(aknEvent);

    CleanupStack::PushL(batteryNotifierSubject);
    subjects->AppendL(batteryNotifierSubject);
    CleanupStack::Pop(batteryNotifierSubject);

    // ----------------------------
    // Small indicator notifier.
    // ----------------------------
    CAknSmallIndicatorSubject* smallIndicatorSubject = CAknSmallIndicatorSubject::NewL(aknEvent);

    CleanupStack::PushL(smallIndicatorSubject);
    subjects->AppendL(smallIndicatorSubject);
    CleanupStack::Pop(smallIndicatorSubject);

    // Mediator event not needed anymore.
    CleanupStack::Pop(aknEvent);

    // ----------------------------
    // Incall bubble notifier.
    // ----------------------------
    CAknIncallBubbleSubject* incallBubbleSubject = CAknIncallBubbleSubject::NewL();

    CleanupStack::PushL(incallBubbleSubject);
    subjects->AppendL(incallBubbleSubject);
    CleanupStack::Pop(incallBubbleSubject);

    // =========================================================================
    // Traditional notifiers, moved here because of higher wg-priority (wouldn't
    // require any capabilities otherwise).
    // =========================================================================

    // ----------------------------
    // Global list query.
    // ----------------------------
    CAknGlobalListQuerySubject* listQuerySubject = CAknGlobalListQuerySubject::NewL();

    CleanupStack::PushL(listQuerySubject);
    subjects->AppendL(listQuerySubject);
    CleanupStack::Pop(listQuerySubject);

    // ----------------------------
    // Global msg query.
    // ----------------------------
    CAknGlobalMsgQuerySubject* msgQuerySubject = CAknGlobalMsgQuerySubject::NewL();

    CleanupStack::PushL(msgQuerySubject);
    subjects->AppendL(msgQuerySubject);
    CleanupStack::Pop(msgQuerySubject);

    // ----------------------------
    // Global confirmation query.
    // ----------------------------
    CAknGlobalConfirmationQuerySubject* confirmationQuerySubject =
        CAknGlobalConfirmationQuerySubject::NewL();

    CleanupStack::PushL(confirmationQuerySubject);
    subjects->AppendL(confirmationQuerySubject);
    CleanupStack::Pop(confirmationQuerySubject);

    // ----------------------------
    // Global progress dialog.
    // ----------------------------
    CAknGlobalProgressDialogSubject* progressDialogSubject =
        CAknGlobalProgressDialogSubject::NewL();

    CleanupStack::PushL(progressDialogSubject);
    subjects->AppendL(progressDialogSubject);
    CleanupStack::Pop(progressDialogSubject);

    // ----------------------------
    // Global list msg query.
    // ----------------------------
    CAknGlobalListMsgQuerySubject* listMsgQuerySubject = CAknGlobalListMsgQuerySubject::NewL();

    CleanupStack::PushL(listMsgQuerySubject);
    subjects->AppendL(listMsgQuerySubject);
    CleanupStack::Pop(listMsgQuerySubject);

    CleanupStack::Pop(subjects);
    return subjects;
}
// -----------------------------------------------------------------------------
// TSTSDistinguishedNameConverter::CreateDNL
// Create CX500DistinguishedName
// -----------------------------------------------------------------------------
CX500DistinguishedName* TSTSDistinguishedNameConverter::CreateDNL(
    const TDesC& aNameInfo)
{

    CArrayPtrFlat< CX520AttributeTypeAndValue>* elements =
        new(ELeave) CArrayPtrFlat<CX520AttributeTypeAndValue> (1);
    CleanupStack::PushL(elements);
    CleanupResetAndDestroyPushL(*elements);
    TInt pos(0);
    TInt nameLength(aNameInfo.Length());
    TInt elementStart(0);

    while (pos < nameLength)
    {
        if (aNameInfo[ pos ] == '\\')
        {
            // next character is escaped, so we jump over it
            pos++;
        }
        else if ((aNameInfo[ pos ] == ',') || (pos == (nameLength - 1)))
        {
            // found the end of single element, parse it
            TInt elementLength = pos - elementStart;
            if (pos == (nameLength - 1))
            {
                elementLength++;
            }
            TPtrC elementDes(aNameInfo.Mid(elementStart, elementLength));
            CX520AttributeTypeAndValue* element =
                ParseDNElementL(elementDes);
            if (element)
            {
                CleanupStack::PushL(element);
                elements->AppendL(element);
                CleanupStack::Pop();  // element
            }
            elementStart = pos + 1;
        }
        pos++;
    }

    TInt elementCount = elements->Count();

    if (elementCount == 0)
    {
        CX520AttributeTypeAndValue* element = GenerateDNElementLC();
        elements->AppendL(element);
        CleanupStack::Pop();  // element
        elementCount++;
    }

    // In certificates the element order is reversed
    CArrayPtrFlat< CX520AttributeTypeAndValue>* reversedElements =
        new(ELeave) CArrayPtrFlat<CX520AttributeTypeAndValue> (elementCount);
    CleanupStack::PushL(reversedElements);

    for (TInt i = elementCount - 1; i >= 0; i--)
    {
        reversedElements->AppendL(elements->At(i));
    }

    CX500DistinguishedName* dn =
        CX500DistinguishedName::NewL(*reversedElements);

    CleanupStack::PopAndDestroy(3);   // elements, reversedElements


    return dn;
}
void CUploadContainer::ConstructL(const TRect& aRect)
{
	CALLSTACKITEM_N(_CL("CUploadContainer"), _CL("ConstructL"));

	iControls=new (ELeave) CArrayPtrFlat< CCoeControl >(10);
	CreateWindowL();

	TRect r(TPoint(5, 5), TSize(aRect.Width()-10, 1));

	if (iFileName.Right(3).CompareF(_L("jpg"))==0) {
#ifndef __S60V2__
		iMdaServer=CMdaServer::NewL();
		iFileUtil=CMdaImageFileToBitmapUtility::NewL(*this, iMdaServer);
#else
		iFileUtil=CMdaImageFileToBitmapUtility::NewL(*this, 0);
#endif
		iFileUtil->OpenL(iFileName);
		scaled=false;
		iImgPlaceHolder=new (ELeave) CEikLabel;
		iControls->AppendL(iImgPlaceHolder);
		iImgPlaceHolder->SetContainerWindowL( *this );
		iImgPlaceHolder->SetFont(iEikonEnv->DenseFont());
		iImgPlaceHolder->SetTextL( _L("loading image...") ); 
		r.SetHeight(IMG_HEIGHT);
		iImgPlaceHolder->SetRect(r);
		r.Move(0, r.Height()+4);
	} else {
		r.SetHeight(IMG_HEIGHT);
		r.Move(0, r.Height()+4);
	}

	TInt tagw=0;
	/*
	iTagLabel=new (ELeave) CEikLabel;
	iControls->AppendL(iTagLabel);
	iTagLabel->SetContainerWindowL( *this );
	iTagLabel->SetTextL( _L("Tag:") );
	r.SetHeight(12);
	iTagLabel->SetRect(r);
	tagw=iTagLabel->MinimumSize().iWidth+4;
	r.Move( tagw , 0); r.SetWidth(r.Width()-tagw);
	*/

	TBuf<100> tag;
	Settings().GetSettingL(SETTING_UPLOAD_TAG, tag);
	if (tag.Length() == 0) tag=KTag();

	iTagEdit=new (ELeave) CEikEdwin;
	iControls->AppendL(iTagEdit);
	iTagEdit->SetContainerWindowL( *this );
	iTagEdit->ConstructL();
	iTagEdit->SetTextL(&tag);
	iTagEdit->AddEdwinObserverL(this);
	r.SetHeight(16);
	iTagEdit->SetRect(r);
	iTagEdit->ActivateL();
	r.Move(-tagw, r.Height()+4); r.SetWidth(r.Width()+tagw);


	TBool no_descr;
	if (iTagOnly) 
		no_descr=true;
	else
		no_descr=false;
	
	if (!no_descr) {
		TInt height=56;
		/*
		iDescriptionLabel=new (ELeave) CEikLabel;
		iControls->AppendL(iDescriptionLabel);
		iDescriptionLabel->SetContainerWindowL( *this );
		iDescriptionLabel->SetTextL( _L("Description:") );
		r.SetHeight(12);
		iDescriptionLabel->SetRect(r);
		r.Move(0, r.Height()+4);
		height-=16;
		*/
		r.Move(0, 2);

		iDescriptionEdit=new (ELeave) CEikEdwin;
		iControls->AppendL(iDescriptionEdit);
		iDescriptionEdit->SetContainerWindowL( *this );
		iDescriptionEdit->ConstructL();
		iDescriptionEdit->AddEdwinObserverL(this);
		iDescriptionEdit->SetTextL(&(KDescription()));
		r.SetHeight(height);
		iDescriptionEdit->SetRect(r);
		r.Move(0, r.Height()+4);

		SetEditSelected(iDescriptionEdit, true); SetEditActive(iDescriptionEdit, true);
	} else {
		SetEditSelected(iTagEdit, true); SetEditActive(iTagEdit, true);
	}

	SetRect(aRect);
	ActivateL();	
}
// -----------------------------------------------------------------------------
// CSTSASN1Sequence::DecodeItemsLC
// Decodes raw-data to ASN.1 modules, pushes items to cleanupstack
// Checks removed records and padding bytes and ignores them.
// -----------------------------------------------------------------------------
CArrayPtrFlat<TASN1DecGeneric>* CSTSASN1Sequence::DecodeItemsLC(
    const TASN1DecGeneric& aRawData)
{
    CArrayPtrFlat<TASN1DecGeneric>* items = new(ELeave) CArrayPtrFlat<
    TASN1DecGeneric> (KSTSDefaultGranularity);
    TCleanupItem cleanupSeq(CleanupSequence, items);
    CleanupStack::PushL(cleanupSeq);

    TPtrC8 source(aRawData.GetContentDER());
    TInt sourceLength = source.Length();

    TInt pos = 0;
    while (pos < sourceLength)
    {
        TPtrC8 restOfData(source.Right(sourceLength - pos));
        TUint8 tag = restOfData[0];//first byte is tag

        TInt restOfDataLength = restOfData.Length();
        //check does contains removed record or padding bytes
        if (tag == KSTSRemovedRecordTag)
        {
            //we can jump over this record
            if (restOfDataLength >= KSTSRecordHeaderLength)
            {
                //2. byte is record length
                TInt recordDataLength = restOfData[1];
                //update position after this record
                pos += recordDataLength + KSTSRecordHeaderLength;
            }
            else
            {
                //there is only one byte left so in this Removed Tag case
                //we can ignore this and continue without leaving
                pos++;
            }
        }
        else if (tag == KSTSPaddingByte)
        {
            //we can jump over padding bytes
            TInt amountOfPaddingBytes = 1; //one padding byte is already found
            TBool paddingByte = ETrue;

            //we start from second byte, because first is already read
            for (TInt i = 1; (i < restOfDataLength) && (paddingByte); i++)
            {
                //take next value
                TUint8 nextByte = restOfData[i];
                //if padding byte, increase amount of padding bytes
                if (nextByte == KSTSPaddingByte)
                {
                    amountOfPaddingBytes++;
                }
                else //end loop
                {
                    paddingByte = EFalse;
                }
            }
            //update position after padding bytes
            pos += amountOfPaddingBytes;
        }
        else //we can append record to array
        {
            //take next record
            TASN1DecGeneric* decGenRecord =
                new(ELeave) TASN1DecGeneric(restOfData);
            CleanupStack::PushL(decGenRecord);
            decGenRecord->InitL();
            //append record to array
            items->AppendL(decGenRecord);
            //update position after record
            pos += decGenRecord->LengthDER();
            CleanupStack::Pop(decGenRecord);
        }
    }

    return items;

}