realtimenetprots/sipfw/ProfileAgent/Profile/Src/sipconcreteprofileholder.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2007-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        : sipconcreteprofileholder.cpp
       
    15 // Part of     : SIP / SIP Profile Agent / SIP Concrete Profile
       
    16 // Implementation
       
    17 // Version     : %version: 2.1.1 %
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //  INCLUDE FILES
       
    23 #include "sipconcreteprofileholder.h"
       
    24 #include "sipprofile.h"
       
    25 #include "sipmanagedprofile.h"
       
    26 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CSIPConcreteProfileHolder::NewL
       
    32 // Two-phased constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C CSIPConcreteProfileHolder* CSIPConcreteProfileHolder::NewL()
       
    36 	{
       
    37 	CSIPConcreteProfileHolder* self = CSIPConcreteProfileHolder::NewLC();
       
    38 	CleanupStack::Pop(self);
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CSIPConcreteProfileHolder::NewLC
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CSIPConcreteProfileHolder* CSIPConcreteProfileHolder::NewLC()
       
    48 	{
       
    49 	CSIPConcreteProfileHolder* self = new (ELeave) CSIPConcreteProfileHolder();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	return self;
       
    53 	}
       
    54 		
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSIPConcreteProfileHolder::ConstructL
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CSIPConcreteProfileHolder::ConstructL()
       
    60 	{
       
    61 	}
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CSIPConcreteProfileHolder::CSIPConcreteProfileHolder
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CSIPConcreteProfileHolder::CSIPConcreteProfileHolder()
       
    68 	{
       
    69 	iInternalized = EFalse;
       
    70 	}
       
    71 		
       
    72 // -----------------------------------------------------------------------------
       
    73 // CSIPConcreteProfileHolder::~CSIPConcreteProfileHolder
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C CSIPConcreteProfileHolder::~CSIPConcreteProfileHolder()
       
    77 	{
       
    78 	if (iInternalized)
       
    79 		{
       
    80 		iSIPProfiles.ResetAndDestroy();
       
    81 		}
       
    82 	else
       
    83 		{
       
    84 		iSIPProfiles.Reset();
       
    85 		}
       
    86 	}
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CSIPConcreteProfileHolder::SIPProfiles
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 EXPORT_C RPointerArray<CSIPConcreteProfile>& 
       
    93 CSIPConcreteProfileHolder::SIPProfiles()
       
    94 	{
       
    95 	return iSIPProfiles;
       
    96 	}
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSIPConcreteProfileHolder::InternalizeL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C CSIPConcreteProfileHolder* CSIPConcreteProfileHolder::InternalizeL(
       
   103     RReadStream& aReadStream)
       
   104 	{
       
   105 	CSIPConcreteProfileHolder* self = CSIPConcreteProfileHolder::NewLC();
       
   106 	self->DoInternalizeL (aReadStream);
       
   107 	CleanupStack::Pop(self);
       
   108 	return self;
       
   109 	}
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CSIPConcreteProfileHolder::ExternalizeL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 EXPORT_C void CSIPConcreteProfileHolder::ExternalizeL(
       
   116     RWriteStream& aWriteStream) const
       
   117 	{
       
   118 	TUint count = iSIPProfiles.Count();
       
   119 	aWriteStream.WriteUint32L(count);
       
   120 	for (TUint i = 0; i < count; i++) 
       
   121 		{
       
   122 		CSIPConcreteProfile* profile = CloneProfileWithoutPasswordsLC( 
       
   123 			(CSIPConcreteProfile*) iSIPProfiles[i] );
       
   124 
       
   125 		profile->ExternalizeL(aWriteStream);
       
   126 		CleanupStack::PopAndDestroy(profile);
       
   127 		}
       
   128 	}
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CSIPConcreteProfileHolder::ExternalizedSizeL
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C TUint CSIPConcreteProfileHolder::ExternalizedSizeL() const
       
   135 	{
       
   136 	TUint size = 4;
       
   137 	for (TInt i = 0; i < iSIPProfiles.Count(); i++) 
       
   138 		{
       
   139 		CSIPConcreteProfile* profile = CloneProfileWithoutPasswordsLC( 
       
   140 			(CSIPConcreteProfile*) iSIPProfiles[i] );
       
   141 
       
   142 		size = size + profile->ExternalizedSizeL();
       
   143 		CleanupStack::PopAndDestroy(profile);
       
   144 		}
       
   145 	return size;
       
   146 	}
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CSIPConcreteProfileHolder::DoInternalizeL
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CSIPConcreteProfileHolder::DoInternalizeL(RReadStream& aReadStream)
       
   153 	{
       
   154 	iInternalized = ETrue;
       
   155 	TUint count = aReadStream.ReadUint32L();
       
   156 	for (TUint i = 0; i < count; i++) 
       
   157 		{
       
   158 		CSIPConcreteProfile* profile = 
       
   159 		    CSIPConcreteProfile::InternalizeL(aReadStream);
       
   160 		CleanupStack::PushL(profile);
       
   161 		iSIPProfiles.AppendL(profile);
       
   162 		CleanupStack::Pop(profile);
       
   163 		}
       
   164 	}
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CSIPConcreteProfileHolder::CloneProfileWithoutPasswordsLC
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 CSIPConcreteProfile* CSIPConcreteProfileHolder::CloneProfileWithoutPasswordsLC(
       
   171 		const CSIPConcreteProfile* aProfile)
       
   172 	{
       
   173 	CSIPConcreteProfile* clonedProfile = 
       
   174 		aProfile->CloneWithDynamicValuesL();
       
   175 	
       
   176 	// Remove passwords from copied profile
       
   177 	CleanupStack::PushL(clonedProfile);
       
   178 	clonedProfile->SetServerParameterL(
       
   179 		KSIPOutboundProxy, KSIPDigestPassword, KNullDesC8 );
       
   180 	clonedProfile->SetServerParameterL( 
       
   181 		KSIPRegistrar, KSIPDigestPassword, KNullDesC8 );	
       
   182 
       
   183 	return clonedProfile;
       
   184 	}