realtimenetprots/sipfw/ProfileAgent/Client/Src/sipmanagedprofileregistry.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        : sipmanagedprofileregistry
       
    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 "sipmanagedprofileregistry.h"
       
    25 #include "sipprofileregistryobserver.h"
       
    26 #include "sipmanagedprofile.h"
       
    27 #include "sipconcreteprofile.h"
       
    28 #include "SIPProfileITC.h"
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSIPManagedProfileRegistry::NewL
       
    34 // Two-phased constructor.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CSIPManagedProfileRegistry* CSIPManagedProfileRegistry::NewL(
       
    38 											MSIPProfileRegistryObserver& aObserver)
       
    39 	{
       
    40     CSIPManagedProfileRegistry* self = CSIPManagedProfileRegistry::NewLC (aObserver);
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43 	}
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CSIPManagedProfileRegistry::NewLC
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CSIPManagedProfileRegistry* CSIPManagedProfileRegistry::NewLC(
       
    51 											MSIPProfileRegistryObserver& aObserver)
       
    52 	{
       
    53 	CSIPManagedProfileRegistry* self = new(ELeave)CSIPManagedProfileRegistry(aObserver);
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     return self;
       
    57 	}
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CSIPManagedProfileRegistry::~CSIPManagedProfileRegistry
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CSIPManagedProfileRegistry::~CSIPManagedProfileRegistry()
       
    64 	{
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSIPManagedProfileRegistry::CreateL
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C CSIPManagedProfile* CSIPManagedProfileRegistry::CreateL(
       
    72 	const TSIPProfileTypeInfo& aType)
       
    73 	{
       
    74 	CSIPConcreteProfile *concreteProfile = iITC->SIPCreateProfileL(aType);
       
    75 	CleanupStack::PushL(concreteProfile);
       
    76 	CSIPManagedProfile* profile = CSIPManagedProfile::NewL(0);
       
    77 	CleanupStack::Pop(concreteProfile);
       
    78 	profile->SetConcreteProfile(concreteProfile);
       
    79 	return profile;
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CSIPManagedProfileRegistry::IsInUse
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C TBool CSIPManagedProfileRegistry::IsInUseL(const CSIPProfile& aSIPProfile) const
       
    87 	{
       
    88 	return (UsageL(aSIPProfile) != 0);
       
    89 	}
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSIPManagedProfileRegistry::SaveL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CSIPManagedProfileRegistry::SaveL(CSIPProfile& aSIPProfile)
       
    96 	{
       
    97 	__ASSERT_ALWAYS (aSIPProfile.ConcreteProfile().ValidateProfileParamsL(),User::Leave (KErrArgument));
       
    98 	aSIPProfile.ConcreteProfile().SetLastRegistrationError(KErrNone);
       
    99 	if (aSIPProfile.ConcreteProfile().Id() == 0)
       
   100 		{
       
   101 		AddProfileL(aSIPProfile);
       
   102 		aSIPProfile.SetRegistry(this);
       
   103 		} 
       
   104 	else
       
   105 		{
       
   106 		UpdateProfileL(aSIPProfile);
       
   107 		}
       
   108 	aSIPProfile.ConcreteProfile().SetDefault(EFalse);
       
   109 	}
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CSIPManagedProfileRegistry::DestroyL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 EXPORT_C void CSIPManagedProfileRegistry::DestroyL(CSIPProfile& aSIPProfile)
       
   116 	{
       
   117 	aSIPProfile.ConcreteProfile().SetLastRegistrationError(KErrNone);
       
   118 	RemoveProfileL(aSIPProfile);
       
   119 	}
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CSIPManagedProfileRegistry::CSIPManagedProfileRegistry
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 CSIPManagedProfileRegistry::CSIPManagedProfileRegistry(
       
   126 	MSIPProfileRegistryObserver& aObserver):
       
   127 	CSIPProfileRegistryBase(aObserver)
       
   128 	{
       
   129 	}
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CSIPManagedProfileRegistry::ConstructL
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CSIPManagedProfileRegistry::ConstructL()
       
   136 	{
       
   137 	BaseConstructL();
       
   138 	}
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CSIPManagedProfileRegistry::NewInstanceL
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CSIPProfile* CSIPManagedProfileRegistry::NewInstanceL()
       
   145 	{
       
   146 	CSIPManagedProfile* profile = CSIPManagedProfile::NewL(this);
       
   147     return profile;
       
   148 	}