realtimenetprots/sipfw/SIP/Client/src/CSIPClientConnectionReceiver.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name          : CSIPClientConnectionReceiver.cpp
       
    15 // Part of       : SIPClient
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "CSIPClientConnectionReceiver.h"
       
    22 #include "RSIPConnection.h"
       
    23 #include "sipclientconnectionobserver.h"
       
    24 #include "siprequestelements.h"
       
    25 #include "sipresponseelements.h"
       
    26 #include "sipmessageelements.h"
       
    27 #include "sipinternalerr.h"
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CSIPClientConnectionReceiver::CSIPClientConnectionReceiver
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CSIPClientConnectionReceiver::CSIPClientConnectionReceiver (
       
    35                                         RSIPConnection& aConnection,
       
    36                                         MSIPClientConnectionObserver& aObserver) 
       
    37  : CSIPITCReceiverBase (aConnection),
       
    38    iConnection (aConnection),
       
    39    iObserver (aObserver)
       
    40 	{
       
    41 	}
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CSIPClientConnectionReceiver::~CSIPClientConnectionReceiver
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CSIPClientConnectionReceiver::~CSIPClientConnectionReceiver () 
       
    48 	{
       
    49 	}
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CSIPClientConnectionReceiver::IncomingRequest
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 void 
       
    56 CSIPClientConnectionReceiver::IncomingRequestL (TSIPIds& aIds,
       
    57                                                 CSIPRequestElements* aRequest)
       
    58     {
       
    59     TUint32 requestId = aIds.iRequestId;
       
    60 	if (aIds.iDialogId != 0)
       
    61 		{
       
    62 		iObserver.IncomingDialogRequestL(aRequest, requestId, aIds.iDialogId);
       
    63 		}
       
    64 	else
       
    65 		{
       
    66 		iObserver.IncomingRequestL(aRequest,requestId);
       
    67 		}
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CSIPClientConnectionReceiver::IncomingResponse
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void 
       
    75 CSIPClientConnectionReceiver::IncomingResponseL (TSIPIds& aIds,
       
    76                                                  CSIPResponseElements* aResponse)
       
    77     {
       
    78 	TUint32 requestId = aIds.iRequestId;
       
    79 	TUint32 registrationId = aIds.iRegistrationId;
       
    80 	TUint32 dialogId = aIds.iDialogId;	
       
    81 	TUint32 refreshId = aIds.iRefreshId;
       
    82 	if (dialogId != 0)
       
    83 		{	
       
    84         if (refreshId != 0)
       
    85             {
       
    86 		    iObserver.IncomingDialogResponseL(aResponse, requestId,
       
    87 		                                      refreshId, dialogId);
       
    88             }
       
    89         else
       
    90             {
       
    91             iObserver.IncomingDialogResponseL(aResponse,requestId,dialogId);
       
    92             }
       
    93 		}
       
    94 	else if (registrationId != 0)
       
    95 		{
       
    96 		iObserver.IncomingRegistrationResponseL(aResponse,requestId,
       
    97 		                                        refreshId, registrationId);
       
    98 		}
       
    99 	else if (refreshId != 0)
       
   100 		{
       
   101 		iObserver.IncomingRefreshResponseL(aResponse,requestId,refreshId);
       
   102 		}	
       
   103 	else
       
   104 		{
       
   105 		iObserver.IncomingResponseL(aResponse,requestId);
       
   106 		}
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CSIPClientConnectionReceiver::ErrorOccuredL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CSIPClientConnectionReceiver::ErrorOccuredL (TSIPIds& aIds, TInt aError)
       
   114 	{
       
   115     switch (aError)
       
   116         {
       
   117         case CSIPConnection::EInit:
       
   118 		case CSIPConnection::EActive:
       
   119 		case CSIPConnection::ESuspended:
       
   120 		case CSIPConnection::EInactive:
       
   121         case CSIPConnection::EUnavailable:
       
   122 			ConnectionStateChanged(static_cast<CSIPConnection::TState>(aError));
       
   123             break;
       
   124 
       
   125         case KInviteTransactionCompleted:
       
   126             InviteCompleted(aIds);
       
   127             break;
       
   128 
       
   129         default: 
       
   130             ErrorOccured(aIds,aError);
       
   131             break;
       
   132 		}
       
   133 	}
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CSIPClientConnectionReceiver::ErrorOccured
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CSIPClientConnectionReceiver::ErrorOccured (TSIPIds& aIds, TInt aError)
       
   140     {
       
   141 	TUint32 requestId = aIds.iRequestId;
       
   142 	TUint32 registrationId = aIds.iRegistrationId;
       
   143 	TUint32 dialogId = aIds.iDialogId;	
       
   144 	TUint32 refreshId = aIds.iRefreshId;    
       
   145 	if (dialogId != 0)
       
   146 		{
       
   147         if (refreshId != 0)
       
   148             {
       
   149 		    iObserver.DialogErrorOccured(aError,dialogId,refreshId,requestId);
       
   150             }
       
   151         else
       
   152             {
       
   153             iObserver.DialogErrorOccured(aError,dialogId,requestId);
       
   154             }
       
   155 		}
       
   156 	else if (registrationId != 0)
       
   157 		{
       
   158 		iObserver.RegistrationErrorOccured(aError,registrationId,requestId);
       
   159 		}		
       
   160 	else if (refreshId != 0)
       
   161 		{
       
   162 		iObserver.RefreshErrorOccured(aError,refreshId);
       
   163 		}
       
   164 	else
       
   165 		{
       
   166 		iObserver.ErrorOccured(aError,requestId);
       
   167 		}
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CSIPClientConnectionReceiver::InviteCompleted
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CSIPClientConnectionReceiver::InviteCompleted (TSIPIds& aIds)
       
   175     {
       
   176     iObserver.InviteCompleted(aIds.iRequestId);
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CSIPClientConnectionReceiver::ConnectionStateChanged
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 void CSIPClientConnectionReceiver::ConnectionStateChanged (
       
   184     CSIPConnection::TState aState)
       
   185     {
       
   186 	iConnection.SetState(aState);
       
   187 	iObserver.ConnectionStateChanged(aState);
       
   188     }