realtimenetprots/sipfw/SIP/sipapi/src/CSIPInternalStates.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          : CSIPInternalStates.cpp
       
    15 // Part of       : SIPClient
       
    16 // Version       : SIP/4.0
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "sipinternalstates.h"
       
    22 #include "sipclientserver.h"
       
    23 #include "RSIP.h"
       
    24 #include "siptransactionbase.h"
       
    25 #include "SipDialogImplementation.h"
       
    26 
       
    27 
       
    28 #ifdef CPPUNIT_TEST
       
    29 #undef EXPORT_C
       
    30 #define EXPORT_C
       
    31 #endif
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CSIPInternalStates::NewL
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CSIPInternalStates* CSIPInternalStates::NewL ()
       
    38 	{
       
    39     CSIPInternalStates* self = CSIPInternalStates::NewLC();
       
    40     CleanupStack::Pop (self);
       
    41     return self;
       
    42 	}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSIPInternalStates::NewLC
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CSIPInternalStates* CSIPInternalStates::NewLC ()
       
    49 	{
       
    50 	CSIPInternalStates* self = new(ELeave)CSIPInternalStates;
       
    51     CleanupStack::PushL (self);
       
    52     self->ConstructL ();
       
    53     return self;
       
    54 	}
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSIPInternalStates::CSIPInternalStates
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CSIPInternalStates::CSIPInternalStates ()
       
    61 	{
       
    62 	}
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CSIPInternalStates::ConstructL
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CSIPInternalStates::ConstructL ()
       
    69 	{
       
    70 	iSip = new(ELeave)RSIP;
       
    71 	User::LeaveIfError(iSip->Connect());
       
    72 	}
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CSIPInternalStates::~CSIPInternalStates
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C CSIPInternalStates::~CSIPInternalStates()
       
    79 	{
       
    80 	if (iSip)
       
    81         {
       
    82         iSip->Close();
       
    83         }
       
    84 	delete iSip;
       
    85 	}
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSIPInternalStates::GetTransactionState
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C TInt 
       
    92 CSIPInternalStates::GetTransactionState(const CSIPTransactionBase& aTransaction,
       
    93                                         TState& aState)
       
    94     {
       
    95     TSIPIds ids;
       
    96     ids.iRequestId = aTransaction.RequestId();
       
    97     return GetState (*iSip,ids,aState,ESipItcGetTransactionState);
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CSIPInternalStates::GetDialogState
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C TInt CSIPInternalStates::GetDialogState (const CSIPDialog& aDialog,
       
   105                                                   TState& aState)
       
   106     {
       
   107     TSIPIds ids;    
       
   108 	ids.iDialogId =
       
   109 		const_cast<CSIPDialog&>(aDialog).Implementation().DialogId();
       
   110     return GetState (*iSip,ids,aState,ESipItcGetDialogState);
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CSIPInternalStates::SigCompCompartmentCount
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 EXPORT_C TInt CSIPInternalStates::SigCompCompartmentCount ()
       
   118     {    
       
   119     TPckgBuf<TInt> compartmentCountPckg;
       
   120     TIpcArgs args;
       
   121     args.Set (ESipItcArgInternalState, &compartmentCountPckg);
       
   122     TInt err = iSip->Send(ESipItcGetCompartmentCount,args);
       
   123     if (err == KErrNone)
       
   124     	{    	
       
   125     	return compartmentCountPckg();
       
   126     	}
       
   127     return err;    
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CSIPInternalStates::GetState
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 TInt CSIPInternalStates::GetState (RSIP& aSip,
       
   135 								   TSIPIds& aIds,
       
   136                                    TState& aState,
       
   137                                    TInt aFunction)
       
   138     {
       
   139     TPckgBuf<TSIPIds> sipIdsPckg(aIds);
       
   140   
       
   141     TIpcArgs args;
       
   142     args.Set (ESipItcArgIds, &sipIdsPckg);
       
   143     
       
   144     TPckgBuf<TInt> statePckg;
       
   145     args.Set (ESipItcArgInternalState, &statePckg);
       
   146 
       
   147     TInt err = aSip.Send(static_cast<TSipItcFunctions>(aFunction),args);
       
   148     if (err == KErrNone)
       
   149         {
       
   150         aState = static_cast<TState>(statePckg());
       
   151         }
       
   152     return err;
       
   153     }