Exemple #1
0
// ----------------------------------------------------------------------------
// CMceInReferTest::RespondTest3L
// ----------------------------------------------------------------------------
//
void CMceInReferTest::RespondTest3L()
    {
    EUNIT_ASSERT( iManager->Events().Count() == 0 );
    MCE_INCOMING_REFER( iManager );
    EUNIT_ASSERT( iManager->Events().Count() == 1 );
    EUNIT_ASSERT( iManager->Refers().Count() == 1 );
    
    iInRefer = static_cast<CMceInRefer*>( iManager->Refers()[0] );
    EUNIT_ASSERT( iInRefer->IsInRefer() );
    EUNIT_ASSERT( iInRefer->Type() == CMceRefer::ENoSuppression );
    EUNIT_ASSERT( iInRefer->State() == CMceRefer::EIdle );
    
    CDesC8ArrayFlat* headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( headers );
    headers->AppendL( KMceHeader1 );
    headers->AppendL( KMceHeader2 );    
    
    iInEvent = iInRefer->RespondL(_L8("NOT_FINE"), 444, headers );
    CleanupStack::Pop( headers );
    EUNIT_ASSERT( !iInEvent );
    EUNIT_ASSERT( iInRefer->State() == CMceRefer::ETerminated );
    EUNIT_ASSERT( iStorage->iIDS.iSessionID == iInRefer->Id() );
    
    iInEvent = static_cast<CMceInEvent*>( iManager->Events()[0] );
    MCE_SES_RECEIVE( iInEvent, KErrCompletion );
    iInEvent = NULL;
    }
// ---------------------------------------------------------------------------
// UT_CMCENatUseCases::SetupL
// ---------------------------------------------------------------------------
void UT_CMCENatUseCases::SetupL()
{
    CMCETls::OpenL();
    SdpCodecStringPool::OpenL();

    iIds.iAppUID = 10;
    iIds.iProfileID = 1;
    iIds.iManagerType = KMceCSSIPSession;
    iIds.iDialogType = KMceDlgTypeInvite;
    iServerCore = CMceServerCore::NewL();
    iStorage = CMCETls::Storage();

    iNatSessionId = 3;
    iServerCore->Manager().MediaManager().NatPluginManager().iEnabled = ETrue;

    CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( params );
    params->AppendL( _L8("") );
    params->AppendL( _L8("*****@*****.**") );

    CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
    CleanupStack::PushL( msgParams );
    iStorage->StoreL( iIds, *msgParams );
    CleanupStack::PopAndDestroy( msgParams );
    CleanupStack::PopAndDestroy( params );

    iSession = CMceCsSession::NewL( *iServerCore );
    iSession->SetClientUidL( iIds, RMessage2() );
    iSession->CreateSubSessionL( iIds, RMessage2() );

    iNatSipSession = static_cast<CMceNatSipSession*>(
                         (iSession->Implementation().SubSessions())[0] );
}
void UT_CMceStateError::SetupL(  )
    {
    CMCETls::OpenL();
    
    //TMceIds ids;
    iIds.iProfileID = 1;
    iIds.iManagerType = KMceCSSIPSession;
    iIds.iDialogType = KMceDlgTypeInvite;
    iServerCore = CMceServerCore::NewL();
    
    iStorage = CMCETls::Storage();
    
	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
	CleanupStack::PushL( params );
	params->AppendL( _L8("User <user2@host>") );
	params->AppendL( _L8("User <user@host>") );
    
    CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
    CleanupStack::PushL( msgParams );
    iStorage->StoreL( iIds, *msgParams );
    CleanupStack::PopAndDestroy( msgParams );
    CleanupStack::PopAndDestroy( params );
    
    iSession = CMceCsSession::NewL(*iServerCore);
    iSession->CreateSubSessionL(iIds, RMessage2());
    iSipSession =  static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]);
    
    iSipSession->NextState( KMceStateError );
    iState = static_cast<CMceStateError*>(&iSipSession->CurrentState());
    
    }
void UT_CMceStateOffering::SetupL(  )
    {
    CMCETls::OpenL();
    SdpCodecStringPool::OpenL();

    //TMceIds ids;
    iIds.iProfileID = 1;
    iIds.iManagerType = KMceCSSIPSession;
    iIds.iDialogType = KMceDlgTypeInvite;
    iServerCore = CMceServerCore::NewL();
    
    iStorage = CMCETls::Storage();
    
	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
	CleanupStack::PushL( params );
	params->AppendL( _L8("User <user2@host>") );
	params->AppendL( _L8("User <user@host>") );
    
    CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
    CleanupStack::PushL( msgParams );
    iStorage->StoreL( iIds, *msgParams );
    CleanupStack::PopAndDestroy( msgParams );
    CleanupStack::PopAndDestroy( params );
    
    iSession = CMceCsSession::NewL(*iServerCore);
    iSession->CreateSubSessionL(iIds, RMessage2());
    iSipSession =  static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]);
    
    CSIPClientTransaction* transaction = 
        MCETestHelper::ClientTransactionLC( 
            SipStrConsts::EInvite, KMceSipOK, SipStrConsts::EPhraseOk, ETrue );
	iSipSession->SetPendingTransactionL( transaction );
    CleanupStack::Pop( transaction );    
    iSipSession->iResponse = transaction;
    
    iSipSession->iBody = CMceComSession::NewL( CMceComSession::EOutSession );
    imServer = new (ELeave) CMceServerStub();
    iManager = CMceMediaManager::NewL( *imServer );
    iSdpSession = CMceSdpSession::NewL( *iSipSession->iBody, *iManager );

    iSipSession->NextState( KMceStateOffering );  
    iState = static_cast<CMceStateOffering*>(&iSipSession->CurrentState());
    
    iSipSession->iOffer = CSdpDocument::NewL();        
    }
Exemple #5
0
TCertStatus PkiUtil::CheckUserCertValidityL(RPKIServiceAPI& aPkiService,
        CDesC8ArrayFlat& aValidCaCertNameList,
        TOwnCertInfo& aOwnCert)
{

    static const TInt KUndefinedKeySize = 0;

    TCertStatus status = ECertValid;

    HBufC8* subjectName = NULL;
    HBufC8* rfc822Name = NULL;

    if (aOwnCert.iOwnCertExists)
    {
        // Reserve enough space for UTF-8
        TInt len = 3*( aOwnCert.iSubjectDnSuffix.Length() );
        subjectName = HBufC8::NewLC(len);
        TPtr8 subjectNamePtr = subjectName->Des();
        if (CnvUtfConverter::ConvertFromUnicodeToUtf8(subjectNamePtr, aOwnCert.iSubjectDnSuffix) != 0)
        {
            User::Leave(KErrCorrupt);
        }

        if ( aOwnCert.iIdentityAsRfc822Name == EIdentityAsRfc822NameYes)
        {
            rfc822Name = HBufC8::NewLC(aOwnCert.iRfc822NameFqdn.Length());
            TPtr8 rfc822NamePtr = rfc822Name->Des();
            if (CnvUtfConverter::ConvertFromUnicodeToUtf8(rfc822NamePtr, aOwnCert.iRfc822NameFqdn) != 0)
            {
                User::Leave(KErrCorrupt);
            }

        }
        else
        {
            rfc822Name = HBufC8::NewLC(1); //empty string
        }

        status = ECertNotFound;
        for (TInt i = 0; i < aValidCaCertNameList.Count(); ++i)
        {

            status = CertStatusL(aPkiService, aValidCaCertNameList[i],
                                 *subjectName, *rfc822Name,
                                 KUndefinedKeySize);
            if (status != ECertNotFound)
            {
                break;
            }
        }

        CleanupStack::PopAndDestroy(rfc822Name);
        CleanupStack::PopAndDestroy(subjectName);
    }

    return status;
}
QStringList S60FormatSupported::supportedPlayMimeTypesL()
{
    RArray<TUid> mediaIds; //search for both audio and video
    RMMFControllerImplInfoArray iControllers;
    m_controllerparam = CMMFControllerPluginSelectionParameters::NewL();
    m_playformatparam = CMMFFormatSelectionParameters::NewL();
    mediaIds.Append(KUidMediaTypeAudio);
    mediaIds.Append(KUidMediaTypeVideo);
    m_controllerparam->SetMediaIdsL(mediaIds, CMMFPluginSelectionParameters::EAllowOtherMediaIds);
    m_controllerparam->SetRequiredPlayFormatSupportL(*m_playformatparam);
    m_controllerparam->ListImplementationsL(iControllers);
    CDesC8ArrayFlat* controllerArray = new (ELeave) CDesC8ArrayFlat(1);
    for (TInt i = 0; i < iControllers.Count(); i++) {
        for (TInt j = 0; j < (iControllers[i]->PlayFormats()).Count(); j++) {
            const CDesC8Array& iarr = (iControllers[i]->PlayFormats()[j]->SupportedMimeTypes());
            TInt count = iarr.Count();
            for (TInt k = 0; k < count; k++) {
                TPtrC8 ptr = iarr.MdcaPoint(k);
                HBufC8* n = HBufC8::NewL(ptr.Length());
                TPtr8 ptr1 = n->Des();
                ptr1.Copy((TUint8*) ptr.Ptr(), ptr.Length());
                controllerArray->AppendL(ptr1);
            }
        }
    }

    // converting CDesC8Array to QStringList
    for (TInt x = 0; x < controllerArray->Count(); x++) {
        m_supportedplaymime.append(QString::fromUtf8(
                (const char*) (controllerArray->MdcaPoint(x).Ptr()),
                controllerArray->MdcaPoint(x).Length()));
    }

    // populating the list with only audio and controller mime types
    QStringList tempaudio = m_supportedplaymime.filter(QString("audio"));
    QStringList tempvideo = m_supportedplaymime.filter(QString("video"));

    m_supportedplaymime.clear();
    m_supportedplaymime = tempaudio + tempvideo;
    mediaIds.Close();
    delete controllerArray;
    iControllers.ResetAndDestroy();
    return m_supportedplaymime;
}
void CSdlAppUi::StartTestL(TInt aCmd)
{

	//TInt flags = CSDL::EDrawModeGdi | CSDL::EEnableFocusStop
	//		| CSDL::EMainThread;// | CSDL::EAutoOrientation;

	TInt flags = 0;

	//flags |= CSDL::EDrawModeDSB | CSDL::EDrawModeDSBDoubleBuffer;
	flags |= CSDL::EDrawModeGdi;
	// Don't draw when in background.
	//flags |= CSDL::EEnableFocusStop;
	flags |= CSDL::EAutoOrientation;
	// This should be on by default anyway
	flags |= CSDL::EMainThread;

	//Create CommandLine Arguments and read it.
	CDesC8ArrayFlat *arr = new (ELeave) CDesC8ArrayFlat(1);
	CleanupStack::PushL(arr);

	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	// The real args we are interested in start at the 2nd arg
	for (TInt i = 1; i < args->Count(); i++)
	{
		TBuf8<256> arg;
		arg.Copy(args->Arg(i));

		arr->AppendL(arg);
		//TPtrC argumentPrt(args->Arg(i));
		//console->Printf(_L("Arg %d == %S\n"), i, &argumentPrt);
	}

	iSdl = CSDL::NewL(flags);

	iSdl->SetContainerWindowL(iSDLWin->GetWindow(), iEikonEnv->WsSession(),
			*iEikonEnv->ScreenDevice());
	iSdl->CallMainL(iWait->iStatus, *arr, flags, 0x14000);
	iWait->Start();

	arr->Reset();
	CleanupStack::PopAndDestroy(2); // command line and arr
}
void CCalAlarmAttachTest::TestCopyEntryWithAlarmContentL()
    {
    test.Printf(_L("Test copying entry but delete the original one\n"));
    _LIT8(KUidEntryOriginal, "EntryOriginalUid");
    CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KUidEntryOriginal());
    CleanupStack::PopAndDestroy(alarm);
    
    RPointerArray<CCalEntry> entries;
    CleanupResetAndDestroyPushL(entries);
    iTestLib->SynCGetEntryViewL().FetchL(KUidEntryOriginal(), entries);
    
    // Copy the entry from the original one
    _LIT8(KUidEntryCopy, "EntryCopyUid");
    HBufC8* guid1 = KUidEntryCopy().AllocLC();
    CCalEntry* copiedEntry = CCalEntry::NewL(CCalEntry::EEvent, guid1, CCalEntry::EMethodNone,0);
    CleanupStack::Pop(guid1);
    CleanupStack::PushL(copiedEntry);
    copiedEntry->CopyFromL(*entries[0],CCalEntry::EDontCopyId);//restore the alarmaction
    entries.ResetAndDestroy();
    entries.AppendL(copiedEntry);
    CleanupStack::Pop(copiedEntry);
     
 //delete the original entry that will delete the alarm and its content 
    CDesC8ArrayFlat* guidArray = new(ELeave)CDesC8ArrayFlat(1);
    CleanupStack::PushL(guidArray);
    guidArray->AppendL(KUidEntryOriginal());
    iTestLib->SynCGetEntryViewL().DeleteL(*guidArray);
    CleanupStack::PopAndDestroy(guidArray);
    
    //Store the copied entry and access its alarm content
    TestAlarmL(copiedEntry, KContent(), KMimeType());
    TInt entriesStored = 0;
    iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
    entries.ResetAndDestroy();
    iTestLib->SynCGetEntryViewL().FetchL(KUidEntryCopy(), entries);

    TestAlarmL(entries[0], KContent(), KMimeType());
    CleanupStack::PopAndDestroy(&entries);
    }
void UT_CMceStateOffering::Setup2L(  )
    {
    CMCETls::OpenL();
    SdpCodecStringPool::OpenL();

    //TMceIds ids;
    iIds.iProfileID = 1;
    iIds.iManagerType = KMceCSSIPSession;
    iIds.iDialogType = KMceDlgTypeInvite;
    iServerCore = CMceServerCore::NewL();
    
    iStorage = CMCETls::Storage();
    
    CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( params );
    params->AppendL( _L8("User <user2@host>") );
    params->AppendL( _L8("User <user@host>") );
    
    CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
    CleanupStack::PushL( msgParams );
    iStorage->StoreL( iIds, *msgParams );
    CleanupStack::PopAndDestroy( msgParams );
    CleanupStack::PopAndDestroy( params );
    
    iSession = CMceCsSession::NewL(*iServerCore);
    iSession->CreateSubSessionL(iIds, RMessage2());
    iSipSession =  static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]);
    
    iSipSession->SetBodyL();
        
    MCETestHelper::RequestL( iSipSession, SipStrConsts::EUpdate, ETrue, EFalse );
    	
    MCE_SET_STATES( iSipSession /*session*/, 
                    CMceSession::EOffering /*clientState*/, 
                    KMceStateOffering /*serverState*/ );
    iState = static_cast<CMceStateOffering*>(&iSipSession->CurrentState());
    HBufC8* token = KMediaToken().AllocL();
    iSipSession->SetMediaAuthorizationToken( token );
    }
/**
 * INPUT:
 *   Headers:		-
 *   Parameters:	AuthenticationMechanism, SecurityParams*
 *   IDs:			-
 *
 * OUTPUT:
 *   Parameters:	-
 *   IDs:			-
 */
void TCmdSetSecurityParams::ExecuteL()
	{
	// -- Setup ---------------------------------------------------------------

	// Get mandatory AuthenticationMechanism
	TPtrC8 mechanism = ExtractTextL( KParamAuthenticationMechanism );

	// Create a string array for the parameter values
	CDesC8ArrayFlat* secParams =
							new( ELeave ) CDesC8ArrayFlat( KTcGranularity );
	CleanupStack::PushL( secParams );

	// Get optional security parameters structure
	CTcStructure* structure = FindStructureL( KParamSecurityParams, EFalse );
	if( structure )
		{
		TInt count = structure->Count();
		for( TInt i = 0; i < count; i++ )
			{
			// Each item is read from the structure
			const CTcNameValue& tv = structure->Item( i );
			// ..and appended to the array formatted as "<name><tab><value>"
			TBuf8< KMaxSecurityParamLength > entry;
			entry.Append( tv.Name() );
			entry.Append( KTab );
			entry.Append( tv.Value() );
			secParams->AppendL( entry );
			}
		}

	// -- Execution -----------------------------------------------------------

//	CSIPSecurity* security = CSIPSecurity::NewLC( iContext.SIP() );
//	security->SetParamsL( mechanism, *secParams );
//	CleanupStack::PopAndDestroy( security );
	CleanupStack::PopAndDestroy( secParams );

	// -- Response creation ---------------------------------------------------
	}
void UT_CMceStateServerEstablishing::SetupL(  )
    {
    CMCETls::OpenL();
    SdpCodecStringPool::OpenL();
    //TMceIds ids;
    iIds.iProfileID = 1;
    iIds.iManagerType = KMceCSSIPSession;
    iIds.iDialogType = KMceDlgTypeInvite;
    iServerCore = CMceServerCore::NewL();
    
    iStorage = CMCETls::Storage();
    
	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
	CleanupStack::PushL( params );
	params->AppendL( _L8("User <user2@host>") );
	params->AppendL( _L8("User <user@host>") );
    
    CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
    CleanupStack::PushL( msgParams );
    iStorage->StoreL( iIds, *msgParams );
    CleanupStack::PopAndDestroy( msgParams );
    CleanupStack::PopAndDestroy( params );
    
    iSession = CMceCsSession::NewL(*iServerCore);
    iSession->CreateSubSessionL(iIds, RMessage2());
    iSipSession =  static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]);
    
    // incoming request
    CSIPServerTransaction* invite = 
        MCETestHelper::ServerTransactionL( SipStrConsts::EInvite );
    CleanupStack::PushL( invite );
    iSipSession->iPendingReceivedRequests.AppendL( invite );
    CleanupStack::Pop( invite );
    
    iSipSession->NextState( KMceStateServerEstablishing );
    
    iState = static_cast<CMceStateServerEstablishing*>(&iSipSession->CurrentState());
    }
/**
* Delete entries by uid list 
*/
void CTestCalInterimApiModifier::DeleteEntriesByUidListL()
	{
	CDesC8ArrayFlat* deleteGuidArray = new(ELeave) CDesC8ArrayFlat(4);
	CleanupStack::PushL(deleteGuidArray);
	const TInt KUidCount(iModifier->iEntryArray.Count());
	for (TInt j(0); j < KUidCount; ++j)
		{
		if(iModifier->iEntryArray[j]->RecurrenceIdL().TimeUtcL() == Time::NullTTime())
			{
			// Deleting a Parent entry deletes all the associated child entries
			// Hence bypasing all child entries
			deleteGuidArray->AppendL(iModifier->iEntryArray[j]->UidL());
			}
		}
	TRAPD(err, iEntryView->DeleteL(*deleteGuidArray));
	CleanupStack::PopAndDestroy(deleteGuidArray);

	if((err != KErrNone))
		{
		iTestStep->ERR_PRINTF2(KErrDeleteOperation,err);
		iTestStep->SetTestStepResult(EFail);
		}
	}
Exemple #13
0
TInt CSocketEngine::GetCookieArray(const TDesC8& aData,CDesC8ArrayFlat& aCookies){
  _LIT8(KSC,"Set-Cookie:");
  TInt cnt=0;
  TPtrC8 r;
  TPtrC8 ptr(aData);
  TInt pos=ptr.FindF(KSC);
  while(pos>=0&&(pos+KSC().Length())<ptr.Length()){
    ptr.Set(ptr.Mid(pos+KSC().Length()));
    pos=ptr.FindF(_L8("\n"));
    if(pos>0){
      r.Set(ptr.Left(pos));
      aCookies.AppendL(r);
      cnt++;
    }
    pos=ptr.FindF(KSC);
  }
  return cnt;
}
// -----------------------------------------------------------------------------
// CMceOutRefer::ConstructL
// -----------------------------------------------------------------------------
//
void CMceOutRefer::ConstructL( 	const TDesC8& aRecipient,
                    	        const TDesC8& aReferTo,
                    	        TType aType,
                    	        HBufC8* aOriginator )
    {
    CDesC8ArrayFlat* params = 
        new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
	CleanupStack::PushL( params );
    params->AppendL( aReferTo );
    
    if ( iDialogId == KMceNotAssigned )
        {
        params->AppendL( aRecipient );
        if ( aOriginator )
            {
            params->AppendL( *aOriginator );
            }
        else
            {
            params->AppendL( KNullDesC8 );
            }
        }
        
    if ( aType == ENoSuppression )
        {
        HBufC8* originator = NULL;
        if ( aOriginator )
            {
            originator = ( *aOriginator ).AllocL();
            }
        CleanupStack::PushL( originator );
        iOwnedEvent = CMceOutEvent::NewL( iManager,
					                  iProfileId,
					                  aRecipient,
							          KReferEventHeader,
		    				          0,
					                  originator,
					                  iDialogId,
			    	                  KMceDlgTypeRefer,
					                  params );
	    CleanupStack::Pop( originator );
	    CleanupStack::Pop( params );
	    }
    
    HBufC8* recipient = aRecipient.AllocLC();
    HBufC8* referTo = aReferTo.AllocLC();
    
    if ( aType == ENoSuppression )
        {
        CMceRefer::ConstructL( recipient, referTo, aOriginator, NULL );    
        CleanupStack::Pop( referTo );
        CleanupStack::Pop( recipient ); 
        }
    else
        {
        CMceRefer::ConstructL( recipient, referTo, aOriginator, params ); 
        CleanupStack::Pop( referTo );
        CleanupStack::Pop( recipient ); 
        CleanupStack::Pop( params );   
        }
    }
// ----------------------------------------------------------------------------
// CMceOutSessionTest::EstablishTestL
// ----------------------------------------------------------------------------
//
void CMceSecureOutSessionTest::EstablishTestL()
    {
    MCE_CREATE_PROFILE;

    EUNIT_ASSERT( iStorage->iSessionId == 0 );

    iSecureOutSession = CMceSecureOutSession::NewL( *iManager, *profile, KMceRecipient );
    EUNIT_ASSERT( iManager->Sessions().Count() == 1 );
    EUNIT_ASSERT( iSecureOutSession->Recipient().Compare( KMceRecipient ) == 0 );
    EUNIT_ASSERT( iSecureOutSession->Id() == 1 );

    EUNIT_ASSERT( iStorage->iSessionId == 1 );
    
    iSecureOutSession->EstablishL();
    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EOffering );
    EUNIT_ASSERT( iSecureOutSession->Id() == 1 );
    
    
    CMceMsgObject<CMceComSession>* sentSessionMsg = 
            new (ELeave) CMceMsgObject<CMceComSession>();
            
    CleanupStack::PushL( sentSessionMsg );
    sentSessionMsg->DecodeL( *(iStorage->iContext) );
    sentSessionMsg->PushL();
    
    CMceComSession* sentSession = sentSessionMsg->iObject;
    
    EUNIT_ASSERT( sentSession->iType == CMceComSession::EOutSession );
    EUNIT_ASSERT( sentSession->iState == CMceSession::EIdle );
    EUNIT_ASSERT( sentSession->iID == iStorage->iIDS.iSessionID );
    EUNIT_ASSERT( sentSession->Streams().Count() == 0 );

    sentSessionMsg->Pop();
    delete sentSession;
    CleanupStack::PopAndDestroy( sentSessionMsg );

    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EOffering );
    EUNIT_ASSERT( iSecureOutSession->Id() == 1 );

    TRAPD( notReady, iSecureOutSession->EstablishL() );
    MCE_TEST_HANDLE_ALLOC_FAILURE( notReady )
    EUNIT_ASSERT( notReady == KErrNotReady );

    MCE_TEST_DELETE( iSecureOutSession );
    
    EUNIT_ASSERT( iManager->Sessions().Count() == 0 );
    
//detailed
    
    iStorage->Reset();

    iSecureOutSession = CMceSecureOutSession::NewL( *iManager, *profile, KMceRecipient );
    EUNIT_ASSERT( iManager->Sessions().Count() == 1 );
    EUNIT_ASSERT( iSecureOutSession->Recipient().Compare( KMceRecipient ) == 0 );

    for ( int i=0;i<2;i++ )
        {
        
        CMceAudioStream* outStream = CMceAudioStream::NewL();
        CleanupStack::PushL( outStream );
        CMceAudioStream* inStream = CMceAudioStream::NewL();
        CleanupStack::PushL( inStream );
           
        outStream->AddSinkL( CMceRtpSink::NewLC() );
        CleanupStack::Pop();
        outStream->SetSourceL( CMceMicSource::NewLC() );
        CleanupStack::Pop();
        
        CDesC8ArrayFlat* sdp = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
        CleanupStack::PushL( sdp );
        sdp->AppendL( KMceMedialine1 );
        sdp->AppendL( KMceMedialine2 );    
        outStream->SetMediaAttributeLinesL( sdp );
        CleanupStack::Pop( sdp );
        
        inStream->SetSourceL( CMceRtpSource::NewLC() );
        CleanupStack::Pop();
        inStream->AddSinkL( CMceSpeakerSink::NewLC() );
        CleanupStack::Pop();
        
        sdp = 0;
        sdp = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
        CleanupStack::PushL( sdp );
        sdp->AppendL( KMceMedialine1 );
        sdp->AppendL( KMceMedialine2 );    
        inStream->SetMediaAttributeLinesL( sdp );
        CleanupStack::Pop( sdp );
        
        
        outStream->BindL( inStream );
        CleanupStack::Pop( inStream );
        iSecureOutSession->AddStreamL( outStream );
        CleanupStack::Pop( outStream );
        
        // Try to add same stream again 
   		TRAPD( err, iSecureOutSession->AddStreamL( outStream ) );
   		MCE_TEST_HANDLE_ALLOC_FAILURE( err )
   		EUNIT_ASSERT_EQUALS( KErrArgument, err );
  
        }

    static_cast<CMceAudioStream*>( iSecureOutSession->Streams()[1])->BindL( NULL );
    
    CDesC8ArrayFlat* headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( headers );
    headers->AppendL( KMceHeader1 );
    headers->AppendL( KMceHeader2 );    
    
    HBufC8* contentType = KMceContentType().AllocLC();
    HBufC8* body = KMceMessageBody().AllocLC();

    // Leaving cases
    // content type, no content
    TRAPD( err, iSecureOutSession->EstablishL( KMceTestTimeout, 
                             headers,
                             contentType,
                             NULL ) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( err )
    EUNIT_ASSERT( err == KErrArgument );
    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EIdle );
    
    // no content type, content
    TRAPD( err2, iSecureOutSession->EstablishL( KMceTestTimeout, 
                             headers,
                             NULL,
                             body ) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( err2 )
    EUNIT_ASSERT( err2 == KErrArgument );
    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EIdle );
    
    // no headers, no content type, no content, content headers
    TRAPD( err3, iSecureOutSession->EstablishL( KMceTestTimeout, 
                             NULL,
                             NULL,
                             NULL,
                             headers ) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( err3 )                         
    EUNIT_ASSERT( err3 == KErrArgument );
    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EIdle );
    
    iSecureOutSession->EstablishL( KMceTestTimeout, 
                             headers,
                             contentType,
                             body );
                             
    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EOffering );

    CleanupStack::Pop( body );
    CleanupStack::Pop( contentType );
    CleanupStack::Pop( headers );
    
    EUNIT_ASSERT( iStorage->iContent->Compare( KMceMessageBody ) == 0 );
    
    
    sentSessionMsg = new (ELeave) CMceMsgObject<CMceComSession>();
            
    CleanupStack::PushL( sentSessionMsg );
    sentSessionMsg->DecodeL( *(iStorage->iContext) );
    sentSessionMsg->PushL();
    
    sentSession = sentSessionMsg->iObject;
    
    EUNIT_ASSERT( sentSession->iType == CMceComSession::EOutSession );
    EUNIT_ASSERT( sentSession->iState == CMceSession::EIdle );
    EUNIT_ASSERT( sentSession->iID == iStorage->iIDS.iSessionID );
    
    EUNIT_ASSERT( sentSession->iSIPContentType->Compare( KMceContentType ) == 0 );
    EUNIT_ASSERT( sentSession->iSIPHeaders->Count() == 2 );
    EUNIT_ASSERT( sentSession->iSIPHeaders->MdcaPoint( 0 ).Compare( KMceHeader1 ) == 0 );
    EUNIT_ASSERT( sentSession->iSIPHeaders->MdcaPoint( 1 ).Compare( KMceHeader2 ) == 0 );

    
    EUNIT_ASSERT( sentSession->Streams().Count() == 2 );
    
    EUNIT_ASSERT( sentSession->Streams()[0]->iLocalMediaSDPLines->MdcaPoint( 0 ).Compare( KMceMedialine1 ) == 0 );
    EUNIT_ASSERT( sentSession->Streams()[0]->iLocalMediaSDPLines->MdcaPoint( 1 ).Compare( KMceMedialine2 ) == 0 );
    EUNIT_ASSERT( static_cast<CMceComAudioStream*>( sentSession->Streams()[0])->BoundStream() );
    EUNIT_ASSERT( static_cast<CMceComAudioStream*>( sentSession->Streams()[0])->BoundStreamL().iLocalMediaSDPLines->MdcaPoint( 0 ).Compare( KMceMedialine1 ) == 0 );
    EUNIT_ASSERT( static_cast<CMceComAudioStream*>( sentSession->Streams()[0])->BoundStreamL().iLocalMediaSDPLines->MdcaPoint( 1 ).Compare( KMceMedialine2 ) == 0 );
    EUNIT_ASSERT( !static_cast<CMceComAudioStream*>( sentSession->Streams()[1])->BoundStream() );


    TRAPD( notReady2, iSecureOutSession->EstablishL( KMceTestTimeout, NULL, NULL, NULL) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( notReady2 )
    EUNIT_ASSERT( notReady2 == KErrNotReady );
    
    sentSessionMsg->Pop();
    delete sentSession;
    CleanupStack::PopAndDestroy( sentSessionMsg );

    EUNIT_ASSERT( iSecureOutSession->State() == CMceSession::EOffering );

    MCE_DELETE_PROFILE;    
    
    }
Exemple #16
0
// ----------------------------------------------------------------------------
// CMceInReferTest::TerminateTestL
// ----------------------------------------------------------------------------
//
void CMceInReferTest::TerminateTestL()
    {
    EUNIT_ASSERT( iManager->Events().Count() == 0 );
    
    MCE_INCOMING_REFER( iManager );
    
    EUNIT_ASSERT( iManager->Events().Count() == 1 );
    EUNIT_ASSERT( iManager->Refers().Count() == 1 );
    
    iInRefer = static_cast<CMceInRefer*>( iManager->Refers()[0] );
    EUNIT_ASSERT( iInRefer->IsInRefer() );
    EUNIT_ASSERT( iInRefer->Type() == CMceRefer::ENoSuppression );
    EUNIT_ASSERT( iInRefer->State() == CMceRefer::EIdle );
    
    //simple accept
    iInEvent = iInRefer->AcceptL();
    EUNIT_ASSERT( iInRefer->State() == CMceRefer::EPending );
    EUNIT_ASSERT( iStorage->iIDS.iSessionID == iInRefer->Id() );

    //simple accept
    TRAPD(err,iInRefer->AcceptL());
    MCE_TEST_HANDLE_ALLOC_FAILURE( err ) 
    EUNIT_ASSERT( err == KErrNotReady );
    
    MCE_SESSION_STATECHANGE( iInEvent, CMceEvent::EActive, KMceNotAssigned );
    HBufC8* sipfrag = KContentSIPFragType().AllocLC();
	
	HBufC8* messageOK = KContentMsgOK().AllocLC();
	iInEvent->TerminateL( NULL, sipfrag, messageOK );
	
	CleanupStack::Pop( messageOK );
	CleanupStack::Pop( sipfrag );
     //This is needed otherwise it will leave as KErrNotReady when trys to delete event
    iInEvent->iState = CMceEvent::ETerminated ;

	//terminate with headers
	MCE_SESSION_STATECHANGE( iInEvent, CMceEvent::EActive, KMceNotAssigned );
	EUNIT_ASSERT( iInEvent->State() == CMceEvent::EActive );

	CDesC8ArrayFlat* headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( headers );
    headers->AppendL( KMceHeader1 );
    headers->AppendL( KMceHeader2 ); 
    iInEvent->TerminateL(headers);
	CleanupStack::Pop(headers);
	
	//terminate with subscription state headers
	MCE_SESSION_STATECHANGE( iInEvent, CMceEvent::EActive, KMceNotAssigned );
	EUNIT_ASSERT( iInEvent->State() == CMceEvent::EActive );

	CDesC8ArrayFlat* headers2 = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
    CleanupStack::PushL( headers2 );
    headers->AppendL( KMceSubscriptionStateHeader3 );
    headers->AppendL( KMceHeader2 ); 
    iInEvent->TerminateL( headers2 );
	CleanupStack::Pop( headers2 );


    // Leaving cases
    // content type, no content
	MCE_SESSION_STATECHANGE( iInEvent, CMceEvent::EActive, KMceNotAssigned );
	EUNIT_ASSERT( iInEvent->State() == CMceEvent::EActive );

	HBufC8* contentType = KMceEventHeader().AllocLC();
    HBufC8* content = KMceEventHeader().AllocLC();
    
    
    TRAPD( err1, iInEvent->TerminateL( NULL, contentType, NULL ) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( err )   
    EUNIT_ASSERT( err1 == KErrArgument );
    EUNIT_ASSERT( iInEvent->State() == CMceEvent::EActive );
    
    // no content type content
    TRAPD( err2, iInEvent->TerminateL( NULL, NULL, content) );
    MCE_TEST_HANDLE_ALLOC_FAILURE( err2 )   
    EUNIT_ASSERT( err2 == KErrArgument );
    EUNIT_ASSERT( iInEvent->State() == CMceEvent::EActive );
    iInEvent->TerminateL(0, contentType, content);
    CleanupStack::Pop( content );
    CleanupStack::Pop( contentType );	
    }
Exemple #17
0
TCertStatus PkiUtil::GetValidCaCertSubjectNameListL(RPKIServiceAPI& aPkiService,
        const CArrayFixFlat<TCertInfo*>& aIkeCAList,
        CDesC8ArrayFlat& aCaCertNameList)
{

    TCertStatus status = ECertValid;
    RPointerArray<CX509Certificate> certificateList;
    TRAPD(err, certificateList = PkiUtil::GetCaCertListL(aPkiService, aIkeCAList));

    switch(err)
    {
    case KErrNone:
        for (TInt i = 0; i < certificateList.Count(); ++i)
        {
            const CX509Certificate* cert = certificateList[i];
            status = CertStatusL(*cert, -1);

            if (status == ECertValid)
            {
                const CX500DistinguishedName& subjectName = cert->SubjectName();
                HBufC* subjectNameString = PkiUtil::CertDnL(subjectName);
                CleanupStack::PushL(subjectNameString);

                // Reserve enough space for UTF-8
                TInt len = 3*( subjectNameString->Length() );
                HBufC8* subjectNameString8Bit = HBufC8::NewLC(len);
                TPtr8 subjectNameString8BitPtr = subjectNameString8Bit->Des();
                if (CnvUtfConverter::ConvertFromUnicodeToUtf8(subjectNameString8BitPtr,
                        *subjectNameString) != 0)
                {
                    User::Leave(KErrCorrupt);
                }
                TRAPD(err, aCaCertNameList.InsertIsqL(*subjectNameString8Bit));

                CleanupStack::PopAndDestroy(subjectNameString8Bit);
                CleanupStack::PopAndDestroy(subjectNameString);

                err = (err == KErrAlreadyExists) ? KErrNone : err;
                User::LeaveIfError(err);
            }
            else
            {
                aCaCertNameList.Reset();
                break;
            }
        }
        break;
    case KErrNotFound: // Flow through
    case KErrArgument: // CA cert is not found if policys CA DATA is invalid
        status = ECertNotFound;
        break;
    default:
        certificateList.ResetAndDestroy();
        certificateList.Close();
        User::Leave(err);
    }

    certificateList.ResetAndDestroy();
    certificateList.Close();

    return status;
}
/**
 * INPUT:
 *   Headers:		-
 *   Parameters:	ProfileType*, ProfileAOR*
 *   IDs:			RegistryId
 *
 * OUTPUT:
 *	 Parameters:	-
 *	 IDs:			ProfileIdList
 */
void TCmdGetProfiles::ExecuteL()
	{
	// -- Setup ---------------------------------------------------------------

    // Get selected registry
    CTcSIPProfileContainer& container = SelectProfileL();

	// Type
	TcLog::WriteFormat( _L8("-- Get optional structure \"ProfileType\"") );
	CTcStructure* structure = FindStructureL( KParamProfileType, EFalse );
	TSIPProfileTypeInfo typeInfo;
	if( structure )
		{
		TcLog::Write( KLogOk );
		TcLog::WriteFormat( _L8("-- Get mandatory structure item \"ProfileName\"") );
		typeInfo.iSIPProfileName = structure->ItemL( KParamProfileName )->Value();
		TcLog::Write( KLogOk );
		TcLog::WriteFormat( _L8("-- Get mandatory structure item \"Class\"") );
		typeInfo.iSIPProfileClass = ProfileTypeClassL( structure );
		TcLog::Write( KLogOk );
		}
	else
		{
		TcLog::Write( KLogNotFound );
		}

	// Get profile AOR, or KNullDesC8
	TPtrC8 aor = ExtractTextL( KParamProfileAOR, EFalse );

	// -- Execution -----------------------------------------------------------

	RPointerArray< CSIPProfile > profileArray;
	CleanupResetAndDestroyPushL( profileArray );

	// See if Type was given
	if( structure )
		{
		container.ManagedProfileRegistry().ProfilesL( typeInfo, profileArray );
		}
	else if( aor != KNullDesC8 )
		{
		container.ManagedProfileRegistry().ProfilesL( aor, profileArray );
		}
	else
		{
		User::Leave( KTcErrMandatoryParameterNotFound );
		}

	// -- Response creation ---------------------------------------------------

    // Crete response only if some profiles exist
	TInt count = profileArray.Count();
	if ( count > 0 )
	    {
    	CDesC8ArrayFlat* array = new ( ELeave ) CDesC8ArrayFlat( count );
    	CleanupStack::PushL( array );

    	for( TInt i = 0; i < count; i++ )
    		{
    		// Register object
    		CSIPProfile* profile = profileArray[ i ];
    		// Create a name out of the profile id
    		TBuf8< KTcMaxIntConversion > idName;
    		
    		TUint32 profileId( 0 );
    		User::LeaveIfError(
    		        profile->GetParameter( KSIPProfileId, profileId ) );
    		idName.AppendNum( (TInt)profileId );
    		// ..and add it to the ProfileIdList array
    		array->AppendL( idName );
    		}

    	AddArrayResponseL( KParamProfileProfileIdist, *array );
    	
    	CleanupStack::PopAndDestroy(); // array
	    }
	CleanupStack::PopAndDestroy(); // profileArray
	}
Exemple #19
0
// -----------------------------------------------------------------------------
// MceSip::UserHeadersToTextArrayL
// -----------------------------------------------------------------------------
//
CDesC8Array* MceSip::UserHeadersToTextArrayL( 
                                    CSIPTransactionBase& aTransaction,
                                    const CSIPDialog& aDialog )
    {
	CDesC8ArrayFlat* headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
	CleanupStack::PushL( headers );

	HBufC8* head = NULL;
    const CSIPHeaderBase* callid = NULL;
    const CSIPHeaderBase* cseq = NULL;
    const CSIPFromHeader* from = NULL;
    const CSIPToHeader* to = NULL;
    const CSIPMessageElements* elements = ToMessageElements( aTransaction );

    if ( aTransaction.IsSIPClientTransaction() )
        {
        const CSIPResponseElements* responseElements =
            static_cast<CSIPClientTransaction&>( aTransaction ).
                ResponseElements();
        cseq = responseElements ? responseElements->CSeqHeader() : NULL;

        from = responseElements ? responseElements->FromHeader() : NULL;
        to = responseElements ? responseElements->ToHeader() : NULL;

        }
    else
        {
        
        const CSIPRequestElements* requestElements =
            static_cast<CSIPServerTransaction&>( aTransaction ).
                RequestElements();
        from = requestElements ? requestElements->FromHeader() : NULL;
        to = requestElements ? requestElements->ToHeader() : NULL;
        
        }

    from = !from ? &aDialog.FromHeader() : from;
    to = !to ? &aDialog.ToHeader() : to;
    
    head = from->ToTextLC();
	headers->AppendL( *head );
	CleanupStack::PopAndDestroy( head );
    head = to->ToTextLC();
	headers->AppendL( *head );
	CleanupStack::PopAndDestroy( head );

    if ( cseq )
        {
	    head = cseq->ToTextLC();
		headers->AppendL( *head );
		CleanupStack::PopAndDestroy( head );
        }

    TRAPD( error, callid = &aDialog.CallIdL() );
    if ( error == KErrNone )
        {
        head = callid->ToTextLC();
    	headers->AppendL( *head );
    	CleanupStack::PopAndDestroy( head );
        }
        

	if ( elements )
		{
		const RPointerArray<CSIPHeaderBase>& sipHeaders = 
		    elements->UserHeaders();
		
		for ( TInt i=0; i < sipHeaders.Count(); i++ )
			{
			CSIPHeaderBase* anotherhead = sipHeaders[ i ];
			head = anotherhead->ToTextLC();
			headers->AppendL( *head );
			CleanupStack::PopAndDestroy( head );
		    }
        
            
		}
		
	CleanupStack::Pop( headers );
	return headers;
	
    }
// -----------------------------------------------------------------------------
// CSTSUserAuth::DecodeL
// Decrypts raw data to this instance
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSTSUserAuth::DecodeL(const TDesC8& aRawData)
{
    CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC(ETrue, // must be sequence
                                            aRawData, KSTSMinNumberOfSubModules);

    // we would not get this far if there was atleast two element
    TInt pos = 0;
    // decoding authentication id (octet string)
    TASN1DecOctetString authId;
    HBufC8* tmp = authId.DecodeDERL(*itemsData->At(pos++));
    delete iAuthId;
    iAuthId = tmp;

    // decoding user authentication method (choice)
    // we need: apduPinEntry [0]APDUPinEntry
    TASN1DecGeneric taggedEntryDec(*itemsData->At(pos++));
    taggedEntryDec.InitL();
    if (taggedEntryDec.Tag() == KSTSAPDUPinEntryTag)
    {
        // set information that apduHeaders used
        iType = EAPDUPinEntry;
        // decoding apduPinEntry
        TASN1DecGeneric decGen(taggedEntryDec.GetContentDER());
        TRAPD(err, decGen.InitL());
        // it there is some optional headers inside APDUPINEntry
        if (!err)
        {
            CleanupStack::PopAndDestroy(itemsData);
            itemsData = DecodeSequenceLC(EFalse, taggedEntryDec.Encoding());
            TInt numOfHeaders = itemsData->Count();

            if (numOfHeaders)
            {
                CDesC8ArrayFlat* tmpArray =
                    new(ELeave) CDesC8ArrayFlat(numOfHeaders);
                CleanupStack::PushL(tmpArray);

                TUint currentTag = 0;
                TInt itemsLeft = numOfHeaders;
                // decode all pinheaders(octet string) in loop
                for (TInt i = 0; i < numOfHeaders; i++)
                {
                    TBool ready = EFalse;
                    TASN1DecGeneric decGenApduHeader(*itemsData->At(i));
                    // we must check tags in order 0 to ...
                    while (!ready && (currentTag <= (TUint)(itemsLeft
                                                            + currentTag)))
                    {
                        // add found header to correct place in buffer
                        if (decGenApduHeader.Tag() == currentTag)
                        {
                            TASN1DecGeneric decGenApduHeaderDER(
                                itemsData->At(i)->Encoding());
                            decGenApduHeaderDER.InitL();
                            TASN1DecOctetString apduHeader;
                            HBufC8* headerBuf = apduHeader.DecodeDERL(
                                                    decGenApduHeaderDER);
                            CleanupStack::PushL(headerBuf);

                            tmpArray->AppendL(headerBuf->Des());
                            CleanupStack::PopAndDestroy(headerBuf);
                            ready = ETrue;
                            itemsLeft--;
                        }
                        // there was no header for this tag, so add empty
                        else
                        {
                            tmpArray->AppendL(KNullDesC8());
                        }
                        currentTag++;
                    }
                }
                delete iApduPinHeaders;
                iApduPinHeaders = tmpArray;
                // compress to get rid of possible unneccessary slots
                iApduPinHeaders->Compress();
                CleanupStack::Pop(tmpArray);
            }
        }
    }
    else
    {
        iType = EOther;
        // we won't need others at all
    }
    CleanupStack::PopAndDestroy(itemsData);
}