realtimenetprots/sipfw/SIP/Dialogs/src/DialogStateBase.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2005-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          : DialogStateBase.cpp
       
    15 // Part of       : SIPDialogs
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "DialogStateBase.h"
       
    22 #include "MDialogContext.h"
       
    23 #include "MDialogOwner.h"
       
    24 #include "TransactionItem.h"
       
    25 #include "RefreshItem.h"
       
    26 #include "sip.h"
       
    27 #include "sipresponse.h"
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // TDialogStateBase::TDialogStateBase
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 TDialogStateBase::TDialogStateBase(MDialogContext& aDialog)
       
    34  : iDialog(aDialog)
       
    35     {
       
    36     }
       
    37     
       
    38 // -----------------------------------------------------------------------------
       
    39 // TDialogStateBase::~TDialogStateBase
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 TDialogStateBase::~TDialogStateBase()
       
    43     {
       
    44     }   
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // TDialogStateBase::RequestsWithinDialogAllowed
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 TBool TDialogStateBase::RequestsWithinDialogAllowed () const
       
    51     {
       
    52     return ETrue; 
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // TDialogStateBase::Accept
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 TBool TDialogStateBase::Accept(CSIPRequest& /*aRequest*/) const
       
    60     {
       
    61     return ETrue;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // TDialogStateBase::PassToOwnerL
       
    66 // -----------------------------------------------------------------------------
       
    67 // 
       
    68 void TDialogStateBase::PassToOwnerL (CTransactionItemBase& aTransactionItem,
       
    69                                      CSIPResponse* aResponse)
       
    70     {
       
    71     MDialogOwner* owner = iDialog.DialogOwner();
       
    72     TDialogId dialogId = iDialog.DialogId();
       
    73     TTransactionId transactionId = aTransactionItem.Id();
       
    74     TRefreshId refreshId = KEmptyRefreshId;
       
    75     if (aTransactionItem.IsRefreshed())
       
    76         {
       
    77         refreshId = static_cast<CRefreshItem&>(aTransactionItem).RefreshId();
       
    78         if (aTransactionItem.Terminate() && 
       
    79             aResponse->Type() != CSIPResponse::E1XX)
       
    80             {
       
    81             iDialog.RemoveTransactionItem(transactionId);
       
    82 			owner->DialogsReceivedL(transactionId,refreshId,dialogId,aResponse);
       
    83 			return;
       
    84             }
       
    85         }
       
    86 	if (aTransactionItem.PassResponseToOwner())
       
    87 		{
       
    88 		TUint responseCode = aResponse->ResponseCode();
       
    89 		owner->DialogsReceivedL(transactionId,refreshId,dialogId,aResponse);
       
    90 		aTransactionItem.ResponseReceived(responseCode);
       
    91 		}
       
    92 	else
       
    93 		{
       
    94 		delete aResponse;
       
    95 		}
       
    96     }
       
    97     
       
    98 // -----------------------------------------------------------------------------
       
    99 // TDialogStateBase::PassToOwnerL
       
   100 // -----------------------------------------------------------------------------
       
   101 // 
       
   102 void TDialogStateBase::PassToOwnerL (TTransactionId aTransactionId,
       
   103                                      CSIPRequest* aRequest)
       
   104     {
       
   105     TDialogId dialogId = iDialog.DialogId();
       
   106     iDialog.DialogOwner()->DialogsReceivedL(aTransactionId,dialogId,aRequest);
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // TDialogStateBase::PassToOwner
       
   111 // -----------------------------------------------------------------------------
       
   112 // 
       
   113 TInt TDialogStateBase::PassToOwner (CTransactionItemBase& aTransactionItem,
       
   114                                     TInt aErr)
       
   115     {
       
   116     MDialogOwner* owner = iDialog.DialogOwner();
       
   117     TDialogId dialogId = iDialog.DialogId();
       
   118     TTransactionId transactionId = aTransactionItem.Id();
       
   119     TRefreshId refreshId = KEmptyRefreshId;
       
   120     if (aTransactionItem.IsRefreshed())
       
   121         {
       
   122         refreshId = static_cast<CRefreshItem&>(aTransactionItem).RefreshId();
       
   123         }
       
   124     return owner->DialogsError(transactionId,refreshId,dialogId,aErr);
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // TDialogStateBase::PassToOwnerL
       
   129 // -----------------------------------------------------------------------------
       
   130 // 
       
   131 void TDialogStateBase::PassToOwnerL (CTransactionItemBase& aTransactionItem,
       
   132                                      TInt aErr)
       
   133     {
       
   134     TInt err = PassToOwner(aTransactionItem,aErr);
       
   135     if (err != KErrNone)
       
   136         {
       
   137         User::Leave(err);
       
   138         }
       
   139     }