void CClearConfig::ClearL(RULogger& loggerSession)
{	
	loggerSession.Stop();//C.A. previously:loggerSession.StopOutputting();
	loggerSession.DeActivateInputPlugin();
	CArrayPtrFlat<HBufC8> *allplugins = new (ELeave)CArrayPtrFlat<HBufC8>(1);
	loggerSession.GetInstalledOutputPlugins(*allplugins);//C.A. previously:loggerSession.InstalledOutputPlugins(*allplugins);
	for(TInt i=0;i<(allplugins->Count());i++)
	if(allplugins->Count())
	{
		TBuf8<50> dataBuf;
		dataBuf.Copy(allplugins->At(i)->Des());
		loggerSession.RemovePluginConfigurations(dataBuf);
	}
	CArrayFixFlat<TUint8> *getfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
	loggerSession.GetPrimaryFiltersEnabled(*getfilter);//C.A. previously:loggerSession.GetEnabledClassifications(*getfilter);
	TInt Result=loggerSession.SetPrimaryFiltersEnabled(*getfilter,EFalse);//C.A. previously:TInt Result=loggerSession.DisableClassifications(*getfilter);
	RArray<TUint32> get2filter;	
	loggerSession.GetSecondaryFiltersEnabled(get2filter);//C.A. previously:loggerSession.GetEnabledModuleUids(get2filter);
	loggerSession.SetSecondaryFiltersEnabled(get2filter,EFalse);//C.A. previously:loggerSession.DisableModuleUids(get2filter);
	//C.A. previously:loggerSession.EnableClassificationFiltering();
	loggerSession.SetSecondaryFilteringEnabled(ETrue);//C.A. previously:loggerSession.EnableModuleUidFiltering();
	loggerSession.SetBufferSize(1024);
	loggerSession.SetNotificationSize(512);
	loggerSession.SetBufferMode(1);//C.A. previously:loggerSession.SetBufferMode(EStraight);
}
// ---------------------------------------------------------
// CDownloadMgrSession::InitializeL
// ---------------------------------------------------------
//
void CDownloadMgrSession::InitializeL()
    {
    CLOG_ENTERFN( "CDownloadMgrSession::DownloadMgrAttachCountL" )
    iIsMaster = (TBool)CurrentMessage().Int2();

    TUid uid;
    TPckg<TUid> uidPckg( uid );

    Read( 0, uidPckg );

    CreateClientAppInstanceL( uidPckg().iUid );

    // Check how many download we have and return it to the client
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::InitializeL iClientAppInstance %d", iClientAppInstance );
    CArrayPtrFlat<CHttpDownload>* currentDownloads = iClientAppInstance->DownloadsL();
	TPckg<TInt> countPckg( currentDownloads->Count() );
	TPckg<TInt> sessionId( iSessionId );

    Write( 1, CurrentMessage(), countPckg );
    Write( 3, CurrentMessage(), sessionId );

    CLOG_NAME_2( _L("Session_%x_%x"), uidPckg().iUid, iSessionId );

    currentDownloads->Reset();
    delete currentDownloads;
    }
// -----------------------------------------------------------------------------
// CHttpConnHandler::Connected
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::Connected()
    {
    if( iNewConnection )
        {
        iNewConnection = EFalse;

        if( iStatus.Int() == KErrNone )
            {
            if( !iIapId )
                {
                UpdateIapId();
                }

            TRAP_IGNORE( SetConnectionInfoL() );
            }
        }

    __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
    CArrayPtrFlat<CHttpDownload>* downloads = 
                                iClientApp->Downloads();
    for( TInt i = 0; i < downloads->Count(); ++i )
        {
        if( (*downloads)[i]->ConnHandler() == this )
            {
            iShutDown->Cancel();
            (*downloads)[i]->Connected();
            }
        }
    }
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHttpDownloadManagerServerEngine::ConstructL()
    {
    CLOG_NAME( _L("Engine") );
    LOGGER_ENTERFN( "ConstructL()" );

    User::LeaveIfError( iRfs.Connect() );
	User::LeaveIfError(iRfs.ShareProtected());

    iDocHandler = CDocumentHandler::NewL();
    
    iFeatProgressiveDownload = FeatureManager::FeatureSupported( KFeatureIdBrowserProgressiveDownload );
    
    iProperty = new (ELeave) RProperty;
    CLOG_ATTACH( iProperty, this );
    iProperty->Attach( KPSUidUikon,KUikMMCInserted );
    
    iMMCNotifier = new (ELeave) CMMCNotifier( iProperty );
    CLOG_ATTACH( iMMCNotifier, this );
    iMMCNotifier->StartObserving( this );

    QueryMMCUniqueId();

    QueryDriveListL();

    iClientApps = new (ELeave) CArrayPtrFlat<CHttpClientApp>(2);

    // make directory for the server
    // No problem if it already exists
    TInt error = iRfs.MkDirAll( KDmDefaultDir );
    if( error != KErrNone && error != KErrAlreadyExists )
        // leave if makedir failed in some way
        // don't leave if already exists
        {
        CLOG_WRITE8_1( "MkDirAll: %d", error );
        User::Leave( error );
        }

    LoadClientsL();
    
    // This code generates a unique id for the next download
    // client will create. It is always the the highest unique
    // id of all downloads + 1.
    iNextDownloadId = 1;

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

        for( TInt i = 0; i < allDownloads->Count(); ++i )
            {
            if( iNextDownloadId <= (*allDownloads)[i]->Id() )
                {
                iNextDownloadId = (*allDownloads)[i]->Id() + 1;
                }
            }
        }
    
    error = iSocketServ.Connect();
    User::LeaveIfError(error);
    }
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::AllDownloadsSizeInDriveL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CHttpDownloadManagerServerEngine::AllDownloadsSizeInDriveL(const CHttpDownload *aDownload, TInt aDriveId) const
    {
    LOGGER_ENTERFN( "AllDownloadsSizeInDriveL" );

    TInt allDownloadsSize( 0 );
    TInt numClientApps = iClientApps->Count();
    for( TInt apps = 0; apps < numClientApps; ++apps )
        {
        CArrayPtrFlat<CHttpDownload>* dlArray = (*iClientApps)[apps]->Downloads();
        TInt numDownloads = dlArray->Count();
        for( TInt dl = 0; dl < numDownloads; ++dl )
            {
            if( ( aDownload != (*dlArray)[dl]) && (*dlArray)[dl]->State() != EHttpDlMultipleMOCompleted 
                  && aDriveId == (*dlArray)[dl]->GetDestinationDriveID())
                {
                TInt32 totalSize(0);
                TInt32 downloadedSize(0);
                
                (*dlArray)[dl]->GetIntAttributeL(EDlAttrMultipleMOLength, totalSize);
                (*dlArray)[dl]->GetIntAttributeL(EDlAttrMultipleMODownloadedSize, downloadedSize);

                //Do not conside the downloads with unknown size
                if(KDefaultContentLength != totalSize)
                	allDownloadsSize += (totalSize - downloadedSize);
                }
            }
        }
    
    return allDownloadsSize;
    }
示例#6
0
void CX509CertExtension::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
	{
	TASN1DecSequence encSeq;
	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 2, KMaxTInt);

	TASN1DecObjectIdentifier encOID;
	iId = encOID.DecodeDERL(*(seq->At(0)));
	//second is either critical flag, or the ext
	TASN1DecGeneric* second = seq->At(1);
	if (second->Tag() != EASN1Boolean)
		{
		iData = second->Encoding().AllocL();
		aPos += second->LengthDER();
		}
	else
		{
		TASN1DecBoolean encBool;
		iCritical = encBool.DecodeDERL(*second);
		if (seq->Count() != 3)
			{
			User::Leave(KErrArgument);
			}

		TASN1DecGeneric* third = seq->At(2);
		iData = third->Encoding().AllocL();
		}
	CleanupStack::PopAndDestroy();//seq
	}
void CWapDgrmTestStep::_Parse2L(CArrayPtrFlat<CSmsMessage>& aSmsArray,
						CWapReassemblyStore* aWapStore)
/**
 *  This method tests mainly CWapDatagram::DecodeConcatenatedMessagesL
 */
{
    TInt Count = aSmsArray.Count();

    // In reverse order
    // Note ! You can test additional features by changing value of
    // i or a global variable (insertSms). For example:
    // incrementing i by 1: a duplicate test
    // decrementing i by 1: not all datagrams are pushed to the store
    // ncreasing insertSms causes datagrams to be appended to the reserve array
    // Remember to set flush the reserve array on a later phase
    // by setting iIsFlushReserveArray true


    for (TInt i=Count-1;i>=iInsertSms;i--)
    {
        CWapDatagram* Wap=CWapDatagram::NewL(*(aSmsArray.At(i)));
        if (!Wap->IsComplete())
        {
            TInt Index = 0;
            TBool IsComplete = EFalse;
            IsComplete = aWapStore->AddMessageL(Index,*Wap);
            if (IsComplete)
            {
                aWapStore->GetDatagramL(Index,*Wap);
				aWapStore->BeginTransactionLC();
                aWapStore->DeleteEntryL(Index);
				aWapStore->CommitTransactionL();
                _Print(*Wap);
            }
        }
        else
            _Print(*Wap);

        delete Wap;
    }

	// append rest of the datagrams to the ReserveArray
	if (iInsertSms>0 && Count>1)
	{
		// reserve order here too
        for (TInt i=iInsertSms-1;i>=0;i--)
        {
            CWapDatagram* Wap=CWapDatagram::NewL(*(aSmsArray.At(i)));
            iReserveArray->AppendL(Wap);
        }
	}

    if (iIsFlushReserveArray)
    {
        _FlushReserveArrayL(aWapStore);
        iInsertSms = 0;
        iIsFlushReserveArray = EFalse;
    }
}
示例#8
0
void CX509ValidityPeriod::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
	{
	TASN1DecSequence encSeq;
	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
	if (seq->Count() != 2)
		{
		User::Leave(KErrArgument);
		}
	TASN1DecX509Time decTime;
	iStart = decTime.DecodeDERL(*(seq->At(0)));
	iFinish = decTime.DecodeDERL(*(seq->At(1)));
	CleanupStack::PopAndDestroy();//seq + contents
	}
// ---------------------------------------------------------
// CDownloadMgrSession::DownloadMgrAttachL
// ---------------------------------------------------------
//
void CDownloadMgrSession::DownloadMgrAttachL()
    {
    CLOG_ENTERFN( "CDownloadMgrSession::DownloadMgrAttachL" )
    // The client would like to attach the dowmloads were created previously.
    // Here, we create a buffer with the unique handles of download subsessions
    // and copy it to the client's address space.
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL iClientAppInstance %d", iClientAppInstance );
    CArrayPtrFlat<CHttpDownload>* currentDownloads = iClientAppInstance->DownloadsL();
    CleanupStack::PushL( currentDownloads );
    TPckgBuf<TInt> arrayPckg;
    HBufC8* buf = HBufC8::NewLC( currentDownloads->Count() * arrayPckg.Size() );
    // Cerate subsessions one by one and write the unique handles to the client.
    // Later the handles is used by the client subsession to attach to the server.
    for( TInt i = 0; i < currentDownloads->Count(); i++ )
        {
        CHttpDownload* httpDownload = (*currentDownloads)[i];
	    // make a new download object
	    CDownloadSubSession* download = CDownloadSubSession::NewL( this, httpDownload );
        CleanupStack::PushL( download );
	    // add object to object container to gererate unique id
	    iObjectContainer->AddL( download );
	    // add object to object index; this returns a unique handle so we can get it again
        CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, download %d", download );
	    arrayPckg() = iObjectIx->AddL( download );
        CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, iObjectIx->ActiveCount() %d", iObjectIx->ActiveCount() );
        // Store handle to the subsession. It is used when the URL is checked.
        download->SetHandle( arrayPckg() );
        CleanupStack::Pop( download ); //download
        buf->Des().Append( arrayPckg );
        }
    TPtr8 ptr = buf->Des();

    Write( 0, CurrentMessage(), ptr );

    CleanupStack::PopAndDestroy( buf ); // buf
    currentDownloads->Reset();
    CleanupStack::PopAndDestroy( currentDownloads ); // currentDownloads
    }
// -----------------------------------------------------------------------------
// CHttpConnHandler::ConnectionError
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::ConnectionError( TInt aError )
    {
    __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
    CArrayPtrFlat<CHttpDownload>* downloads = 
                                iClientApp->Downloads();

    for( TInt i = 0; i < downloads->Count(); ++i )
        {
        if( (*downloads)[i]->ConnHandler() == this )
            {
            (*downloads)[i]->ConnectionFailed( aError );
            }
        }
    }
// -----------------------------------------------------------------------------
// CHttpConnHandler::DoCancel
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::DoCancel()
    {
    LOGGER_ENTERFN( "DoCancel" );

    CArrayPtrFlat<CHttpDownload>* downloads = 
                                iClientApp->Downloads();
    for( TInt i = 0; i < downloads->Count(); ++i )
        {
        if( (*downloads)[i]->ConnHandler() == this )
            {
            (*downloads)[i]->ConnectionFailed( KErrCancel );
            }
        }
    }
void CDecPkcs12Attribute::ConstructL(const TDesC8& aBagAttributes)
	{
	TASN1DecGeneric seqGen(aBagAttributes);
	seqGen.InitL();
	
	// Check if this is a Sequence
	if (seqGen.Tag() != EASN1Sequence || seqGen.Class() != EUniversal)
		{
		User::Leave(KErrArgument);
		}
	
	TASN1DecSequence seq;
	CArrayPtrFlat<TASN1DecGeneric>* attributeSet = seq.DecodeDERLC(seqGen);
	const TASN1DecGeneric* attributeSetAt0 = attributeSet->At(0);
	if(attributeSetAt0->Tag() != EASN1ObjectIdentifier || attributeSetAt0->Class() != EUniversal)
		{
		User::Leave(KErrArgument);
		}
		
	// Decode the ObjectIdentifier
	TASN1DecObjectIdentifier oid;
	iAttributeId = oid.DecodeDERL(*attributeSetAt0); 
	 
	const TASN1DecGeneric* attributeSetAt1 = attributeSet->At(1);
	if(attributeSetAt1->Tag() != EASN1Set || attributeSetAt1->Class() != EUniversal)
		{
		User::Leave(KErrArgument);
		}
			
	// Attribute Set
	TASN1DecSet decSet;
    CArrayPtrFlat<TASN1DecGeneric>* attributeValues = decSet.NewDERLC(attributeSetAt1->Encoding());
    
    TInt attributeCount = attributeValues->Count();
		    
    for(TInt index = 0; index < attributeCount; ++index)         
	   	{
	   	const TASN1DecGeneric* attributeValuesAt = attributeValues->At(index);
		TASN1DecGeneric seqGen(*attributeValuesAt);
		seqGen.InitL();
		TPtrC8 attrValue = seqGen.Encoding();
		TDesC8* attributeVal = attrValue.AllocL();
		CleanupStack::PushL(attributeVal);
		iAttributeValue.AppendL(attributeVal);
		CleanupStack::Pop(attributeVal);
	   	}
    CleanupStack::PopAndDestroy(2,attributeSet); // attributeSet,attributeValues    
	}	
示例#13
0
void CX509Certificate::DecodeExtsL(const TDesC8& aBinaryData, TBool& aHasElementAlready)
	{
	TASN1DecSequence encSeq;
	TInt pos = 0;
	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, pos);
	TInt count = seq->Count();
	for (TInt i = 0; i < count; i++)
		{
		TASN1DecGeneric* gen = seq->At(i);
		CX509CertExtension* ext = CX509CertExtension::NewLC(gen->Encoding());
		iExtensions->AppendL(ext);
		CleanupStack::Pop();//ext
		}
	CleanupStack::PopAndDestroy();//
	aHasElementAlready = ETrue;
	}
// -----------------------------------------------------------------------------
// CHttpConnHandler::ShutDown
//
// Connection notification is not canceled here, because need to know
// when the connection is really closed. Forget the connection name, set by
// the client app only if the connection is really closed.
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::ShutDown( TBool aFromDestructor )
    {
    CLOG_WRITE( "ShutDown" );
    CLOG_WRITE8_1( "dest: %d", aFromDestructor );

    iNewConnection = EFalse;

    if( iShutDown )
        {
        iShutDown->Cancel();
        }

    if( iConnNotif )
        {
        iConnNotif->Cancel();
        }
    
    Cancel();
    CLOG_WRITE( "Canceled" );
    iConnStage = KConnectionUninitialised;

	CLOG_WRITE( "Closing connection" );
    iConnection.Close();
    CLOG_WRITE( "Conn closed" );

    // Pause the downloads  
    CArrayPtrFlat<CHttpDownload>* downloads = 
                                iClientApp->Downloads();
    for( TInt i = 0; i < downloads->Count(); ++i )
        {
        if( (*downloads)[i]->ConnHandler() == this )
            {
            TRAP_IGNORE( (*downloads)[i]->PauseL( ETrue ) );
            }
        }
    if( !iClientInst && !aFromDestructor )
        // Client instance already exited and all download disconnected ->
        // no need for this connhandler anymore.
        // the next client will create a new connhandler and assigned downloads
        // will use that one.
        {
        CLOG_WRITE( "Destroy me" );
        // DO NOT USE 'this' after this call!!!
        iClientApp->DestroyConnHandler( this );
        }
    }
// -----------------------------------------------------------------------------
// CHttpConnHandler::ConnectionStageChanged
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::ConnectionStageChanged( TInt aStage )
    {
    CLOG_WRITE8_1( "Stage: %d", aStage );

    iConnStage = aStage;

    if( iConnStage == KConnectionUninitialised || 
        iConnStage == KDataTransferTemporarilyBlocked
        )
        {
        __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
        CArrayPtrFlat<CHttpDownload>* downloads = 
                                    iClientApp->Downloads();
        for( TInt i = 0; i < downloads->Count(); ++i )
            {
            if( (*downloads)[i]->ConnHandler() == this )
                {
                if( iConnStage == KConnectionUninitialised )
                    {
                    // from now on this name is invalid -> forget it!
                    delete iConnName; iConnName = NULL;

                    (*downloads)[i]->Disconnected();
                    }
                else
                    {
                    (*downloads)[i]->Suspended();
                    }
                }
            }

        if( iConnStage == KConnectionUninitialised )
            {
            ShutDown();
            }
        if ( iConnStage == KDataTransferTemporarilyBlocked )
            {
            iShutDown->Start( KShutDownTimer );
            }     
        }
    else if( iConnStage == KLinkLayerOpen )
        // connection open
        {
        Connected();
        }
    }
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::FindDownload
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
CHttpDownload* 
    CHttpDownloadManagerServerEngine::FindDownload( TInt32 aDownloadId )
    {
    for( TInt apps = 0; apps < iClientApps->Count(); ++apps )
        {
        CArrayPtrFlat<CHttpDownload>* allDownloads = (*iClientApps)[apps]->Downloads();

        for( TInt i = 0; i < allDownloads->Count(); ++i )
            {
            if( (*allDownloads)[i]->Id() == aDownloadId )
                {
                return (*allDownloads)[i];
                }
            }
        }

    return NULL;        
    }
// -----------------------------------------------------------------------------
// CHttpConnHandler::Referencies
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CHttpConnHandler::Referencies()
    {
    TInt refs( 0 );

    __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
    CArrayPtrFlat<CHttpDownload>* downloads = 
                                iClientApp->Downloads();

    for( TInt i = 0; i < downloads->Count(); ++i )
        {
        if( (*downloads)[i]->ConnHandler() == this )
            {
            ++refs;
            }
        }

    return refs;
    }
CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
{
    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = new CArrayPtrFlat<MEikSrvNotifierBase2>(1);
    if (notifiers)
    {
        TRAPD(err, CreateNotifiersL(*notifiers));
        if (err)
        {
            TInt count = notifiers->Count();
            while (count--)
            {
                (*notifiers)[count]->Release();
            }
            delete notifiers;
            notifiers = NULL;
        }
    }
    return notifiers;
}
示例#19
0
void CWapThdrTestStep::_PrintSegments(CArrayPtrFlat<HBufC8>& aSegmentArray)
/**
 *  print an array of segments to the console
 */
{
    TBuf<16>  NumStr;
    TInt Count = aSegmentArray.Count();
    for (TInt i=0; i<Count; i++)
    {
        NumStr.Num(i);
        INFO_PRINTF1(NumStr);
        _Print(_L8(": "));
        NumStr.Num((*aSegmentArray[i]).Length());
        INFO_PRINTF1(NumStr);
        _Print(_L8(": "));
        _Print(*aSegmentArray[i]);
        _Print(_L8("\n"));
    }
}
示例#20
0
/**
 Sets the animation frames to the player.
*/
void RBitmapAnim::SetFrameArrayL(const CArrayPtrFlat<CBitmapFrameData>& aFrameArray)
	{
	const TInt count = aFrameArray.Count();

	if (count > 0)
		{
		User::LeaveIfError(CommandReply(EBitmapAnimCommandResetFrameArray));
		CBitmapFrameData* frameData;
		User::LeaveIfError(CommandReply(EBitmapAnimCommandClearDataFrames));

		TInt index = 0;

		for (index = 0; index < count; index++)
			{
			frameData = aFrameArray.At(index);
			SetFrameL(*frameData, EBitmapAnimCommandSetDataFrame);
			}
		}
	}
LOCAL_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
	{
	CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers =
        new CArrayPtrFlat<MEikSrvNotifierBase2>(1);
        if (notifiers)
        {
          TRAPD(err, CreateNotifiersL(notifiers));
          if (err)
          { // release any notifiers we have created
		          TInt count = notifiers->Count();
              while (--count >= 0)
                {
                (*notifiers)[count]->Release();
                }
              delete notifiers;
              notifiers = NULL;
          }
        }
	return notifiers;
	}
// ---------------------------------------------------------------------------
// ?description
// ---------------------------------------------------------------------------
//
CArrayPtr<MEikSrvNotifierBase2>* CreateNotifierArrayL()
    {
    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = 
        new( ELeave ) CArrayPtrFlat<MEikSrvNotifierBase2>( KBTNotifWrapperArraySize );
    CleanupStack::PushL( notifiers );
    // Create all the notifiers:
    // Connection authorization notifier
    CreateAndAppendNotifierLC( *notifiers, KBTManAuthNotifierUid, KBTAuthChannel );
    // Old and new PIN notifiers
    CreateAndAppendNotifierLC( *notifiers, KBTManPinNotifierUid, KBTAuthChannel );
    CreateAndAppendNotifierLC( *notifiers, KBTPinCodeEntryNotifierUid, KBTAuthChannel );
    // Secure simple pairing notifiers
    CreateAndAppendNotifierLC( *notifiers, KBTNumericComparisonNotifierUid, KBTAuthChannel );
    CreateAndAppendNotifierLC( *notifiers, KBTPasskeyDisplayNotifierUid, KBTAuthChannel );
    
    // todo: add
    // KBTUserConfirmationNotifierUid for incoming JW dedicated bonding.
    
    CreateAndAppendNotifierLC( *notifiers, KDeviceSelectionNotifierUid, KBTDiscoveryChannel );
    
    CreateAndAppendNotifierLC( *notifiers, KBTGenericInfoNotifierUid, KBTInfoChannel );

    CreateAndAppendNotifierLC( *notifiers, KPowerModeSettingNotifierUid, KBTPowerModeChannel );
    /*
     * todo:
     * Other notifiers to be migrated:
     * 
     * existing stack notifiers:
     * CreateAndAppendNotifierL( aArray, KPbapAuthNotifierUid, KBTObexPINChannel );
     * 
     * S60-defined platform:
     * CreateAndAppendNotifierL( aArray, KBTObexPasskeyQueryNotifierUid, KBTObexPINChannel );
     * CreateAndAppendNotifierL( aArray, KBTGenericQueryNotifierUid, KBTQueryChannel );
     * 
     * new (PAN-related):
     * CreateAndAppendNotifierL( aArray, KBTPanDeviceSelectionNotifierUid, KBTDiscoveryChannel );
     * CreateAndAppendNotifierL( aArray, KBTPanNapUplinkAuthorisationNotifierUid, KBTAuthChannel );
     */
    CleanupStack::Pop( notifiers->Count() + 1, notifiers );  // Each notifier + notifier array itself
    return notifiers;
    }
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::ActiveDownloads
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CHttpDownloadManagerServerEngine::ActiveDownloads() const
    {
    LOGGER_ENTERFN( "ActiveDownloads" );

    TInt downloads( 0 );

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

        for( TInt dl = 0; dl < dlArray->Count(); ++dl )
            {
            if( (*dlArray)[dl]->State() == EHttpDlInprogress )
                {
                ++downloads;
                }
            }
        }

    return downloads;
    }
//------------------------------------------------------------------------
//CHttpDownloadManagerServerEngine::MMCModeChanged
//------------------------------------------------------------------------
void CHttpDownloadManagerServerEngine::MMCModeChanged( TBool aMmcPresent )
    {
    for( TInt apps = 0; apps < iClientApps->Count(); ++apps )
        {
        CArrayPtrFlat<CHttpDownload>* allDownloads = (*iClientApps)[apps]->Downloads();

        for( TInt i = 0; i < allDownloads->Count(); ++i )
            {
            QueryMMCUniqueId();
            
            if( aMmcPresent )
                {
                (*allDownloads)[i]->MediaInserted( iMMCUniqueID );
                }
            else
                {
                (*allDownloads)[i]->MediaRemoved( iMMCUniqueID );
                }
            }
        }
    }
// -----------------------------------------------------------------------------
// 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;
    }
// -----------------------------------------------------------------------------
// CHttpDownloadManagerServerEngine::IsDownloadAttached
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TBool CHttpDownloadManagerServerEngine::IsAttachedAlready(TInt32 aDownloadId)
{
    LOGGER_ENTERFN( "IsAttachedAlready" );

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

        for( TInt dl = 0; dl < dlArray->Count(); ++dl )
            {
            if( (*dlArray)[dl]->Id() == aDownloadId )
                {
				if ((*dlArray)[dl]->PDClientAppInstance())
					{
						return ETrue;
					}
                }
            }
        }

    return EFalse;

}
// -----------------------------------------------------------------------------
// CHttpConnHandler::RunL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::RunL()
    {
    LOGGER_ENTERFN( "RunL()" );
    CLOG_WRITE8_1( "%d", iStatus.Int() );
    if( iStatus.Int() != KErrNone )
        {
        iNewConnection = EFalse;

        CArrayPtrFlat<CHttpDownload>* downloads = 
                                    iClientApp->Downloads();
        for( TInt i = 0; i < downloads->Count(); ++i )
            {
            if( (*downloads)[i]->ConnHandler() == this )
                {
                (*downloads)[i]->ConnectionFailed( iStatus.Int() );
                }
            }
        }
    else
        {
        // Have to check the connection stage if the it was cloned.
        TNifProgress progress;

        iConnection.Progress( progress );

        iConnStage = progress.iStage;
        CLOG_WRITE_1( "Stage: %d", iConnStage );

        if( iConnStage == KLinkLayerOpen )
            // Connect request was issued by download when connection was already 
            // open -> RConnection.Start() wasn't called, only the request
            // was completed.
            {
            Connected();
            }
        }
    }
示例#28
0
void CX509SigningAlgorithmIdentifier::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
	{
	TASN1DecSequence encSeq;
	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
	TInt count = seq->Count();
	TASN1DecObjectIdentifier encOID;
	HBufC* oid = encOID.DecodeDERL(*(seq->At(0)));
	CleanupStack::PushL(oid);
	TPtrC oidDes(oid->Des()); 
	//none of the signing algorithms we support have parameters here...
	HBufC8* encodedParams = HBufC8::NewLC(1);
	*encodedParams = KNullDesC8;

	if (oidDes == KDSAWithSHA1)
		{
		//should be no params, but we allow params encoded as NULL for interop reasons
		TAlgorithmId algId = EDSA;
		TAlgorithmId digestId = ESHA1;
		iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
		iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
		if (count == 1)
			{			
			CleanupStack::PopAndDestroy(3);//seq, oid, encodedParams
			return;
			}
		}

	if (oidDes == KMD2WithRSA)
		{
		TAlgorithmId algId = ERSA;
		TAlgorithmId digestId = EMD2;
		iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
		iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
		}

	if (oidDes == KMD5WithRSA)
		{
		TAlgorithmId algId = ERSA;
		TAlgorithmId digestId = EMD5;
		iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
		iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
		}

	if (oidDes == KSHA1WithRSA  || oidDes == KSHA1WithRSASignature)
		{
		TAlgorithmId algId = ERSA;
		TAlgorithmId digestId = ESHA1;
		iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
		iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
		}

	if (oidDes == KSHA224WithRSA)
         {
         TAlgorithmId algId = ERSA;
         TAlgorithmId digestId = ESHA224;
         iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
         iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
         }
	
	if (oidDes == KSHA256WithRSA)
         {
         TAlgorithmId algId = ERSA;
         TAlgorithmId digestId = ESHA256;
         iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
         iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
         }

	if (oidDes == KSHA384WithRSA)
         {
         TAlgorithmId algId = ERSA;
         TAlgorithmId digestId = ESHA384;
         iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
         iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
         }

	if (oidDes == KSHA512WithRSA)
         {
         TAlgorithmId algId = ERSA;
         TAlgorithmId digestId = ESHA512;
         iDigestAlgorithm = CAlgorithmIdentifier::NewL(digestId, encodedParams->Des());
         iAsymmetricAlgorithm = CAlgorithmIdentifier::NewL(algId, encodedParams->Des());
         }

		//???not sure if we should just leave here...
	if (iDigestAlgorithm == NULL)
		{	
		User::Leave(KErrNotSupported);
		}
	else
		{
		if (count != 2)
			{
			// Shouldn't ever get here, since RFC2459 mandates having 2
			// data items.  However, some people miss out the second
			// when it's NULL, so we'll not report and error here
			}
		else
			{
			TASN1DecGeneric* gen = seq->At(1);
			TASN1DecNull null;
			null.DecodeDERL(*gen);//just to check the syntax is OK
			}
		}
	CleanupStack::PopAndDestroy(3);//seq, oid, encodedParams
	}
示例#29
0
TBool IkePkiUtils::VerifySignatureL(TInt aIkeVersion, 
                                    const TDesC8& aSignature, 
                                    const TDesC8& aRefHash, 
                                    const CX509Certificate& aCert)
    {
	//
	// Verify IKE signature. 
	//
	TBool status = EFalse;
	
	if ( aSignature.Length() > 0 )	
	    {	    	
    	CIkePublicKey* publicKey = CIkePublicKey::NewL(aCert);
    	if ( !publicKey )
    	    {	    
    		return EFalse;			
    	    }

    	CleanupStack::PushL(publicKey);			

    	switch (publicKey->Algorithm())
    	    {
    		case EPKIRSA:
    			{
                HBufC8 *resBuf;
                TUtlCrypto::RsaPublicKeyDecryptL(publicKey->KeyData(), aSignature, resBuf);
                CleanupStack::PushL(resBuf);							
                
                if ( aIkeVersion == MAJORV1 ) 
                    {
                    //
                    // Because IKEv1 signature is not a "real" PKCS1
                    // encoded signature but pure private encrypted has
                    // signature is verified by using RSA public key
                    // decrypt and result comparison to reference hash
                    //
                    status = (aRefHash.Compare(*resBuf) == 0); //Compare the result with the hash to see if they match
                    }
                else
    				{
                    //
                    // IKEv2(n) signature is encoded as PKCS1v1_5
                    // signature (EMSA-PKCS1-v1_5)
                    // ASN1 encoding of signature is the following:
                    //	DigestInfo::=SEQUENCE{
                    //	  digestAlgorithm  AlgorithmIdentifier,
                    //	  digest OCTET STRING }
                    //
                    CArrayPtrFlat<TASN1DecGeneric>* seq = NULL;
                    TInt position = 0;
    									
                    TRAPD(err, seq = DecodeDERL(*resBuf, position));
                    if ( err == KErrNone )
                        {
                        TCleanupItem CleanupSeq(IkeCert::CleanupSequence, seq);						
                        CleanupStack::PushL(CleanupSeq);
                        if (seq->Count() == 2)
                            {
                            //
                            // Currently the digestAlgorithm is not
                            // verified, but only digest value itself is
                            // compared with reference hash.
                            // ( see CPKCS1SignatureResult::DoVerifyL() in
                            //   x509cert.cpp)
                            // 
                            const TASN1DecGeneric* gen2 = seq->At(1);                            
                            TPtrC8 digest(gen2->GetContentDER());
                            status = (aRefHash.Compare(digest) == 0);
                            }
                        CleanupStack::PopAndDestroy(); //CleanupSeq
                        }
                    else
                        {
                        //
                        // Verify signature as pure encrypted (SHA1)
                        // hash as old IKEv1 style "signature" 
                        //
                        //DEB(iService.PrintText(_L("Old IKEv1 style signature used by IKEv2 peer !\n"));)					   
                        status = (aRefHash.Compare(*resBuf) == 0); //Compare the result with the hash to see if they match					   
                        }	
    				}
                CleanupStack::PopAndDestroy(resBuf);
    			break;
    			}
            case EPKIDSA:
                {
                const TPtrC8 sigR = aSignature.Left(aSignature.Length() / 2);
                const TPtrC8 sigS = aSignature.Right(aSignature.Length() / 2);

                status = TUtlCrypto::DsaVerifySignatureL(publicKey->KeyData(), 
                                                         publicKey->KeyParams(), 
                                                         sigR, sigS, aRefHash);
                break;
                }
            default:        //Only RSA and DSA are valid
                User::Invariant();
            	break;
    		}

    	CleanupStack::PopAndDestroy(publicKey);
	    }
	return status;
    }	
示例#30
0
void CX509Certificate::ConstructCertL()
	{
	TPtrC8 signedData = SignedDataL();
	TASN1DecSequence encSeq;
	TInt pos = 0;
	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(signedData, pos, 6, KMaxTInt);//6 is the minimum number of elements in an x509 cert
	TInt count = seq->Count();
	pos = 0;
	TASN1DecGeneric* curr = seq->At(pos);
	pos++;
	iDataElements = new(ELeave) TFixedArray<TPtrC8*, KX509MaxDataElements>;
	iDataElements->Reset();
	TPtrC8** pElement = iDataElements->Begin();
	if ((curr->Class() == EContextSpecific) && (curr->Tag() == 0))
		{
		//version!
		TASN1DecGeneric ver(curr->GetContentDER());
		ver.InitL();
		TPtrC8 pVer8 = ver.GetContentDER();
		if(pVer8.Length() != 1)
			{
			User::Leave(KErrArgument);
			}
		iVersion = (pVer8[0]) + 1;
		if ((iVersion < 1) || (iVersion > 3) || (count < 7))
			{
			User::Leave(KErrArgument);
			}
		*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
		curr = seq->At(pos);
		pos++;
		}
	else
		{
		*pElement++ = NULL;
		}
	if (curr->Tag() != EASN1Integer)
		{
		User::Leave(KErrArgument);
		}
	iSerialNumber = (curr->GetContentDER()).AllocL();
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
	curr = seq->At(pos);
	pos++;
	CX509SigningAlgorithmIdentifier* algorithmId = CX509SigningAlgorithmIdentifier::NewLC(curr->Encoding());
	if (!(SigningAlgorithm() == *(algorithmId)))
		{
		User::Leave(KErrArgument);
		}
	CleanupStack::PopAndDestroy();//algorithmId
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());

	curr = seq->At(pos);
	pos++;
	iIssuerName = CX500DistinguishedName::NewL(curr->Encoding());
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
	curr = seq->At(pos);
	pos++;
	iValidityPeriod = CX509ValidityPeriod::NewL(curr->Encoding());
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
	curr = seq->At(pos);
	pos++;
	iSubjectName = CX500DistinguishedName::NewL(curr->Encoding());
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
	curr = seq->At(pos);
	pos++;
	iSubjectPublicKeyInfo = CX509SubjectPublicKeyInfo::NewL(curr->Encoding());
	*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
	//do issuer uid, subject uid, exts
	//these are all optional
	TBool hasIssuerUid = EFalse;
	TBool hasSubjectUid = EFalse;
	TBool hasExts = EFalse;
	iExtensions = new(ELeave)CArrayPtrFlat<CX509CertExtension> (1);
	if (pos < count)//otherwise there aren't any of 'em
		{
		curr = seq->At(pos);
		pos++;
		if (curr->Class() != EContextSpecific)
			{
			User::Leave(KErrArgument);
			}
		switch(curr->Tag())
			{
			case 1:
				{
				iIssuerUid = DecodeUidL(curr->GetContentDER(), hasIssuerUid);
				*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
				break;
				}
			case 2:
				{
				iSubjectUid = DecodeUidL(curr->GetContentDER(), hasSubjectUid);
				*pElement++ = NULL;
				*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
				break;
				}
			case 3:
				{
				DecodeExtsL(curr->GetContentDER(), hasExts);
				*pElement++ = NULL;
				*pElement++ = NULL;
				*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
				break;
				}
			default:
				{
				User::Leave(KErrArgument);
				}
			}
		if (pos < count)
			{
			curr = seq->At(pos);
			pos++;
			switch(curr->Tag())
				{
				case 2:
					{
					iSubjectUid = DecodeUidL(curr->GetContentDER(), hasSubjectUid);
					*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
					break;
					}
				case 3:
					{
					DecodeExtsL(curr->GetContentDER(), hasExts);
					*pElement++ = NULL;
					*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
					break;
					}
				default:
					{
					User::Leave(KErrArgument);
					}
				}
			if (pos < count)
				{
				curr = seq->At(pos);
				pos++;
				if (curr->Tag() == 3)
					{
					DecodeExtsL(curr->GetContentDER(), hasExts);
					*pElement++ = new(ELeave) TPtrC8(curr->Encoding());
					}
				else
					{
					User::Leave(KErrArgument);
					}
				}
			}
		}
	if (pos != count)
		{
		User::Leave(KErrArgument);
		}
	if (!iIssuerUid)
		{
		iIssuerUid = HBufC8::NewL(1);
		*iIssuerUid = KNullDesC8;
		}
	if (!iSubjectUid)
		{
		iSubjectUid = HBufC8::NewL(1);
		*iSubjectUid = KNullDesC8;
		}
		
	// we have not checked for the certificate version number based on 
	// the certificate contents. This is primarily done to avoid BC for 
	// clients who are still using malformed certificates.
	
	CleanupStack::PopAndDestroy();//seq
	}