1 /* |
|
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation of RCmConnectionMethodExt. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <cmconnectionmethodext.h> |
|
21 #include <cmdestinationext.h> |
|
22 |
|
23 #include "cmmserverdefs.h" |
|
24 #include "cmmanagerapi.h" |
|
25 #include "cmdestinationwrapper.h" |
|
26 #include "cmconnectionmethodwrapper.h" |
|
27 |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "cmconnectionmethodextTraces.h" |
|
31 #endif |
|
32 |
|
33 |
|
34 //----------------------------------------------------------------------------- |
|
35 // RCmConnectionMethodExt::RCmConnectionMethodExt() |
|
36 //----------------------------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C RCmConnectionMethodExt::RCmConnectionMethodExt( |
|
39 const RCmConnectionMethodExt& aConnMethod ) |
|
40 { |
|
41 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_ENTRY ); |
|
42 |
|
43 this->iCmConnectionMethodWrapper = aConnMethod.iCmConnectionMethodWrapper; |
|
44 if ( iCmConnectionMethodWrapper ) |
|
45 { |
|
46 iCmConnectionMethodWrapper->IncreaseReferenceCounter(); |
|
47 } |
|
48 |
|
49 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_EXIT ); |
|
50 } |
|
51 |
|
52 //----------------------------------------------------------------------------- |
|
53 // RCmConnectionMethodExt::Close() |
|
54 //----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C void RCmConnectionMethodExt::Close() |
|
57 { |
|
58 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_CLOSE_ENTRY ); |
|
59 |
|
60 if ( iCmConnectionMethodWrapper ) |
|
61 { |
|
62 if ( iCmConnectionMethodWrapper->DecreaseReferenceCounter() <= 0 ) |
|
63 { |
|
64 delete iCmConnectionMethodWrapper; |
|
65 } |
|
66 iCmConnectionMethodWrapper = NULL; |
|
67 } |
|
68 |
|
69 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_CLOSE_EXIT ); |
|
70 } |
|
71 |
|
72 //----------------------------------------------------------------------------- |
|
73 // RCmConnectionMethodExt::~RCmConnectionMethodExt() |
|
74 //----------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C RCmConnectionMethodExt::~RCmConnectionMethodExt() |
|
77 { |
|
78 OstTraceFunctionEntry0( DUP2_RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_ENTRY ); |
|
79 Close(); |
|
80 OstTraceFunctionExit0( DUP2_RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_EXIT ); |
|
81 } |
|
82 |
|
83 //----------------------------------------------------------------------------- |
|
84 // RCmConnectionMethodExt::CreateCopyL() |
|
85 //----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C RCmConnectionMethodExt RCmConnectionMethodExt::CreateCopyL() |
|
88 { |
|
89 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_CREATECOPYL_ENTRY ); |
|
90 |
|
91 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
92 { |
|
93 User::Leave( KErrBadHandle ); |
|
94 } |
|
95 |
|
96 TInt connMethodHandle = iCmConnectionMethodWrapper->GetHandle(); |
|
97 CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC(); |
|
98 |
|
99 TInt err = cmWrapper->CreateConnMethodCopy( |
|
100 iCmConnectionMethodWrapper->GetMainSession(), |
|
101 connMethodHandle ); |
|
102 User::LeaveIfError( err ); |
|
103 CleanupStack::Pop( cmWrapper ); |
|
104 |
|
105 RCmConnectionMethodExt cm; |
|
106 cm.iCmConnectionMethodWrapper = cmWrapper; |
|
107 |
|
108 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_CREATECOPYL_EXIT ); |
|
109 return cm; |
|
110 } |
|
111 |
|
112 //----------------------------------------------------------------------------- |
|
113 // RCmConnectionMethodExt::GetIntAttributeL() |
|
114 //----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C TUint32 RCmConnectionMethodExt::GetIntAttributeL( |
|
117 TUint32 aAttribute ) const |
|
118 { |
|
119 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_GETINTATTRIBUTEL_ENTRY ); |
|
120 |
|
121 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
122 { |
|
123 User::Leave( KErrBadHandle ); |
|
124 } |
|
125 |
|
126 TUint32 value( 0 ); |
|
127 TInt err = iCmConnectionMethodWrapper->GetIntAttribute( aAttribute, value ); |
|
128 User::LeaveIfError( err ); |
|
129 |
|
130 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_GETINTATTRIBUTEL_EXIT ); |
|
131 return value; |
|
132 } |
|
133 |
|
134 //----------------------------------------------------------------------------- |
|
135 // RCmConnectionMethodExt::GetBoolAttributeL() |
|
136 //----------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C TBool RCmConnectionMethodExt::GetBoolAttributeL( |
|
139 TUint32 aAttribute ) const |
|
140 { |
|
141 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_GETBOOLATTRIBUTEL_ENTRY ); |
|
142 |
|
143 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
144 { |
|
145 User::Leave( KErrBadHandle ); |
|
146 } |
|
147 |
|
148 TBool value( 0 ); |
|
149 TInt err = iCmConnectionMethodWrapper->GetBoolAttribute( aAttribute, value ); |
|
150 User::LeaveIfError( err ); |
|
151 |
|
152 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_GETBOOLATTRIBUTEL_EXIT ); |
|
153 return value; |
|
154 } |
|
155 |
|
156 //----------------------------------------------------------------------------- |
|
157 // RCmConnectionMethodExt::GetStringAttributeL() |
|
158 //----------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C HBufC* RCmConnectionMethodExt::GetStringAttributeL( |
|
161 TUint32 aAttribute ) const |
|
162 { |
|
163 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_GETSTRINGATTRIBUTEL_ENTRY ); |
|
164 |
|
165 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
166 { |
|
167 User::Leave( KErrBadHandle ); |
|
168 } |
|
169 |
|
170 HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax ); |
|
171 TInt err = iCmConnectionMethodWrapper->GetStringAttribute( aAttribute, buffer ); |
|
172 User::LeaveIfError( err ); |
|
173 |
|
174 if ( buffer->Length() > 0 ) |
|
175 { |
|
176 CleanupStack::Pop( buffer ); |
|
177 } |
|
178 else |
|
179 { |
|
180 CleanupStack::PopAndDestroy( buffer ); |
|
181 buffer = NULL; |
|
182 buffer = KNullDesC().AllocL(); |
|
183 } |
|
184 |
|
185 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_GETSTRINGATTRIBUTEL_EXIT ); |
|
186 return buffer; |
|
187 } |
|
188 |
|
189 //----------------------------------------------------------------------------- |
|
190 // RCmConnectionMethodExt::GetString8AttributeL() |
|
191 //----------------------------------------------------------------------------- |
|
192 // |
|
193 EXPORT_C HBufC8* RCmConnectionMethodExt::GetString8AttributeL( |
|
194 TUint32 aAttribute ) const |
|
195 { |
|
196 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_GETSTRING8ATTRIBUTEL_ENTRY ); |
|
197 |
|
198 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
199 { |
|
200 User::Leave( KErrBadHandle ); |
|
201 } |
|
202 |
|
203 HBufC8* buffer8 = HBufC8::NewLC( KCmmStringLengthMax ); |
|
204 TInt err = iCmConnectionMethodWrapper->GetString8Attribute( aAttribute, buffer8 ); |
|
205 User::LeaveIfError( err ); |
|
206 |
|
207 if ( buffer8->Length() > 0 ) |
|
208 { |
|
209 CleanupStack::Pop( buffer8 ); |
|
210 } |
|
211 else |
|
212 { |
|
213 CleanupStack::PopAndDestroy( buffer8 ); |
|
214 buffer8 = NULL; |
|
215 buffer8 = KNullDesC8().AllocL(); |
|
216 } |
|
217 |
|
218 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_GETSTRING8ATTRIBUTEL_EXIT ); |
|
219 return buffer8; |
|
220 } |
|
221 |
|
222 //----------------------------------------------------------------------------- |
|
223 // RCmConnectionMethodExt::SetIntAttributeL() |
|
224 //----------------------------------------------------------------------------- |
|
225 // |
|
226 EXPORT_C void RCmConnectionMethodExt::SetIntAttributeL( |
|
227 TUint32 aAttribute, |
|
228 TUint32 aValue ) |
|
229 { |
|
230 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_SETINTATTRIBUTEL_ENTRY ); |
|
231 |
|
232 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
233 { |
|
234 User::Leave( KErrBadHandle ); |
|
235 } |
|
236 |
|
237 TInt err = iCmConnectionMethodWrapper->SetIntAttribute( aAttribute, aValue ); |
|
238 User::LeaveIfError( err ); |
|
239 |
|
240 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_SETINTATTRIBUTEL_EXIT ); |
|
241 } |
|
242 |
|
243 //----------------------------------------------------------------------------- |
|
244 // RCmConnectionMethodExt::SetBoolAttributeL() |
|
245 //----------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void RCmConnectionMethodExt::SetBoolAttributeL( |
|
248 TUint32 aAttribute, |
|
249 TBool aValue ) |
|
250 { |
|
251 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_SETBOOLATTRIBUTEL_ENTRY ); |
|
252 |
|
253 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
254 { |
|
255 User::Leave( KErrBadHandle ); |
|
256 } |
|
257 |
|
258 TInt err = iCmConnectionMethodWrapper->SetBoolAttribute( aAttribute, aValue ); |
|
259 User::LeaveIfError( err ); |
|
260 |
|
261 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_SETBOOLATTRIBUTEL_EXIT ); |
|
262 } |
|
263 |
|
264 //----------------------------------------------------------------------------- |
|
265 // RCmConnectionMethodExt::SetStringAttributeL() |
|
266 //----------------------------------------------------------------------------- |
|
267 // |
|
268 EXPORT_C void RCmConnectionMethodExt::SetStringAttributeL( |
|
269 TUint32 aAttribute, |
|
270 const TDesC16& aValue ) |
|
271 { |
|
272 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_SETSTRINGATTRIBUTEL_ENTRY ); |
|
273 |
|
274 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
275 { |
|
276 User::Leave( KErrBadHandle ); |
|
277 } |
|
278 |
|
279 TInt err = iCmConnectionMethodWrapper->SetStringAttribute( aAttribute, aValue ); |
|
280 User::LeaveIfError( err ); |
|
281 |
|
282 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_SETSTRINGATTRIBUTEL_EXIT ); |
|
283 } |
|
284 |
|
285 //----------------------------------------------------------------------------- |
|
286 // RCmConnectionMethodExt::SetString8AttributeL() |
|
287 //----------------------------------------------------------------------------- |
|
288 // |
|
289 EXPORT_C void RCmConnectionMethodExt::SetString8AttributeL( |
|
290 TUint32 aAttribute, |
|
291 const TDesC8& aValue ) |
|
292 { |
|
293 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_SETSTRING8ATTRIBUTEL_ENTRY ); |
|
294 |
|
295 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
296 { |
|
297 User::Leave( KErrBadHandle ); |
|
298 } |
|
299 |
|
300 TInt err = iCmConnectionMethodWrapper->SetString8Attribute( aAttribute, aValue ); |
|
301 User::LeaveIfError( err ); |
|
302 |
|
303 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_SETSTRING8ATTRIBUTEL_EXIT ); |
|
304 } |
|
305 |
|
306 //----------------------------------------------------------------------------- |
|
307 // RCmConnectionMethodExt::UpdateL() |
|
308 //----------------------------------------------------------------------------- |
|
309 // |
|
310 EXPORT_C void RCmConnectionMethodExt::UpdateL() |
|
311 { |
|
312 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_UPDATEL_ENTRY ); |
|
313 |
|
314 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
315 { |
|
316 User::Leave( KErrBadHandle ); |
|
317 } |
|
318 |
|
319 TInt err = iCmConnectionMethodWrapper->Update(); |
|
320 User::LeaveIfError( err ); |
|
321 |
|
322 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_UPDATEL_EXIT ); |
|
323 } |
|
324 |
|
325 //----------------------------------------------------------------------------- |
|
326 // RCmConnectionMethodExt::DeleteL() |
|
327 //----------------------------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C TBool RCmConnectionMethodExt::DeleteL() |
|
330 { |
|
331 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_DELETEL_ENTRY ); |
|
332 |
|
333 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
334 { |
|
335 User::Leave( KErrBadHandle ); |
|
336 } |
|
337 |
|
338 TBool result( ETrue ); |
|
339 TInt err = iCmConnectionMethodWrapper->Delete( result ); |
|
340 User::LeaveIfError( err ); |
|
341 |
|
342 delete iCmConnectionMethodWrapper; |
|
343 iCmConnectionMethodWrapper = NULL; |
|
344 |
|
345 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_DELETEL_EXIT ); |
|
346 return result; |
|
347 } |
|
348 |
|
349 //----------------------------------------------------------------------------- |
|
350 // RCmConnectionMethodExt::DestinationL() |
|
351 //----------------------------------------------------------------------------- |
|
352 // |
|
353 EXPORT_C RCmDestinationExt RCmConnectionMethodExt::DestinationL() const |
|
354 { |
|
355 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_DESTINATIONL_ENTRY ); |
|
356 |
|
357 if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() ) |
|
358 { |
|
359 User::Leave( KErrBadHandle ); |
|
360 } |
|
361 |
|
362 // If client already has a handle open to this destination, give a |
|
363 // reference to it. |
|
364 CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC(); |
|
365 TInt connMethodHandle = iCmConnectionMethodWrapper->GetHandle(); |
|
366 TInt existingHandle( 0 ); |
|
367 destWrap->GetConnMethodAsEmbeddedDestL( |
|
368 iCmConnectionMethodWrapper->GetMainSession(), |
|
369 connMethodHandle, |
|
370 existingHandle ); |
|
371 if ( existingHandle ) |
|
372 { |
|
373 CleanupStack::PopAndDestroy( destWrap ); |
|
374 destWrap = iCmConnectionMethodWrapper->GetMainSession()->GetDestinationWrapperL( |
|
375 existingHandle ); |
|
376 destWrap->IncreaseReferenceCounter(); |
|
377 } |
|
378 else |
|
379 { |
|
380 CleanupStack::Pop( destWrap ); |
|
381 } |
|
382 |
|
383 RCmDestinationExt dest; |
|
384 dest.iCmDestinationWrapper = destWrap; |
|
385 |
|
386 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_DESTINATIONL_EXIT ); |
|
387 return dest; |
|
388 } |
|
389 |
|
390 //-------------------------------------------------------------------------- |
|
391 // RCmConnectionMethodExt::RCmConnectionMethodExt() |
|
392 //-------------------------------------------------------------------------- |
|
393 // |
|
394 EXPORT_C RCmConnectionMethodExt::RCmConnectionMethodExt() : iCmConnectionMethodWrapper( NULL ) |
|
395 { |
|
396 OstTraceFunctionEntry0( DUP1_RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_ENTRY ); |
|
397 OstTraceFunctionExit0( DUP1_RCMCONNECTIONMETHODEXT_RCMCONNECTIONMETHODEXT_EXIT ); |
|
398 } |
|
399 |
|
400 //----------------------------------------------------------------------------- |
|
401 // RCmConnectionMethodExt::operator=() |
|
402 //----------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C RCmConnectionMethodExt& RCmConnectionMethodExt::operator=( |
|
405 const RCmConnectionMethodExt& aConnMethod ) |
|
406 { |
|
407 OstTraceFunctionEntry0( RCMCONNECTIONMETHODEXT_OPERATOR_ENTRY ); |
|
408 |
|
409 if ( this != &aConnMethod ) |
|
410 { |
|
411 Close(); |
|
412 this->iCmConnectionMethodWrapper = aConnMethod.iCmConnectionMethodWrapper; |
|
413 if ( iCmConnectionMethodWrapper ) |
|
414 { |
|
415 iCmConnectionMethodWrapper->IncreaseReferenceCounter(); |
|
416 } |
|
417 } |
|
418 |
|
419 OstTraceFunctionExit0( RCMCONNECTIONMETHODEXT_OPERATOR_EXIT ); |
|
420 return *this; |
|
421 } |
|
422 |
|
423 //-------------------------------------------------------------------------- |
|
424 // RCmConnectionMethodExt::operator==() |
|
425 //-------------------------------------------------------------------------- |
|
426 // |
|
427 EXPORT_C TBool RCmConnectionMethodExt::operator==( RCmConnectionMethodExt& aConnMethod ) const |
|
428 { |
|
429 OstTraceFunctionEntry0( DUP1_RCMCONNECTIONMETHODEXT_OPERATOR_ENTRY ); |
|
430 |
|
431 TBool result( EFalse ); |
|
432 if ( !aConnMethod.iCmConnectionMethodWrapper ) |
|
433 { |
|
434 if ( !iCmConnectionMethodWrapper ) |
|
435 { |
|
436 result = ETrue; // Both empty |
|
437 } |
|
438 else |
|
439 { |
|
440 result = EFalse; |
|
441 } |
|
442 } |
|
443 else if ( !iCmConnectionMethodWrapper ) |
|
444 { |
|
445 result = EFalse; |
|
446 } |
|
447 else |
|
448 { |
|
449 // Both connection method objects have wrappers. |
|
450 |
|
451 if ( !iCmConnectionMethodWrapper->SessionConnected() || |
|
452 !aConnMethod.iCmConnectionMethodWrapper->SessionConnected() ) |
|
453 { |
|
454 result = EFalse; |
|
455 } |
|
456 else |
|
457 { |
|
458 // Both connection method objects are connected to server. |
|
459 |
|
460 TInt handle = aConnMethod.iCmConnectionMethodWrapper->GetHandle(); |
|
461 TInt err = iCmConnectionMethodWrapper->IsEqual( handle, result ); |
|
462 |
|
463 if ( err ) |
|
464 { |
|
465 result = EFalse; |
|
466 } |
|
467 } |
|
468 } |
|
469 |
|
470 OstTraceFunctionExit0( DUP1_RCMCONNECTIONMETHODEXT_OPERATOR_EXIT ); |
|
471 return result; |
|
472 } |
|
473 |
|
474 //-------------------------------------------------------------------------- |
|
475 // |
|
476 //-------------------------------------------------------------------------- |
|
477 // |
|
478 EXPORT_C TBool RCmConnectionMethodExt::operator!=( RCmConnectionMethodExt& aConnMethod ) const |
|
479 { |
|
480 OstTraceFunctionEntry0( DUP2_RCMCONNECTIONMETHODEXT_OPERATOR_ENTRY ); |
|
481 |
|
482 TBool result = !( operator==( aConnMethod ) ); |
|
483 |
|
484 OstTraceFunctionExit0( DUP2_RCMCONNECTIONMETHODEXT_OPERATOR_EXIT ); |
|
485 return result; |
|
486 } |
|
487 |
|
488 // End of file |
|