multimediacommsengine/mmcesrv/mmceserver/src/mcesip.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <e32math.h>
       
    22 #include <siperr.h>
       
    23 #include <sdpcodecerr.h>
       
    24 #include <sdpdocument.h>
       
    25 #include <siptoheader.h>
       
    26 #include <sipdialog.h>
       
    27 #include <sipcallidheader.h>
       
    28 #include <sipcseqheader.h>
       
    29 #include <sipretryafterheader.h>
       
    30 #include <sipcontactheader.h>
       
    31 #include <sipsupportedheader.h>
       
    32 #include <siprequireheader.h>
       
    33 #include <sipallowheader.h>
       
    34 #include <sipprofile.h>
       
    35 #include <siprseqheader.h>
       
    36 #include <siprackheader.h>
       
    37 #include "mcesip.h"
       
    38 #include "mcedefs.h"
       
    39 
       
    40 
       
    41 const CSIPTransactionBase::TState KMceTrxStateUndefined = 
       
    42     static_cast<CSIPTransactionBase::TState>(-1);
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // MceSip::ResponseCode
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 TUint MceSip::ResponseCode( CSIPClientTransaction& aResponse )
       
    49     {
       
    50     return aResponse.ResponseElements()->StatusCode();
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // MceSip::ResponseType
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 TMceSipResponseType MceSip::ResponseType( CSIPClientTransaction& aResponse )
       
    58     {
       
    59     
       
    60     TUint responseCode = ResponseCode( aResponse );
       
    61     
       
    62     return ResponseType( responseCode );
       
    63     }
       
    64     
       
    65 // -----------------------------------------------------------------------------
       
    66 // MceSip::ResponseType
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 TMceSipResponseType MceSip::ResponseType( TUint aCode )
       
    70     {
       
    71     if ( aCode < KMceSipOK )//200
       
    72         {
       
    73         return E1XX;
       
    74         }
       
    75     else if ( aCode < KMceSipMultipleChoices )//300
       
    76         {
       
    77         return E2XX;
       
    78         }
       
    79     else if ( aCode < KMceSipBadRequest )//400
       
    80         {
       
    81         return E3XX;
       
    82         }
       
    83     else if ( aCode < KMceSipServerInternalError )//500
       
    84         {
       
    85         return E4XX;
       
    86         }
       
    87     else if ( aCode < KMceSipBusyEverywhere )//600
       
    88         {
       
    89         return E5XX;
       
    90         }
       
    91     else 
       
    92         {
       
    93         return E6XX;
       
    94         }   
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // MceSip::ReasonPhraseL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 RStringF MceSip::ReasonPhraseL( TUint aStatusCode )
       
   102     {
       
   103     RStringF phrase;
       
   104     
       
   105     switch( aStatusCode )
       
   106         {
       
   107         case KMceSipOK:
       
   108             {
       
   109             phrase = SIPStrings::StringF( SipStrConsts::EPhraseOk );
       
   110             break;
       
   111             }
       
   112         case KMceSipBadRequest:
       
   113             {
       
   114             phrase = SIPStrings::StringF( SipStrConsts::EPhraseBadRequest );
       
   115             break;
       
   116             }
       
   117         case KMceSipUnauthorized:
       
   118             {
       
   119             phrase = SIPStrings::StringF( SipStrConsts::EPhraseUnauthorized );
       
   120             break;
       
   121             }
       
   122         case KMceSipForbidden:
       
   123             {
       
   124             phrase = SIPStrings::StringF( SipStrConsts::EPhraseForbidden );
       
   125             break;
       
   126             }
       
   127         case KMceSipNotFound:
       
   128             {
       
   129             phrase = SIPStrings::StringF( SipStrConsts::EPhraseNotFound );
       
   130             break;
       
   131             }
       
   132         case KMceSipMethodNotAllowed:
       
   133             {
       
   134             phrase = SIPStrings::StringF( SipStrConsts::EPhraseMethodNotAllowed );
       
   135             break;
       
   136             }
       
   137         case KMceSip4XXNotAcceptable:
       
   138             {
       
   139             phrase = SIPStrings::StringF( SipStrConsts::EPhraseNotAcceptableHere );
       
   140             break;
       
   141             }
       
   142         case KMceSipProxyAuthenticationRequired:
       
   143             {
       
   144             phrase = SIPStrings::StringF( SipStrConsts::EPhraseProxyAuthenticationRequired );
       
   145             break;
       
   146             }
       
   147         case KMceSipRequestTimeout:
       
   148             {
       
   149             phrase = SIPStrings::StringF( SipStrConsts::EPhraseRequestTimeout );
       
   150             break;
       
   151             }
       
   152         case KMceSipUnsupportedMediaType:
       
   153             {
       
   154             phrase = SIPStrings::StringF( SipStrConsts::EPhraseUnsupportedMediaType );
       
   155             break;
       
   156             }
       
   157         case KMceSipUnsupportedURIScheme:
       
   158             {
       
   159             phrase = SIPStrings::StringF( SipStrConsts::EPhraseUnsupportedURIScheme );
       
   160             break;
       
   161             }
       
   162         case KMceSipBadExtension:
       
   163             {
       
   164             phrase = SIPStrings::StringF( SipStrConsts::EPhraseBadExtension );
       
   165             break;
       
   166             }
       
   167         case KMceSipExtensionRequired:
       
   168             {
       
   169             phrase = SIPStrings::StringF( SipStrConsts::EPhraseExtensionRequired );
       
   170             break;
       
   171             }
       
   172         case KMceSipSessionIntervalTooSmall:
       
   173         case KMceSipIntervalTooBrief:
       
   174             {
       
   175             phrase = SIPStrings::StringF( SipStrConsts::EPhraseIntervalTooBrief );
       
   176             break;
       
   177             }
       
   178         case KMceSipTemporarilyUnavailable:
       
   179             {
       
   180             phrase = SIPStrings::StringF( SipStrConsts::EPhraseTemporarilyNotAvailable );
       
   181             break;
       
   182             }
       
   183         case KMceSipCallOrTransactionDoesNotExist:
       
   184             {
       
   185             phrase = SIPStrings::StringF( SipStrConsts::EPhraseCallTransactionDoesNotExist );
       
   186             break;
       
   187             }
       
   188         case KMceSipLoopDetected:
       
   189             {
       
   190             phrase = SIPStrings::StringF( SipStrConsts::EPhraseLoopDetected );
       
   191             break;
       
   192             }
       
   193         case KMceSipTooManyHops:
       
   194             {
       
   195             phrase = SIPStrings::StringF( SipStrConsts::EPhraseTooManyHops );
       
   196             break;
       
   197             }
       
   198         case KMceSipBusyHere:
       
   199             {
       
   200             phrase = SIPStrings::StringF( SipStrConsts::EPhraseBusyHere );
       
   201             break;
       
   202             }
       
   203         case KMceSipRequestTerminated:
       
   204             {
       
   205             phrase = SIPStrings::StringF( SipStrConsts::EPhraseRequestTerminated );
       
   206             break;
       
   207             }
       
   208         case KMceSipNotAcceptableHere:
       
   209             {
       
   210             phrase = SIPStrings::StringF( SipStrConsts::EPhraseNotAcceptableHere );
       
   211             break;
       
   212             }
       
   213         case KMceSipBadEvent:
       
   214             {
       
   215             phrase = SIPStrings::StringF( SipStrConsts::EPhraseBadEvent );
       
   216             break;
       
   217             }
       
   218         case KMceSipRequestPending:
       
   219             {
       
   220             phrase = SIPStrings::Pool().OpenFStringL( KMceSipPhraseRequestPending() );
       
   221             break;
       
   222             }
       
   223         case KMceSipServerInternalError:
       
   224             {
       
   225             phrase = SIPStrings::StringF( SipStrConsts::EPhraseServerInternalError );
       
   226             break;
       
   227             }
       
   228         case KMceSipNotImplemented:
       
   229             {
       
   230             phrase = SIPStrings::StringF( SipStrConsts::EPhraseNotImplemented );
       
   231             break;
       
   232             }        
       
   233         case KMceSipServiceUnavailable:
       
   234             {
       
   235             phrase = SIPStrings::StringF( SipStrConsts::EPhraseServiceUnavailable );
       
   236             break;
       
   237             }
       
   238         case KMceSipVersionNotSupported:
       
   239             {
       
   240             phrase = SIPStrings::StringF( SipStrConsts::EPhraseVersionNotSupported );
       
   241             break;
       
   242             }
       
   243         case KMceSipDecline:
       
   244             {
       
   245             phrase = SIPStrings::StringF( SipStrConsts::EPhraseDecline );
       
   246             break;
       
   247             }
       
   248         case  KMceSipServerTimeOut:
       
   249             {
       
   250             phrase = SIPStrings::StringF( SipStrConsts::EPhraseRequestTimeout );
       
   251             break;
       
   252             }
       
   253 
       
   254         default:
       
   255             {
       
   256             phrase = SIPStrings::StringF( SipStrConsts::EEmpty );
       
   257             break;
       
   258             }
       
   259         }
       
   260         
       
   261     return phrase;
       
   262     
       
   263     }
       
   264 
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // MceSip::IsResponseTo
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 TBool MceSip::IsResponseTo( CSIPClientTransaction& aResponse, RStringF aMethod )
       
   271     {
       
   272     return &aResponse != NULL && aResponse.Type() == aMethod;
       
   273     }
       
   274     
       
   275     
       
   276 // -----------------------------------------------------------------------------
       
   277 // MceSip::TrxCompleted
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 TBool MceSip::TrxCompleted( CSIPTransactionBase& aTransaction )
       
   281     {
       
   282     // Invite transaction which is in confirmed state can be removed as well,
       
   283     // as it means that error response has been already sent and SIP is 
       
   284     // just waiting for acks for certain time (T4).
       
   285     CSIPTransactionBase::TState trxState = TrxState( aTransaction );
       
   286     return trxState == KMceTrxStateUndefined ||
       
   287            trxState == CSIPTransactionBase::ECompleted || 
       
   288            trxState == CSIPTransactionBase::ETerminated ||
       
   289            TrxType( aTransaction ) == SipStrConsts::EAck ||
       
   290            ( TrxType( aTransaction ) == SipStrConsts::EInvite &&
       
   291              trxState == CSIPTransactionBase::EConfirmed );
       
   292     }
       
   293     
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 // MceSip::TrxState
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 CSIPTransactionBase::TState MceSip::TrxState( 
       
   300                                     CSIPTransactionBase& aTransaction )
       
   301     {
       
   302     CSIPTransactionBase::TState trxState = KMceTrxStateUndefined;
       
   303     TRAP_IGNORE( ( trxState = aTransaction.StateL() ) );
       
   304     return trxState;
       
   305            
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // MceSip::TrxType
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 TInt MceSip::TrxType( CSIPTransactionBase& aTransaction )
       
   313     {
       
   314     return aTransaction.Type().Index( SIPStrings::Table() );
       
   315     }
       
   316     
       
   317     
       
   318     
       
   319             
       
   320 // -----------------------------------------------------------------------------
       
   321 // MceSip::WarningPhraseL
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 RStringF MceSip::WarningPhraseL( TUint aWarnCode )
       
   325     {
       
   326     
       
   327     RStringF warningPhrase;
       
   328 
       
   329     
       
   330     switch( aWarnCode )
       
   331         {
       
   332         case KMceSipWarnIncompatibleNetworkProtocol:
       
   333             {
       
   334             warningPhrase = 
       
   335                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase300() );
       
   336             break;
       
   337             }
       
   338         case KMceSipWarnIncompatibleNetworkAddressFormat:
       
   339             {
       
   340             warningPhrase = 
       
   341                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase301() );
       
   342             break;
       
   343             }
       
   344         case KMceSipWarnIncompatibleTransportProtocol:
       
   345             {
       
   346             warningPhrase = 
       
   347                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase302() );
       
   348             break;
       
   349             }
       
   350         case KMceSipWarnIncompatibleBandwidthUnits:
       
   351             {
       
   352             warningPhrase =
       
   353                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase303() );
       
   354             break;
       
   355             }
       
   356         case KMceSipWarnMediaTypeNotAvailable:
       
   357             {
       
   358             warningPhrase = 
       
   359                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase304() );
       
   360             break;
       
   361             }
       
   362         case KMceSipWarnIncompatibleMediaFormat:
       
   363             {
       
   364             warningPhrase = 
       
   365                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase305() );
       
   366             break;
       
   367             }
       
   368         case KMceSipWarnAttributeNotUnderstood:
       
   369             {
       
   370             warningPhrase = 
       
   371                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase306() );
       
   372             break;
       
   373             }
       
   374         case KMceSipWarnSessionDescriptionParameterNotUnderstood:
       
   375             {
       
   376             warningPhrase = 
       
   377                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase307() );
       
   378             break;
       
   379             }
       
   380         case KMceSipWarnMulticastNotAvailable:
       
   381             {
       
   382             warningPhrase = 
       
   383                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase330() );
       
   384             break;
       
   385             }
       
   386         case KMceSipWarnUnicastNotAvailable:
       
   387             {
       
   388             warningPhrase = 
       
   389                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase331() );
       
   390             break;
       
   391             }
       
   392         case KMceSipWarnInsufficientBandwidth:
       
   393             {
       
   394             warningPhrase = 
       
   395                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase370() );
       
   396             break;
       
   397             }
       
   398         case KMceSipWarnMiscellaneous:
       
   399             {
       
   400             warningPhrase = 
       
   401                 SIPStrings::Pool().OpenFStringL( KMceSipWarnPhrase399() );
       
   402             break;
       
   403             }
       
   404         default:
       
   405             {
       
   406             warningPhrase = SIPStrings::StringF( SipStrConsts::EEmpty );
       
   407             break;
       
   408             }
       
   409         }
       
   410     return warningPhrase;
       
   411     }
       
   412 
       
   413 
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // MceSip::IsSIPStackError
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 TBool MceSip::IsSIPStackError( TInt aError )
       
   420     {
       
   421     return IsSDPError( aError ) ||
       
   422         ( aError >= KErrSIPInvalidURIType 
       
   423         && aError <= KErrSIPMalformedMessage );
       
   424     
       
   425     }
       
   426 
       
   427 // -----------------------------------------------------------------------------
       
   428 // MceSip::IsSDPError
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 TBool MceSip::IsSDPError( TInt aError )
       
   432     {
       
   433     return aError >= KErrSdpCodecDecode && aError <= KErrSdpCodecVersionField;
       
   434     
       
   435     }
       
   436 
       
   437 // -----------------------------------------------------------------------------
       
   438 // MceSip::ErrorResponse
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 void MceSip::ErrorResponse( TInt aError, 
       
   442                             TUint& aSIPResponseCode, 
       
   443                             TInt& aReasonPhrase )
       
   444     {
       
   445     
       
   446     if ( IsSDPError( aError ) )
       
   447         {
       
   448         aSIPResponseCode = KMceSipBadRequest;
       
   449         aReasonPhrase = SipStrConsts::EPhraseBadRequest;
       
   450         }
       
   451     else 
       
   452         {
       
   453         aSIPResponseCode = KMceSipServerInternalError;
       
   454         aReasonPhrase = SipStrConsts::EPhraseServerInternalError;
       
   455         }
       
   456     
       
   457     }
       
   458     
       
   459 
       
   460 // -----------------------------------------------------------------------------
       
   461 // MceSip::DiscardRequest
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 TInt MceSip::DiscardRequest( CSIPServerTransaction& aRequest, TInt aError,
       
   465                              TBool aRetryIndication  )
       
   466     {
       
   467     TInt status = KErrNone;
       
   468     TRAP( status, DoDiscardRequestL( aRequest, aError, aRetryIndication ) );
       
   469     return status;
       
   470     }
       
   471 
       
   472 // -----------------------------------------------------------------------------
       
   473 // MceSip::DiscardRequest
       
   474 // -----------------------------------------------------------------------------
       
   475 //
       
   476 TInt MceSip::DiscardRequest( CSIPServerTransaction* aRequest, TInt aError,
       
   477                              TBool aRetryIndication  )
       
   478     {
       
   479     TInt status = DiscardRequest( *aRequest, aError, aRetryIndication );
       
   480     delete aRequest;
       
   481     
       
   482     return status;
       
   483         
       
   484     }
       
   485 
       
   486     
       
   487 // -----------------------------------------------------------------------------
       
   488 // MceSip::Method
       
   489 // -----------------------------------------------------------------------------
       
   490 //
       
   491 RStringF MceSip::Method( CSIPServerTransaction& aRequest )
       
   492     {
       
   493     const CSIPRequestElements* request = aRequest.RequestElements();
       
   494     if ( request )
       
   495         {
       
   496         return request->Method();
       
   497         }
       
   498     else
       
   499         {
       
   500         return SIPStrings::StringF( SipStrConsts::EEmpty );
       
   501         }
       
   502         
       
   503     }
       
   504     
       
   505 // -----------------------------------------------------------------------------
       
   506 // MceSip::AddressToTextL
       
   507 // -----------------------------------------------------------------------------
       
   508 //
       
   509 HBufC8* MceSip::AddressToTextL( const CSIPAddress& aToAddr )
       
   510     {
       
   511     HBufC8* address = aToAddr.ToTextLC();
       
   512     CleanupStack::Pop( address );
       
   513     return address;
       
   514     }
       
   515 
       
   516 // -----------------------------------------------------------------------------
       
   517 // MceSip::ToFromHeaderL
       
   518 // -----------------------------------------------------------------------------
       
   519 //
       
   520 CSIPFromHeader* MceSip::ToFromHeaderL( const TDesC8& aAddress )
       
   521     {
       
   522 	
       
   523 	CSIPAddress* sipAddressFrom = CSIPAddress::DecodeL( aAddress );    
       
   524 	CleanupStack::PushL( sipAddressFrom );
       
   525 	CSIPFromHeader* fromHeader = CSIPFromHeader::NewL( sipAddressFrom );
       
   526     CleanupStack::Pop( sipAddressFrom );
       
   527     return fromHeader;
       
   528     
       
   529     }
       
   530 
       
   531 
       
   532 // -----------------------------------------------------------------------------
       
   533 // MceSip::ToContentTypeHeaderL
       
   534 // -----------------------------------------------------------------------------
       
   535 //
       
   536 CSIPContentTypeHeader* 
       
   537     MceSip::ToContentTypeHeaderL( TMceContentType aContentType, 
       
   538                                   const HBufC8* aUserDefinedContentType )
       
   539     {
       
   540     
       
   541     CSIPContentTypeHeader* contentTypeHeader = NULL;
       
   542     
       
   543     if ( aUserDefinedContentType )
       
   544         {
       
   545         contentTypeHeader = 
       
   546                 CSIPContentTypeHeader::DecodeL( *aUserDefinedContentType );
       
   547                 
       
   548         }
       
   549     else if ( aContentType == EMceContentTypeSDP )
       
   550         {
       
   551         contentTypeHeader =
       
   552             CSIPContentTypeHeader::NewL( KMceSipMediaTypeApplication,
       
   553                                          KMceSipMediaSubTypeSDP );
       
   554     
       
   555         }
       
   556     else if ( aContentType == EMceContentTypeMultiPart )
       
   557         {
       
   558     	contentTypeHeader = 
       
   559     	    CSIPContentTypeHeader::NewLC( KMceSipMPartMediaTypeMultipart, 
       
   560     	                                  KMceSipMPartMediaSubTypeMixed );
       
   561 
       
   562     	RStringF paramKey = SIPStrings::Pool().OpenFStringL( KMceSipMPartBoundary );
       
   563     	CleanupClosePushL( paramKey );
       
   564     	RStringF paramValue = SIPStrings::Pool().OpenFStringL( KMceSipMPartMessageBoundary );
       
   565     	CleanupClosePushL( paramValue );
       
   566 
       
   567     	contentTypeHeader->SetParamL( paramKey, paramValue );
       
   568     	CleanupStack::PopAndDestroy(); // paramValue
       
   569     	CleanupStack::PopAndDestroy(); // paramKey
       
   570         CleanupStack::Pop( contentTypeHeader );
       
   571         
       
   572         }
       
   573     else
       
   574         {
       
   575         //NOP
       
   576         }
       
   577     
       
   578     return contentTypeHeader;
       
   579     
       
   580     }
       
   581 
       
   582     
       
   583 // -----------------------------------------------------------------------------
       
   584 // MceSip::ToSIPExtensionHeadersL
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void MceSip::ToSIPExtensionHeadersL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, 
       
   588                                      const MDesC8Array& aHeaders )
       
   589     {
       
   590     
       
   591 	for ( int i = 0; i < aHeaders.MdcaCount(); i++ )
       
   592 		{
       
   593 		TPtrC8 param = aHeaders.MdcaPoint( i );
       
   594 		TInt index = param.Locate( KMceSipSeparator );
       
   595 		if ( index != KErrNotFound && 
       
   596 					param.Left( index ) != KMceSipSubscriptionStateHeader )
       
   597 			{
       
   598     		CSIPExtensionHeader* extHeader = CSIPExtensionHeader::NewL( 
       
   599     		                param.Left(index), 
       
   600     			            param.Right( param.Length() - ( index + 1 ) ) );
       
   601     		CleanupStack::PushL( extHeader );
       
   602     		User::LeaveIfError( aSIPHeaders.Append( extHeader ) );
       
   603     		CleanupStack::Pop( extHeader );
       
   604 			}
       
   605 		}
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // MceSip::UserHeadersToTextArrayL
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 CDesC8Array* MceSip::UserHeadersToTextArrayL( 
       
   613                                     CSIPTransactionBase& aTransaction,
       
   614                                     const CSIPDialog& aDialog )
       
   615     {
       
   616 	CDesC8ArrayFlat* headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   617 	CleanupStack::PushL( headers );
       
   618 
       
   619 	HBufC8* head = NULL;
       
   620     const CSIPHeaderBase* callid = NULL;
       
   621     const CSIPHeaderBase* cseq = NULL;
       
   622     const CSIPFromHeader* from = NULL;
       
   623     const CSIPToHeader* to = NULL;
       
   624     const CSIPMessageElements* elements = ToMessageElements( aTransaction );
       
   625 
       
   626     if ( aTransaction.IsSIPClientTransaction() )
       
   627         {
       
   628         const CSIPResponseElements* responseElements =
       
   629             static_cast<CSIPClientTransaction&>( aTransaction ).
       
   630                 ResponseElements();
       
   631         cseq = responseElements ? responseElements->CSeqHeader() : NULL;
       
   632 
       
   633         from = responseElements ? responseElements->FromHeader() : NULL;
       
   634         to = responseElements ? responseElements->ToHeader() : NULL;
       
   635 
       
   636         }
       
   637     else
       
   638         {
       
   639         
       
   640         const CSIPRequestElements* requestElements =
       
   641             static_cast<CSIPServerTransaction&>( aTransaction ).
       
   642                 RequestElements();
       
   643         from = requestElements ? requestElements->FromHeader() : NULL;
       
   644         to = requestElements ? requestElements->ToHeader() : NULL;
       
   645         
       
   646         }
       
   647 
       
   648     from = !from ? &aDialog.FromHeader() : from;
       
   649     to = !to ? &aDialog.ToHeader() : to;
       
   650     
       
   651     head = from->ToTextLC();
       
   652 	headers->AppendL( *head );
       
   653 	CleanupStack::PopAndDestroy( head );
       
   654     head = to->ToTextLC();
       
   655 	headers->AppendL( *head );
       
   656 	CleanupStack::PopAndDestroy( head );
       
   657 
       
   658     if ( cseq )
       
   659         {
       
   660 	    head = cseq->ToTextLC();
       
   661 		headers->AppendL( *head );
       
   662 		CleanupStack::PopAndDestroy( head );
       
   663         }
       
   664 
       
   665     TRAPD( error, callid = &aDialog.CallIdL() );
       
   666     if ( error == KErrNone )
       
   667         {
       
   668         head = callid->ToTextLC();
       
   669     	headers->AppendL( *head );
       
   670     	CleanupStack::PopAndDestroy( head );
       
   671         }
       
   672         
       
   673 
       
   674 	if ( elements )
       
   675 		{
       
   676 		const RPointerArray<CSIPHeaderBase>& sipHeaders = 
       
   677 		    elements->UserHeaders();
       
   678 		
       
   679 		for ( TInt i=0; i < sipHeaders.Count(); i++ )
       
   680 			{
       
   681 			CSIPHeaderBase* anotherhead = sipHeaders[ i ];
       
   682 			head = anotherhead->ToTextLC();
       
   683 			headers->AppendL( *head );
       
   684 			CleanupStack::PopAndDestroy( head );
       
   685 		    }
       
   686         
       
   687             
       
   688 		}
       
   689 		
       
   690 	CleanupStack::Pop( headers );
       
   691 	return headers;
       
   692 	
       
   693     }
       
   694     
       
   695 // -----------------------------------------------------------------------------
       
   696 // MceSip::ToContactHeaderL
       
   697 // -----------------------------------------------------------------------------
       
   698 //
       
   699 CSIPContactHeader* MceSip::ToContactHeaderL( const TDesC8& aContact )
       
   700     {
       
   701     CSIPContactHeader* contact = NULL;
       
   702     
       
   703     RPointerArray< CSIPContactHeader > contacts = CSIPContactHeader::DecodeL( aContact );
       
   704     if ( contacts.Count() > 0 )
       
   705         {
       
   706         contact = contacts[0]; 
       
   707         contacts.Remove(0);
       
   708         contacts.ResetAndDestroy();
       
   709         }
       
   710     else
       
   711         {
       
   712         contacts.Close();
       
   713         User::Leave( KErrNotFound );
       
   714         }
       
   715         
       
   716     return contact;
       
   717     
       
   718     }
       
   719 
       
   720 
       
   721 // -----------------------------------------------------------------------------
       
   722 // MceSip::HasSipsUriInContact
       
   723 // -----------------------------------------------------------------------------
       
   724 //
       
   725 TBool MceSip::HasSipsUriInContactL( const CSIPMessageElements& aMessage )
       
   726 	{
       
   727 	TBool hasSipsUri = EFalse;
       
   728 	CSIPHeaderBase* contact = FindHeader( aMessage, SIPStrings::StringF( 
       
   729 											SipStrConsts::EContactHeader ) );
       
   730                                     
       
   731     if ( !contact )
       
   732     	{
       
   733     	contact = FindHeader( aMessage, SIPStrings::StringF( 
       
   734 											SipStrConsts::EContactHeaderCompact ) );
       
   735     	}
       
   736     
       
   737     if ( contact )
       
   738     	{
       
   739 		const TDesC8& uriScheme = static_cast< CSIPContactHeader* >( contact )->
       
   740 									SIPAddress()->Uri8().Uri().Extract( EUriScheme );
       
   741 		if ( uriScheme.FindF( KMceSipUriSchemeSIPs ) != KErrNotFound )
       
   742 			{
       
   743 			hasSipsUri = ETrue;
       
   744 			}
       
   745 		}
       
   746 
       
   747 	return hasSipsUri;		
       
   748 	}
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 // MceSip::HasTlsInContact
       
   752 // -----------------------------------------------------------------------------
       
   753 //
       
   754 TBool MceSip::HasTlsInContactL( const CSIPMessageElements& aMessage )
       
   755 	{
       
   756 	TBool hasTls = EFalse;
       
   757 	CSIPHeaderBase* contact = FindHeader( aMessage, SIPStrings::StringF( 
       
   758 											SipStrConsts::EContactHeader ) );
       
   759                                     
       
   760     if ( !contact )
       
   761     	{
       
   762     	contact = FindHeader( aMessage, SIPStrings::StringF( 
       
   763 											SipStrConsts::EContactHeaderCompact ) );
       
   764     	}
       
   765     
       
   766     if ( contact )
       
   767     	{
       
   768 	
       
   769 		const TDesC8& uriPath = static_cast< CSIPContactHeader* >( contact )->SIPAddress()->Uri8().Uri().Extract( EUriPath );
       
   770 		if ( uriPath.FindF( KMceSipTransportTLS ) != KErrNotFound )
       
   771 			{
       
   772 			hasTls = ETrue;
       
   773 			}
       
   774 		}
       
   775 		
       
   776 	return hasTls;
       
   777 	}
       
   778 // -----------------------------------------------------------------------------
       
   779 // MceSip::AddSupportedHeaderL
       
   780 // -----------------------------------------------------------------------------
       
   781 //    
       
   782 void MceSip::AddSupportedHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders,
       
   783                                   const TDesC8& aExtension )
       
   784     {
       
   785     RStringF tag = SIPStrings::Pool().OpenFStringL( aExtension );
       
   786     CleanupClosePushL( tag );
       
   787     CSIPSupportedHeader* header = CSIPSupportedHeader::NewL( tag );
       
   788     CleanupStack::PopAndDestroy(); // tag
       
   789     CleanupStack::PushL( header );
       
   790     aSIPHeaders.AppendL( header );
       
   791     CleanupStack::Pop( header );
       
   792     }
       
   793 
       
   794 // -----------------------------------------------------------------------------
       
   795 // MceSip::AddRequireHeaderL
       
   796 // -----------------------------------------------------------------------------
       
   797 //    
       
   798 void MceSip::AddRequireHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders,
       
   799                                 const TDesC8& aExtension )
       
   800     {
       
   801     RStringF tag = SIPStrings::Pool().OpenFStringL( aExtension );
       
   802     CleanupClosePushL( tag );
       
   803     CSIPRequireHeader* header = CSIPRequireHeader::NewL( tag );
       
   804     CleanupStack::PopAndDestroy(); // tag
       
   805     CleanupStack::PushL( header );
       
   806     aSIPHeaders.AppendL( header );
       
   807     CleanupStack::Pop( header );
       
   808     }
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // MceSip::AddAllowHeaderL
       
   812 // -----------------------------------------------------------------------------
       
   813 //     
       
   814 void MceSip::AddAllowHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders,
       
   815                               TInt aMethod )
       
   816     {
       
   817     RStringF method = SIPStrings::StringF( aMethod );
       
   818     CSIPAllowHeader* header = CSIPAllowHeader::NewL( method );
       
   819     CleanupStack::PushL( header );
       
   820     aSIPHeaders.AppendL( header );
       
   821     CleanupStack::Pop( header );
       
   822     }
       
   823 
       
   824 // -----------------------------------------------------------------------------
       
   825 // MceSip::AddRAckHeaderL
       
   826 // -----------------------------------------------------------------------------
       
   827 //     
       
   828 void MceSip::AddRAckHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders,
       
   829                              const CSIPResponseElements& aResponse )
       
   830     {
       
   831     TInt rseq = RSeq( aResponse );
       
   832      
       
   833     if (rseq == KErrNotFound )
       
   834         {
       
   835            User::Leave( KErrArgument );
       
   836         }
       
   837        
       
   838     const CSIPCSeqHeader* cseqHeader = aResponse.CSeqHeader();
       
   839     __ASSERT_ALWAYS( MCE_NOT_NULL_PTR( cseqHeader ), User::Leave( KErrArgument ) );
       
   840      
       
   841     CSIPRAckHeader* header = CSIPRAckHeader::NewL( rseq, 
       
   842                                                    cseqHeader->Seq(),
       
   843                                                    cseqHeader->Method() );
       
   844     CleanupStack::PushL( header );
       
   845     aSIPHeaders.AppendL( header );
       
   846     CleanupStack::Pop( header );
       
   847     }
       
   848     
       
   849     
       
   850 // -----------------------------------------------------------------------------
       
   851 // MceSip::ToMessageElements
       
   852 // -----------------------------------------------------------------------------
       
   853 //
       
   854 const CSIPMessageElements* MceSip::ToMessageElements( 
       
   855     CSIPTransactionBase& aTransaction )
       
   856     {
       
   857     
       
   858     const CSIPMessageElements* elements = NULL;
       
   859                     
       
   860     if ( aTransaction.IsSIPClientTransaction() )
       
   861         {
       
   862         CSIPClientTransaction& trx = 
       
   863             static_cast<CSIPClientTransaction&>( aTransaction );
       
   864         const CSIPResponseElements* resElements = trx.ResponseElements();
       
   865 
       
   866         elements = resElements ? &resElements->MessageElements() : NULL;
       
   867 
       
   868         }
       
   869     else
       
   870         {
       
   871         CSIPServerTransaction& trx = 
       
   872             static_cast<CSIPServerTransaction&>( aTransaction );
       
   873         const CSIPRequestElements* reqElements = trx.RequestElements();
       
   874         
       
   875         elements = reqElements ? &reqElements->MessageElements() : NULL;
       
   876         }
       
   877 
       
   878     return elements;
       
   879     
       
   880     }
       
   881 
       
   882 // -----------------------------------------------------------------------------
       
   883 // MceSip::HasContent
       
   884 // -----------------------------------------------------------------------------
       
   885 //
       
   886 TBool MceSip::HasContent( CSIPTransactionBase& aTransaction )
       
   887     {
       
   888     const CSIPMessageElements* elements = ToMessageElements( aTransaction );
       
   889     if (elements)
       
   890     	return elements->Content().Length() > 0;
       
   891     else return EFalse;
       
   892     }
       
   893 /*    
       
   894 TBool MceSip::HasContent( CSIPTransactionBase& aTransaction )
       
   895     {
       
   896     TBool hasContent = EFalse;
       
   897     const CSIPMessageElements* elements = ToMessageElements( aTransaction );
       
   898     if ( elements && elements->Content().Length() > 0 )
       
   899         {
       
   900         hasContent = ETrue;
       
   901         }
       
   902     return hasContent;
       
   903     }*/
       
   904     
       
   905 // -----------------------------------------------------------------------------
       
   906 // MceSip::SIPStringIndex
       
   907 // -----------------------------------------------------------------------------
       
   908 //    
       
   909 TInt MceSip::SIPStringIndex( const TDesC8& aSIPString )
       
   910     {
       
   911     TInt searchInd = KErrNotFound;
       
   912     const TStringTable& strTable = SIPStrings::Table();
       
   913     
       
   914     TUint strInd = 0;// index in table
       
   915     
       
   916     while ( searchInd == KErrNotFound && strInd < strTable.iCount )
       
   917         {
       
   918         if ( SIPStrings::StringF( strInd ).DesC().CompareF( aSIPString ) == 0 )
       
   919             {
       
   920             searchInd = strInd;
       
   921             }
       
   922         else
       
   923             {
       
   924             strInd++;
       
   925             }
       
   926         } 
       
   927     return searchInd;      
       
   928     }
       
   929     
       
   930 // -----------------------------------------------------------------------------
       
   931 // MceSip::DoDiscardRequestL
       
   932 // -----------------------------------------------------------------------------
       
   933 //
       
   934 void MceSip::DoDiscardRequestL( CSIPServerTransaction& aRequest, TInt aError,
       
   935                                 TBool aRetryIndication )
       
   936     {
       
   937     CSIPResponseElements* response = NULL;
       
   938     TUint responseCode = 0;
       
   939     
       
   940     if ( aError >= (TInt)KMceSipTrying )
       
   941         {
       
   942         responseCode = (TUint)aError;
       
   943         RStringF reasonPhrase = ReasonPhraseL( responseCode );
       
   944         CleanupClosePushL( reasonPhrase );
       
   945         response = 
       
   946             CSIPResponseElements::NewL( responseCode, reasonPhrase );
       
   947                                         
       
   948         CleanupStack::PopAndDestroy();//reasonPhrase
       
   949         }
       
   950     else
       
   951         {
       
   952         TInt reasonPhrase = 0;
       
   953            
       
   954         ErrorResponse( aError, responseCode, reasonPhrase );
       
   955     
       
   956         response = 
       
   957             CSIPResponseElements::NewL( responseCode, 
       
   958                                         SIPStrings::StringF( reasonPhrase ) );
       
   959         }
       
   960         
       
   961     CleanupStack::PushL( response );
       
   962 
       
   963     if ( aRetryIndication )
       
   964         {
       
   965         
       
   966         CSIPMessageElements& elements = response->MessageElements();
       
   967         
       
   968         //create Retry-After header
       
   969         RPointerArray<CSIPHeaderBase> headers;
       
   970         CSIPHeaderBase::PushLC( &headers );
       
   971 
       
   972         CSIPRetryAfterHeader* retryAfter = 
       
   973             CSIPRetryAfterHeader::NewLC( Random( KMceRandMinRetryValue,
       
   974                                                  KMceRandMaxRetryValue ) );
       
   975         headers.AppendL( retryAfter );
       
   976         CleanupStack::Pop( retryAfter );
       
   977         //send invitation
       
   978         elements.SetUserHeadersL( headers );
       
   979         CleanupStack::Pop( &headers );
       
   980         
       
   981         }
       
   982     
       
   983     aRequest.SendResponseL( response );
       
   984     CleanupStack::Pop( response );
       
   985         
       
   986     
       
   987     }
       
   988 
       
   989 // -----------------------------------------------------------------------------
       
   990 // MceSip::FindHeader
       
   991 // -----------------------------------------------------------------------------
       
   992 // 
       
   993 CSIPHeaderBase* MceSip::FindHeader( const CSIPMessageElements& aMessage,
       
   994                                     RStringF aHeaderName )
       
   995     {
       
   996     TBool found = EFalse;
       
   997     CSIPHeaderBase* header = NULL;
       
   998     const RPointerArray<CSIPHeaderBase>& headers = aMessage.UserHeaders();
       
   999     
       
  1000     for ( TInt i=0; i < headers.Count() && !found; i++ )
       
  1001         {
       
  1002         header = headers[i];
       
  1003         if ( header->Name() == aHeaderName )
       
  1004             {
       
  1005             found = ETrue;
       
  1006             }
       
  1007         else
       
  1008             {
       
  1009             header = NULL;
       
  1010             }
       
  1011         }
       
  1012     return header;
       
  1013     }
       
  1014 
       
  1015 // -----------------------------------------------------------------------------
       
  1016 // MceSip::FindHeader
       
  1017 // -----------------------------------------------------------------------------
       
  1018 // 
       
  1019 CSIPHeaderBase* MceSip::FindHeader( const RPointerArray<CSIPHeaderBase>& aHeaders ,
       
  1020                                     RStringF aHeaderName )
       
  1021     {
       
  1022     TBool found = EFalse;
       
  1023     CSIPHeaderBase* header = NULL;
       
  1024     
       
  1025     for ( TInt i=0; i < aHeaders.Count() && !found; i++ )
       
  1026         {
       
  1027         header = aHeaders[i];
       
  1028         if ( header->Name() == aHeaderName )
       
  1029             {
       
  1030             found = ETrue;
       
  1031             }
       
  1032         else
       
  1033             {
       
  1034             header = NULL;
       
  1035             }
       
  1036         }
       
  1037     return header;
       
  1038     }
       
  1039 // -----------------------------------------------------------------------------
       
  1040 // MceSip::FindHeadersL
       
  1041 // -----------------------------------------------------------------------------
       
  1042 // 
       
  1043 void MceSip::FindHeadersL( const CSIPMessageElements& aMessage,
       
  1044                            RStringF aHeaderName,
       
  1045                            RPointerArray<CSIPHeaderBase>& aHeaders )
       
  1046     {
       
  1047     const RPointerArray<CSIPHeaderBase>& headers = aMessage.UserHeaders();
       
  1048     CSIPHeaderBase* header = NULL;
       
  1049     
       
  1050     for ( TInt i=0; i < headers.Count(); i++ )
       
  1051         {
       
  1052         header = headers[i];
       
  1053         if ( header->Name() == aHeaderName )
       
  1054             {
       
  1055             aHeaders.AppendL( header );
       
  1056             }
       
  1057         }
       
  1058     }
       
  1059 
       
  1060 // -----------------------------------------------------------------------------
       
  1061 // MceSip::CompareUri
       
  1062 // -----------------------------------------------------------------------------
       
  1063 // 
       
  1064 TInt MceSip::CompareUri( const CUri8& aRemoteUriOne, const CUri8& aRemoteUriTwo )
       
  1065     {  
       
  1066     TInt ret = KErrGeneral;
       
  1067     
       
  1068     if ( aRemoteUriOne.Uri().Compare( aRemoteUriTwo.Uri(), EUriScheme ) == KErrNone &&
       
  1069          aRemoteUriOne.Uri().Compare( aRemoteUriTwo.Uri(), EUriUserinfo ) == KErrNone &&
       
  1070          aRemoteUriOne.Uri().Compare( aRemoteUriTwo.Uri(), EUriHost ) == KErrNone  )
       
  1071         {
       
  1072         ret = KErrNone;
       
  1073         }
       
  1074         
       
  1075     return ret;
       
  1076     }
       
  1077 
       
  1078 // -----------------------------------------------------------------------------
       
  1079 // MceSip::HasHeaderValueL
       
  1080 // -----------------------------------------------------------------------------
       
  1081 // 
       
  1082 TBool MceSip::HasHeaderValueL( const CSIPMessageElements& aMessage,
       
  1083                               TInt aHeaderName,
       
  1084                               const TDesC8& aHeaderValue )
       
  1085     {
       
  1086     TBool found = EFalse;
       
  1087     CSIPHeaderBase* header = NULL;
       
  1088     const RPointerArray<CSIPHeaderBase>& headers = aMessage.UserHeaders();
       
  1089     
       
  1090     for ( TInt i=0; i < headers.Count() && !found; i++ )
       
  1091         {
       
  1092         header = headers[i];
       
  1093         if ( header->Name() == SIPStrings::StringF( aHeaderName ) )
       
  1094             {
       
  1095             HBufC8* value = header->ToTextValueL();
       
  1096             if ( value->CompareF( aHeaderValue ) == 0 )
       
  1097                 {
       
  1098                 found = ETrue;
       
  1099                 }
       
  1100             delete value;
       
  1101             }
       
  1102             
       
  1103         if ( !found )
       
  1104             {
       
  1105             header = NULL;
       
  1106             }
       
  1107         }
       
  1108     return found;
       
  1109     }
       
  1110     
       
  1111 // -----------------------------------------------------------------------------
       
  1112 // MceSip::HasHeaderValueL
       
  1113 // -----------------------------------------------------------------------------
       
  1114 // 
       
  1115 TBool MceSip::HasHeaderValueL( const RPointerArray<CSIPHeaderBase>& aHeaders,
       
  1116                               TInt aHeaderName,
       
  1117                               const TDesC8& aHeaderValue )
       
  1118     {
       
  1119     TBool found = EFalse;
       
  1120     CSIPHeaderBase* header = NULL;
       
  1121     
       
  1122     for ( TInt i=0; i < aHeaders.Count() && !found; i++ )
       
  1123         {
       
  1124         header = aHeaders[i];
       
  1125         if ( header->Name() == SIPStrings::StringF( aHeaderName ) )
       
  1126             {
       
  1127             HBufC8* value = header->ToTextValueL();
       
  1128             if ( value->CompareF( aHeaderValue ) == 0 )
       
  1129                 {
       
  1130                 found = ETrue;
       
  1131                 }
       
  1132             delete value;
       
  1133             }
       
  1134             
       
  1135         if ( !found )
       
  1136             {
       
  1137             header = NULL;
       
  1138             }
       
  1139         }
       
  1140     return found;
       
  1141     }    
       
  1142 // MceSip::Random
       
  1143 // -----------------------------------------------------------------------------
       
  1144 // 
       
  1145 TUint MceSip::Random( TUint aMinValue, TUint aMaxValue )
       
  1146     {
       
  1147     TUint randomValue( aMinValue <= aMaxValue ? aMinValue : 0 );
       
  1148     
       
  1149     if ( aMinValue <= aMaxValue )
       
  1150         {
       
  1151         
       
  1152         TTime time;
       
  1153         time.HomeTime();
       
  1154         TInt64 seed( time.Int64() );
       
  1155 
       
  1156         
       
  1157         for ( TUint i = 0; i < ( aMaxValue - aMinValue ); i++ )
       
  1158             {
       
  1159             TInt random = Math::Rand( seed );
       
  1160             TReal random2 =  ( TReal )random / KMceRandDividerOne;
       
  1161             TUint random3 = ( TUint )( aMaxValue * random2 ) /
       
  1162             KMceRandDividerTwo;
       
  1163 
       
  1164             if ( aMinValue <= random3 && aMaxValue >= random3 )
       
  1165                 {
       
  1166                 randomValue = random3;
       
  1167                 break;
       
  1168                 }
       
  1169             }
       
  1170         }
       
  1171         
       
  1172     return randomValue;
       
  1173     
       
  1174     }
       
  1175 
       
  1176     
       
  1177 // -----------------------------------------------------------------------------
       
  1178 // MceSip::HeaderValueL
       
  1179 // -----------------------------------------------------------------------------
       
  1180 // 
       
  1181 TUint MceSip::HeaderValueL( TPtr8 aHeader )
       
  1182     {
       
  1183 	TUint value;
       
  1184 	aHeader.Trim();
       
  1185 	
       
  1186 	TInt index = aHeader.Locate( KMceSipHeaderSeparator );
       
  1187 	if( index != KErrNotFound )
       
  1188 		{
       
  1189 		TLex8 lexValue( aHeader.Left( index ) );
       
  1190 		User::LeaveIfError ( lexValue.Val( value, EDecimal ) );
       
  1191 		}
       
  1192 	else
       
  1193 		{
       
  1194 		TLex8 lexValue( aHeader );
       
  1195 		User::LeaveIfError ( lexValue.Val( value, EDecimal ) );
       
  1196 		}
       
  1197 		
       
  1198     return value;
       
  1199     
       
  1200     }
       
  1201 
       
  1202 
       
  1203 
       
  1204 // -----------------------------------------------------------------------------
       
  1205 // MceSip::RSeq     
       
  1206 // -----------------------------------------------------------------------------
       
  1207 // 
       
  1208 
       
  1209 TInt MceSip::RSeq( const CSIPResponseElements& aResponseElements )
       
  1210     {
       
  1211         
       
  1212     TInt value = KErrNotFound; // if its not found
       
  1213     
       
  1214     CSIPHeaderBase* rseqHeader = FindHeader( aResponseElements.MessageElements(),
       
  1215                             SIPStrings::StringF( SipStrConsts::ERSeqHeader ) );
       
  1216                                     
       
  1217     if ( rseqHeader )
       
  1218         {
       
  1219         value = static_cast< CSIPRSeqHeader* >( rseqHeader )->Value(); 
       
  1220         }
       
  1221            
       
  1222     return value;    
       
  1223     }
       
  1224     
       
  1225  // -----------------------------------------------------------------------------
       
  1226 // MceSip::BasicAllowMethods
       
  1227 // -----------------------------------------------------------------------------
       
  1228 //    
       
  1229 void MceSip::BasicAllowMethodsL( RArray<TInt>& aArray )
       
  1230 	{
       
  1231 	User::LeaveIfError( aArray.Append( SipStrConsts::EInvite ));
       
  1232 	User::LeaveIfError( aArray.Append( SipStrConsts::EAck ));
       
  1233 	User::LeaveIfError( aArray.Append( SipStrConsts::ECancel ));
       
  1234 	User::LeaveIfError( aArray.Append( SipStrConsts::EOptions ));
       
  1235 	User::LeaveIfError( aArray.Append( SipStrConsts::EBye ));
       
  1236 	}
       
  1237 	    
       
  1238 
       
  1239 //  End of File