|
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 : SigCompCompartment.cpp |
|
15 // Part of : SigComp |
|
16 // SigComp API frontend |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "Sigcomp.h" |
|
24 #include "Compressor.h" |
|
25 #include "sigcompstateitem.h" |
|
26 #include "StateMgr.h" |
|
27 #include "SigCompCompartmentStatesHolder.h" |
|
28 #include "SigCompCompressionContext.h" |
|
29 #include "sigcompcompartment.h" |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS ============================== |
|
32 |
|
33 CSigCompCompartment::CSigCompCompartment() |
|
34 { |
|
35 } |
|
36 |
|
37 void CSigCompCompartment::ConstructL(const CSigComp& aSigComp, |
|
38 TBool aDynamicCompression) |
|
39 { |
|
40 |
|
41 ConstructL(aSigComp, aSigComp.StateMemorySize(), aDynamicCompression); |
|
42 } |
|
43 |
|
44 void CSigCompCompartment::ConstructL(const CSigComp& aSigComp, |
|
45 CSigComp::TMemorySize aStateMemorySize, |
|
46 TBool aDynamicCompression) |
|
47 { |
|
48 |
|
49 iSigComp = &aSigComp; |
|
50 iStateMemorySize = aStateMemorySize; |
|
51 iDynamicCompression = aDynamicCompression; |
|
52 |
|
53 if(aDynamicCompression) |
|
54 { |
|
55 CSigCompCompressor* ci = const_cast<CSigCompCompressor*>( |
|
56 iSigComp->Compressor()); |
|
57 if(!ci->IsDynamicCompressionSupported()) |
|
58 { |
|
59 User::Leave(KErrNotSupported); |
|
60 } |
|
61 } |
|
62 |
|
63 iStateMgr = const_cast<CStateMgr*>(aSigComp.StateMgr()); |
|
64 iStatesHolder = new (ELeave)CSigCompCompartmentStatesHolder(*iStateMgr, |
|
65 iStateMemorySize); |
|
66 iReturnedFeedback = HBufC8::NewL(0); |
|
67 iRequestedFeedback = HBufC8::NewL(0); |
|
68 iReturnedParameters = HBufC8::NewL(0); |
|
69 } |
|
70 |
|
71 EXPORT_C CSigCompCompartment* CSigCompCompartment::NewL( |
|
72 const CSigComp& aSigComp, |
|
73 TBool aDynamicCompression) |
|
74 { |
|
75 CSigCompCompartment* self = NewLC(aSigComp, aDynamicCompression); |
|
76 CleanupStack::Pop(); |
|
77 |
|
78 return self; |
|
79 } |
|
80 |
|
81 EXPORT_C CSigCompCompartment* CSigCompCompartment::NewL( |
|
82 const CSigComp& aSigComp, |
|
83 CSigComp::TMemorySize aStateMemorySize, |
|
84 TBool aDynamicCompression) |
|
85 { |
|
86 |
|
87 CSigCompCompartment* self = NewLC(aSigComp, |
|
88 aStateMemorySize, |
|
89 aDynamicCompression); |
|
90 CleanupStack::Pop(); |
|
91 |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 EXPORT_C CSigCompCompartment* CSigCompCompartment::NewLC( |
|
97 const CSigComp& aSigComp, |
|
98 TBool aDynamicCompression) |
|
99 { |
|
100 CSigCompCompartment* self = new (ELeave)CSigCompCompartment; |
|
101 |
|
102 CleanupStack::PushL(self); |
|
103 self->ConstructL(aSigComp, aDynamicCompression); |
|
104 |
|
105 return self; |
|
106 } |
|
107 |
|
108 EXPORT_C CSigCompCompartment* CSigCompCompartment::NewLC( |
|
109 const CSigComp& aSigComp, |
|
110 CSigComp::TMemorySize aStateMemorySize, |
|
111 TBool aDynamicCompression) |
|
112 { |
|
113 CSigCompCompartment* self = new (ELeave)CSigCompCompartment; |
|
114 |
|
115 CleanupStack::PushL(self); |
|
116 self->ConstructL(aSigComp, aStateMemorySize, aDynamicCompression); |
|
117 |
|
118 return self; |
|
119 } |
|
120 |
|
121 |
|
122 // Destructor |
|
123 EXPORT_C CSigCompCompartment::~CSigCompCompartment() |
|
124 { |
|
125 |
|
126 delete iCompressionContext; |
|
127 |
|
128 delete iStatesHolder; |
|
129 |
|
130 delete iReturnedFeedback; |
|
131 delete iRequestedFeedback; |
|
132 delete iReturnedParameters; |
|
133 } |
|
134 |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CSigCompCompartment::CompressL |
|
138 // |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 |
|
142 EXPORT_C CBufBase* CSigCompCompartment::CompressL(const TDesC8& aMessage, |
|
143 TBool aForStreamBasedProtocol) |
|
144 { |
|
145 CSigCompCompressor* compressor = const_cast<CSigCompCompressor*>( |
|
146 iSigComp->Compressor()); |
|
147 |
|
148 CBufBase* msg = compressor->CompressMessageL(this, aMessage, |
|
149 aForStreamBasedProtocol); |
|
150 return msg; |
|
151 } |
|
152 |
|
153 |
|
154 // ---------------------------------------------------------------------------- |
|
155 // CSigCompCompartment::SetReturnedFeedbackL |
|
156 // set returned feedback in compartment |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 |
|
160 void CSigCompCompartment::SetReturnedFeedbackL(const TDesC8& aReturnedFeedback) |
|
161 { |
|
162 |
|
163 delete iReturnedFeedback; |
|
164 iReturnedFeedback = NULL; |
|
165 iReturnedFeedback = aReturnedFeedback.AllocL(); |
|
166 } |
|
167 |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CSigCompCompartment::SetRequestedFeedbackL |
|
171 // set requested feedback in compartment |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 |
|
175 void CSigCompCompartment::SetRequestedFeedbackL( |
|
176 const TDesC8& aRequestedFeedback) |
|
177 { |
|
178 |
|
179 delete iRequestedFeedback; |
|
180 iRequestedFeedback = NULL; |
|
181 iRequestedFeedback = aRequestedFeedback.AllocL(); |
|
182 } |
|
183 |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CSigCompCompartment::SetReturnedParametersL |
|
187 // set returned parameters in compartment |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 |
|
191 void CSigCompCompartment::SetReturnedParametersL( |
|
192 const TDesC8& aReturnedParameters) |
|
193 { |
|
194 |
|
195 delete iReturnedParameters; |
|
196 iReturnedParameters = NULL; |
|
197 iReturnedParameters = aReturnedParameters.AllocL(); |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // CSigCompCompartment::StateMemorySize |
|
202 // get state memory size |
|
203 // ---------------------------------------------------------------------------- |
|
204 // |
|
205 |
|
206 CSigComp::TMemorySize CSigCompCompartment::StateMemorySize() const |
|
207 { |
|
208 return iStateMemorySize; |
|
209 }; |
|
210 |
|
211 |
|
212 // ---------------------------------------------------------------------------- |
|
213 // CSigCompCompartment::ReturnedFeedback |
|
214 // get returned feedback from compartment |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 |
|
218 #if defined(SIGCOMP_DEBUG) |
|
219 EXPORT_C |
|
220 #endif |
|
221 const TDesC8& CSigCompCompartment::ReturnedFeedback() const |
|
222 { |
|
223 return *iReturnedFeedback; |
|
224 } |
|
225 |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // CSigCompCompartment::RequestedFeedback |
|
229 // set requested feedback in compartment |
|
230 // ---------------------------------------------------------------------------- |
|
231 // |
|
232 |
|
233 #if defined(SIGCOMP_DEBUG) |
|
234 EXPORT_C |
|
235 #endif |
|
236 const TDesC8& CSigCompCompartment::RequestedFeedback() const |
|
237 { |
|
238 return *iRequestedFeedback; |
|
239 } |
|
240 |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CSigCompCompartment::ReturnedParameters |
|
244 // get returned parameters from compartment |
|
245 // ---------------------------------------------------------------------------- |
|
246 // |
|
247 |
|
248 #if defined(SIGCOMP_DEBUG) |
|
249 EXPORT_C |
|
250 #endif |
|
251 const TDesC8& CSigCompCompartment::ReturnedParameters() const |
|
252 { |
|
253 return *iReturnedParameters; |
|
254 } |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // CSigCompCompartment::StatesHolder |
|
258 // get states holder |
|
259 // ---------------------------------------------------------------------------- |
|
260 // |
|
261 |
|
262 const CSigCompCompartmentStatesHolder* |
|
263 CSigCompCompartment::StatesHolder() const |
|
264 { |
|
265 return iStatesHolder; |
|
266 } |
|
267 |
|
268 const CSigCompCompressionContext* |
|
269 CSigCompCompartment::CompressionContext() const |
|
270 { |
|
271 return iCompressionContext; |
|
272 } |
|
273 |
|
274 void CSigCompCompartment::SetCompressionContext( |
|
275 CSigCompCompressionContext* aContext) |
|
276 { |
|
277 iCompressionContext = aContext; |
|
278 } |
|
279 |
|
280 TBool CSigCompCompartment::IsDynamicCompression() const |
|
281 { |
|
282 return iDynamicCompression; |
|
283 } |
|
284 |
|
285 CSigComp::TCyclesPerBit CSigCompCompartment::CyclesPerBit() const |
|
286 { |
|
287 return iSigComp->CyclesPerBit(); |
|
288 } |
|
289 |
|
290 |
|
291 CSigComp::TMemorySize CSigCompCompartment::DecompressionMemorySize() const |
|
292 { |
|
293 return iSigComp->DecompressionMemorySize(); |
|
294 } |