realtimenetprots/sipfw/ProfileAgent/Client/Src/sipprofileregistry.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-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        : sipprofileregistry
       
    15 // Part of     : SIP Profile Client
       
    16 // implementation
       
    17 // Version     : 1.0
       
    18 // INCLUDE FILES
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 #include "sip.h"
       
    24 #include "sipconnection.h"
       
    25 #include "sipprofileregistry.h"
       
    26 #include "sipprofileregistryobserver.h"
       
    27 #include "sipprofile.h"
       
    28 #include "sipconcreteprofile.h"
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSIPProfileRegistry::NewL
       
    34 // Two-phased constructor.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CSIPProfileRegistry* CSIPProfileRegistry::NewL(
       
    38 	CSIP& aSip,
       
    39 	MSIPProfileRegistryObserver& aObserver)
       
    40 	{
       
    41     CSIPProfileRegistry* self = CSIPProfileRegistry::NewLC(aSip, aObserver);
       
    42     CleanupStack::Pop(self);
       
    43     return self;
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSIPProfileRegistry::NewLC
       
    48 // Two-phased constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CSIPProfileRegistry* CSIPProfileRegistry::NewLC(
       
    52 	CSIP& aSip,
       
    53 	MSIPProfileRegistryObserver& aObserver)
       
    54 	{
       
    55 	CSIPProfileRegistry* self = new (ELeave) CSIPProfileRegistry(aSip, aObserver);
       
    56     CleanupStack::PushL(self);
       
    57     self->ConstructL();
       
    58     return self;
       
    59 	}
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CSIPProfileRegistry::~CSIPProfileRegistry
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C CSIPProfileRegistry::~CSIPProfileRegistry()
       
    66 	{
       
    67 	}
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CSIPProfileRegistry::EnableL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C void CSIPProfileRegistry::EnableL(CSIPProfile& aSIPProfile,
       
    74 						MSIPConnectionObserver &aObserver)
       
    75 	{
       
    76 	__ASSERT_ALWAYS (!aSIPProfile.IsEnabled(), User::Leave (KErrArgument));
       
    77 	aSIPProfile.ConcreteProfile().SetLastRegistrationError(KErrNone);
       
    78 	iConnectionObserver = &aObserver;
       
    79 
       
    80 	EnableProfileL(aSIPProfile);
       
    81 	}
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSIPProfileRegistry::Disable
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C TInt CSIPProfileRegistry::Disable(CSIPProfile& aProfile)
       
    88 	{
       
    89 	aProfile.ConcreteProfile().SetLastRegistrationError(KErrNone);
       
    90 	TRAPD(err, DisableProfileL(aProfile));
       
    91 	return err;
       
    92 	}
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CSIPProfileRegistry::RefreshEnableL
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 
       
    99 EXPORT_C  void CSIPProfileRegistry::RefreshEnableL(CSIPProfile& aProfile)
       
   100 	{
       
   101 	__ASSERT_ALWAYS (aProfile.IsEnabled(), User::Leave (KErrArgument));
       
   102 	EnableProfileL(aProfile);
       
   103 	}
       
   104 // -----------------------------------------------------------------------------
       
   105 // CSIPProfileRegistry::ForceDisable
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C TInt CSIPProfileRegistry::ForceDisable(CSIPProfile& aProfile)
       
   109 	{
       
   110 	aProfile.ConcreteProfile().SetLastRegistrationError(KErrNone);
       
   111 	TRAPD(err, ForceDisableProfileL(aProfile));
       
   112 	return err;
       
   113 	}
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CSIPProfileRegistry::SIP
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C CSIP& CSIPProfileRegistry::SIP() const
       
   120 	{
       
   121 	return iSip;
       
   122 	}
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CSIPProfileRegistry::ConnectionL
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 EXPORT_C CSIPConnection* CSIPProfileRegistry::ConnectionL(
       
   129 						CSIPProfile& aSIPProfile)
       
   130 	{
       
   131 	TUint32 apId(0);
       
   132 	__ASSERT_ALWAYS (iConnectionObserver != 0, User::Leave (KErrArgument));
       
   133 	aSIPProfile.GetParameter(KSIPAccessPointId, apId);
       
   134 	CSIPConnection* connection = iSip.Connection(apId);
       
   135 	if (connection == 0)
       
   136 		{
       
   137 		connection = CSIPConnection::NewL(iSip, apId, *iConnectionObserver);
       
   138 		}
       
   139 		
       
   140     TUint32 ipTosVal( 0 );
       
   141     if ( aSIPProfile.GetParameter( KSIPSoIpTOS, ipTosVal ) != KErrNotFound )
       
   142         {
       
   143         // Client might not have required capabilities for setting socket opts,
       
   144         // ignore error as the connection can be still used
       
   145         TRAP_IGNORE( connection->SetOptL( KSoIpTOS, KProtocolInetIp, ipTosVal ) )
       
   146         }
       
   147 	return connection;
       
   148 	}
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CSIPProfileRegistry::IsEnabled
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C TBool CSIPProfileRegistry::IsEnabled(const CSIPProfile& aSIPProfile) const
       
   155 	{
       
   156 	return aSIPProfile.IsEnabled();
       
   157 	}
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CSIPProfileRegistry::CSIPProfileRegistry
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 CSIPProfileRegistry::CSIPProfileRegistry(
       
   164 	CSIP& aSip,
       
   165 	MSIPProfileRegistryObserver& aObserver):
       
   166 	CSIPProfileRegistryBase(aObserver), iSip(aSip)
       
   167 	{
       
   168 
       
   169 	}
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CSIPProfileRegistry::ConstructL
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CSIPProfileRegistry::ConstructL()
       
   176 	{
       
   177 	BaseConstructL();
       
   178 	}
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CSIPProfileRegistry::NewInstanceL
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 CSIPProfile* CSIPProfileRegistry::NewInstanceL()
       
   185 	{
       
   186     return CSIPProfile::NewL(this);
       
   187 	}
       
   188