|
1 // Copyright (c) 2006-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 : ctlscache.cpp |
|
15 // Part of : SIPSec TLS Plugin |
|
16 // Version : %version: 2.1.1 % |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "MSIPTransportMgr.h" |
|
22 #include "ctlscache.h" |
|
23 #include "ctlsentry.h" |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CTLSCache::NewL |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CTLSCache* CTLSCache::NewL() |
|
30 { |
|
31 return new ( ELeave ) CTLSCache(); |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTLSCache::CTLSCache |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CTLSCache::CTLSCache() |
|
39 #ifdef CPPUNIT_TEST |
|
40 : iEntries( 1 ) |
|
41 #endif |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CTLSCache::~CTLSCache |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CTLSCache::~CTLSCache() |
|
50 { |
|
51 iEntries.ResetAndDestroy(); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CTLSCache::AddEntryL |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CTLSCache::AddEntryL( const TInetAddr& aNextHop, |
|
59 TUint32 aTransportId, |
|
60 const MSIPSecUser& aSIPSecUser ) |
|
61 { |
|
62 __ASSERT_DEBUG( !SearchByNextHop( aNextHop ), |
|
63 User::Leave( KErrAlreadyExists ) ); |
|
64 |
|
65 CTLSEntry* entry = CTLSEntry::NewLC( aNextHop, aTransportId, aSIPSecUser ); |
|
66 iEntries.AppendL( entry ); |
|
67 CleanupStack::Pop( entry ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CTLSCache::SearchByNextHop |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CTLSEntry* CTLSCache::SearchByNextHop( const TInetAddr& aNextHop ) const |
|
75 { |
|
76 for ( TInt i = 0; i < iEntries.Count(); ++i ) |
|
77 { |
|
78 if ( iEntries[ i ]->CompareNextHop( aNextHop ) ) |
|
79 { |
|
80 return iEntries[ i ]; |
|
81 } |
|
82 } |
|
83 |
|
84 return NULL; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CTLSCache::RemoveSIPSecUser |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CTLSCache::RemoveSIPSecUser( MSIPTransportMgr& aTransportMgr, |
|
92 const MSIPSecUser& aSIPSecUser ) |
|
93 { |
|
94 CTLSEntry* entry = NULL; |
|
95 for ( TInt i = iEntries.Count(); i > 0 ; --i ) |
|
96 { |
|
97 entry = iEntries[ i - 1 ]; |
|
98 if ( entry->CompareSIPSecUser( aSIPSecUser ) ) |
|
99 { |
|
100 aTransportMgr.RemoveTransport( entry->TransportId() ); |
|
101 iEntries.Remove( i - 1 ); |
|
102 delete entry; |
|
103 iEntries.Compress(); |
|
104 } |
|
105 } |
|
106 } |