|
1 // Copyright (c) 2004-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 : SIPHeaderLookup.cpp |
|
15 // Part of : Codec |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "SIPHeaderLookup.h" |
|
23 #include "CSIPCodecTlsPtrs.h" |
|
24 #include "CSIPHeaderLookupTable.h" |
|
25 #include "_sipcodecdefs.h" |
|
26 |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // SIPHeaderLookup::OpenL |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 EXPORT_C void SIPHeaderLookup::OpenL() |
|
33 { |
|
34 CSIPCodecTlsPtrs* tlsPtrs = static_cast<CSIPCodecTlsPtrs*>( Dll::Tls() ); |
|
35 // If SIPStrings has not created the tls-pointer, |
|
36 // the string pool has not been opened and header lookup cannot be used. |
|
37 __ASSERT_ALWAYS( tlsPtrs, User::Leave ( KErrNotReady ) ); |
|
38 |
|
39 CSIPHeaderLookupTable* lookup = tlsPtrs->iHeaderLookup; |
|
40 if( lookup ) |
|
41 { |
|
42 lookup->IncrementUsageCount(); |
|
43 } |
|
44 else |
|
45 { |
|
46 tlsPtrs->iHeaderLookup = CSIPHeaderLookupTable::NewL(); |
|
47 } |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // SIPHeaderLookup::Close |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C void SIPHeaderLookup::Close() |
|
55 { |
|
56 CSIPCodecTlsPtrs* tlsPtrs = static_cast<CSIPCodecTlsPtrs*>( Dll::Tls() ); |
|
57 if ( !tlsPtrs || !tlsPtrs->iHeaderLookup ) |
|
58 { |
|
59 return; |
|
60 } |
|
61 |
|
62 CSIPHeaderLookupTable* lookup = tlsPtrs->iHeaderLookup; |
|
63 lookup->DecrementUsageCount(); |
|
64 if ( !tlsPtrs->iStrings ) |
|
65 { |
|
66 if( lookup->UsageCount() == 0 ) |
|
67 { |
|
68 delete tlsPtrs; |
|
69 Dll::FreeTls(); |
|
70 } |
|
71 } |
|
72 else |
|
73 { |
|
74 if( lookup->UsageCount() == 0 ) |
|
75 { |
|
76 tlsPtrs->DestroyHeaderLookup(); |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // SIPHeaderLookup::IsSupportedL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C TBool SIPHeaderLookup::IsSupported(RStringF aHeaderName) |
|
86 { |
|
87 return LookupTable()->IsSupported(aHeaderName); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // SIPHeaderLookup::InternalizeL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C CSIPHeaderBase* |
|
95 SIPHeaderLookup::InternalizeL(RStringF aName,RReadStream& aReadStream) |
|
96 { |
|
97 return LookupTable()->InternalizeL(aName,aReadStream); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // SIPHeaderLookup::IsAPIHeaderL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C TBool SIPHeaderLookup::IsAPIHeader(RStringF aName) |
|
105 { |
|
106 // The headers that support serialization and |
|
107 // are supported as non-extension headers are API headers. |
|
108 return LookupTable()->InternalizeSupported(aName); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // SIPHeaderLookup::CreateHeaderL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C RPointerArray<CSIPHeaderBase> |
|
116 SIPHeaderLookup::CreateHeaderL(RStringF aName,const TDesC8& aValue) |
|
117 { |
|
118 return LookupTable()->CreateHeaderL(aName,aValue); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // SIPHeaderLookup::LookupTable |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 CSIPHeaderLookupTable* SIPHeaderLookup::LookupTable() |
|
126 { |
|
127 CSIPCodecTlsPtrs* tlsPtrs = static_cast<CSIPCodecTlsPtrs*>( Dll::Tls() ); |
|
128 __ASSERT_ALWAYS( tlsPtrs, User::Panic( KNullDesC, KErrNotReady ) ); |
|
129 |
|
130 CSIPHeaderLookupTable* lookup = tlsPtrs->iHeaderLookup; |
|
131 __ASSERT_ALWAYS( lookup, User::Panic( KNullDesC, KErrNotReady ) ); |
|
132 |
|
133 return lookup; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // SIPHeaderLookup::SetConvertToSIPURI |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C void SIPHeaderLookup::SetConvertToSIPURI(TBool aValue) |
|
141 { |
|
142 LookupTable()->SetConvertToSIPURI(aValue); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // SIPHeaderLookup::ConvertToSIPURI |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TBool SIPHeaderLookup::ConvertToSIPURI() |
|
150 { |
|
151 return LookupTable()->ConvertToSIPURI(); |
|
152 } |