realtimenetprots/sipfw/SIP/SigCompController/DefaultPlugin/src/sipsigcompcompartmentuser.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          : sipsigcompcompartmentuser.cpp
       
    15 // Part of       : SIPSigComp
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "sipsigcompcompartmentuser.h"
       
    22 #include "sipsigcompcompartmentctx.h"
       
    23 #include "MCompartmentUserOwner.h"
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSipSigCompCompartmentUser::NewL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CSipSigCompCompartmentUser* CSipSigCompCompartmentUser::NewL(
       
    30     MCompartmentUserOwner& aMyOwner,
       
    31     TUint32 aCompartmentId,
       
    32 	TUint32 aIapId,
       
    33 	TBool aDynamicCompression )
       
    34 	{
       
    35 	CSipSigCompCompartmentUser* self = 
       
    36 	    CSipSigCompCompartmentUser::NewLC( aMyOwner, 
       
    37 	                                       aCompartmentId,
       
    38 	                                       aIapId, 
       
    39 	                                       aDynamicCompression );
       
    40 	CleanupStack::Pop();
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CSipSigCompCompartmentUser::NewLC
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CSipSigCompCompartmentUser* CSipSigCompCompartmentUser::NewLC(
       
    50     MCompartmentUserOwner& aMyOwner,
       
    51     TUint32 aCompartmentId,
       
    52 	TUint32 aIapId,
       
    53 	TBool aDynamicCompression )
       
    54 	{
       
    55 	CSipSigCompCompartmentUser* self = 
       
    56 	    new ( ELeave ) CSipSigCompCompartmentUser( aMyOwner, 
       
    57 	                                               aCompartmentId, 
       
    58 	                                               aIapId,
       
    59 	                                               aDynamicCompression );
       
    60 	CleanupStack::PushL( self );
       
    61 	self->ConstructL();
       
    62 	return self;
       
    63 	}
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSipSigCompCompartmentUser::ConstructL
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void CSipSigCompCompartmentUser::ConstructL()
       
    70 	{
       
    71 	}
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSipSigCompCompartmentUser::~CSipSigCompCompartmentUser
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CSipSigCompCompartmentUser::~CSipSigCompCompartmentUser()
       
    78 	{
       
    79 	if ( iCompartmentCtx )
       
    80 	    {
       
    81 	    iCompartmentCtx->DetachCompartmentUser( this );
       
    82 	    }
       
    83 	}
       
    84     
       
    85 // -----------------------------------------------------------------------------
       
    86 // CSipSigCompCompartmentUser::CompartmentDeleted
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CSipSigCompCompartmentUser::CompartmentDeleted()
       
    90     {
       
    91     // Cannot use ctx anymore
       
    92     iCompartmentCtx = 0;
       
    93     }
       
    94     
       
    95 // -----------------------------------------------------------------------------
       
    96 // CSipSigCompCompartmentUser::Compartment
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CSigCompCompartment* CSipSigCompCompartmentUser::Compartment()
       
   100 	{
       
   101 	if ( iCompartmentCtx )
       
   102 	    {
       
   103 	    return iCompartmentCtx->Compartment();
       
   104 	    }
       
   105 	return 0;
       
   106 	}
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CSipSigCompCompartmentUser::SetAddressL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CSipSigCompCompartmentUser::SetAddressL( const TInetAddr& aAddress )
       
   113 	{
       
   114 	CSipSigCompCompartmentCtx* compCtx = 
       
   115 	        iMyOwner.SearchCompartmentByInetAddr( aAddress, iIapId );
       
   116 	
       
   117     if ( compCtx )
       
   118         {
       
   119         if ( iCompartmentCtx && iCompartmentCtx != compCtx )
       
   120             {
       
   121             // Change compartment, first detach from old compartment
       
   122             iCompartmentCtx->DetachCompartmentUser( this );
       
   123             }
       
   124         }
       
   125     else
       
   126         {
       
   127         // Create new compartment because there wasn't any for this
       
   128         // remote addr
       
   129         compCtx = 
       
   130             iMyOwner.CreateCompartmentL( aAddress, iIapId, iDynamicCompression );
       
   131         }
       
   132     
       
   133     iCompartmentCtx = compCtx;
       
   134     
       
   135     // Attach to compartment, no effect if already attached
       
   136     iCompartmentCtx->AttachCompartmentUserL( this ); 
       
   137 	}
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CSipSigCompCompartmentUser::Match
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TBool CSipSigCompCompartmentUser::Match( const TInetAddr& aAddress ) const
       
   144 	{
       
   145 	return ( iCompartmentCtx && iCompartmentCtx->Match( aAddress, iIapId ) );
       
   146 	}
       
   147 	
       
   148 // -----------------------------------------------------------------------------
       
   149 // CSipSigCompCompartmentUser::Match
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 TBool CSipSigCompCompartmentUser::Match( TUint32 aCompartmentId ) const
       
   153     {
       
   154     return ( iCompartmentId == aCompartmentId );
       
   155     }
       
   156 	
       
   157 // -----------------------------------------------------------------------------
       
   158 // CSipSigCompCompartmentUser::SendFailedL
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 void CSipSigCompCompartmentUser::SendFailedL()
       
   162     {
       
   163     if ( iCompartmentCtx )
       
   164         {
       
   165         iCompartmentCtx->SendFailedL();
       
   166         }
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // Constructor
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 CSipSigCompCompartmentUser::CSipSigCompCompartmentUser(
       
   174     MCompartmentUserOwner& aMyOwner,
       
   175     TUint32 aCompartmentId,
       
   176 	TUint32 aIapId,
       
   177 	TBool aDynamicCompression ) : 
       
   178     iMyOwner( aMyOwner ), 
       
   179     iCompartmentId( aCompartmentId ),
       
   180     iIapId( aIapId ),
       
   181     iDynamicCompression( aDynamicCompression )
       
   182 	{
       
   183 	}
       
   184