|
1 /* |
|
2 * Copyright (c) 2009-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 * Handles client requests. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <cmconnectionmethoddef.h> |
|
21 #include <cmpluginembdestinationdef.h> |
|
22 #include <cmdefconnvalues.h> |
|
23 |
|
24 #include "cmmserver.h" |
|
25 #include "cmmserverdefs.h" |
|
26 #include "cmmsession.h" |
|
27 #include "cmmdestinationinstance.h" |
|
28 #include "cmmconnmethodinstance.h" |
|
29 |
|
30 #include "OstTraceDefinitions.h" |
|
31 #ifdef OST_TRACE_COMPILER_IN_USE |
|
32 #include "cmmsessionTraces.h" |
|
33 #endif |
|
34 |
|
35 |
|
36 CCmmSession* CCmmSession::NewL( CCmmServer& aServer, CCmmCache& aCache ) |
|
37 { |
|
38 OstTraceFunctionEntry0( CCMMSESSION_NEWL_ENTRY ); |
|
39 |
|
40 CCmmSession* self = CCmmSession::NewLC( aServer, aCache ); |
|
41 CleanupStack::Pop( self ); |
|
42 |
|
43 OstTraceFunctionExit0( CCMMSESSION_NEWL_EXIT ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 CCmmSession* CCmmSession::NewLC( CCmmServer& aServer, CCmmCache& aCache ) |
|
48 { |
|
49 OstTraceFunctionEntry0( CCMMSESSION_NEWLC_ENTRY ); |
|
50 |
|
51 CCmmSession* self = new( ELeave ) CCmmSession( aServer, aCache ); |
|
52 CleanupStack::PushL( self ) ; |
|
53 self->ConstructL() ; |
|
54 |
|
55 OstTraceFunctionExit0( CCMMSESSION_NEWLC_EXIT ); |
|
56 return self ; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // Constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CCmmSession::CCmmSession( CCmmServer& aServer, CCmmCache& aCache ) |
|
64 : |
|
65 iServer( aServer ), |
|
66 iCache( aCache ) |
|
67 { |
|
68 OstTraceFunctionEntry0( CCMMSESSION_CCMMSESSION_ENTRY ); |
|
69 |
|
70 iDestinationContainer = NULL; |
|
71 iDestinationObjects = NULL; |
|
72 iConnMethodContainer = NULL; |
|
73 iConnMethodObjects = NULL; |
|
74 |
|
75 OstTraceFunctionExit0( CCMMSESSION_CCMMSESSION_EXIT ); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // The second phase of two phase construction. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CCmmSession::ConstructL() |
|
83 { |
|
84 OstTraceFunctionEntry0( CCMMSESSION_CONSTRUCTL_ENTRY ); |
|
85 |
|
86 iServer.IncrementSessions(); |
|
87 |
|
88 // Create a new object index (it stores the destination objects owned by |
|
89 // this session). |
|
90 iDestinationObjects = CObjectIx::NewL(); |
|
91 |
|
92 // Initialize the object container using the object container index in the |
|
93 // server (Object container provides unique ids for the objects owned by |
|
94 // this session). |
|
95 iDestinationContainer = iServer.NewContainerL(); |
|
96 |
|
97 // The same for connection method subsessions. |
|
98 iConnMethodObjects = CObjectIx::NewL(); |
|
99 iConnMethodContainer = iServer.NewContainerL(); |
|
100 |
|
101 OstTraceFunctionExit0( CCMMSESSION_CONSTRUCTL_EXIT ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // Destructor. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CCmmSession::~CCmmSession() |
|
109 { |
|
110 OstTraceFunctionEntry0( DUP1_CCMMSESSION_CCMMSESSION_ENTRY ); |
|
111 |
|
112 iServer.DecrementSessions(); |
|
113 |
|
114 delete iDestinationObjects; |
|
115 iDestinationObjects = NULL; |
|
116 |
|
117 if ( iDestinationContainer != 0 ) |
|
118 { |
|
119 iServer.RemoveContainer( iDestinationContainer ); |
|
120 iDestinationContainer = NULL; |
|
121 } |
|
122 |
|
123 delete iConnMethodObjects; |
|
124 iConnMethodObjects = NULL; |
|
125 |
|
126 if ( iConnMethodContainer != 0 ) |
|
127 { |
|
128 iServer.RemoveContainer( iConnMethodContainer ); |
|
129 iConnMethodContainer = NULL; |
|
130 } |
|
131 OstTraceFunctionExit0( DUP1_CCMMSESSION_CCMMSESSION_EXIT ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCmmSession::ServiceL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CCmmSession::ServiceL( const RMessage2& aMessage ) |
|
139 { |
|
140 OstTraceFunctionEntry0( CCMMSESSION_SERVICEL_ENTRY ); |
|
141 |
|
142 TInt result( KErrNone ); |
|
143 switch ( aMessage.Function() ) |
|
144 { |
|
145 case ECmmGetBearerInfoInt: |
|
146 { |
|
147 GetBearerInfoIntL( aMessage ); |
|
148 } |
|
149 break; |
|
150 case ECmmGetBearerInfoBool: |
|
151 { |
|
152 GetBearerInfoBoolL( aMessage ); |
|
153 } |
|
154 break; |
|
155 case ECmmGetBearerInfoString: |
|
156 { |
|
157 GetBearerInfoStringL( aMessage ); |
|
158 } |
|
159 break; |
|
160 case ECmmGetBearerInfoString8: |
|
161 { |
|
162 GetBearerInfoString8L( aMessage ); |
|
163 } |
|
164 break; |
|
165 case ECmmGetConnMethodInfoInt: |
|
166 { |
|
167 GetConnMethodInfoIntL( aMessage ); |
|
168 } |
|
169 break; |
|
170 case ECmmGetConnMethodInfoBool: |
|
171 { |
|
172 GetConnMethodInfoBoolL( aMessage ); |
|
173 } |
|
174 break; |
|
175 case ECmmGetConnMethodInfoString: |
|
176 { |
|
177 GetConnMethodInfoStringL( aMessage ); |
|
178 } |
|
179 break; |
|
180 case ECmmGetConnMethodInfoString8: |
|
181 { |
|
182 GetConnMethodInfoString8L( aMessage ); |
|
183 } |
|
184 break; |
|
185 case ECmmGetConnMethodArray: |
|
186 { |
|
187 GetConnMethodArrayL( aMessage ); |
|
188 } |
|
189 break; |
|
190 case ECmmGetAllDestinations: |
|
191 { |
|
192 GetAllDestinationsL( aMessage ); |
|
193 } |
|
194 break; |
|
195 case ECmmGetEasyWlanId: |
|
196 { |
|
197 GetEasyWLANIdL( aMessage ); |
|
198 } |
|
199 break; |
|
200 case ECmmRemoveAllReferences: // CM becomes uncategorized. |
|
201 { |
|
202 RemoveAllReferencesL( aMessage ); |
|
203 } |
|
204 break; |
|
205 case ECmmGetSupportedBearers: |
|
206 { |
|
207 GetSupportedBearersL( aMessage ); |
|
208 } |
|
209 break; |
|
210 case ECmmReadDefaultConnection: |
|
211 { |
|
212 ReadDefaultConnectionL( aMessage ); |
|
213 } |
|
214 break; |
|
215 case ECmmWriteDefaultConnection: |
|
216 { |
|
217 // Default connection is now just internet snap. |
|
218 result = KErrNotSupported; |
|
219 } |
|
220 break; |
|
221 case ECmmReadGeneralConnectionSettings: |
|
222 { |
|
223 ReadGenConnSettingsL( aMessage ); |
|
224 } |
|
225 break; |
|
226 case ECmmWriteGeneralConnectionSettings: |
|
227 { |
|
228 WriteGenConnSettingsL( aMessage ); |
|
229 } |
|
230 break; |
|
231 case ECmmGetBearerPriorityArray: |
|
232 { |
|
233 GetBearerPriorityArrayL( aMessage ); |
|
234 } |
|
235 break; |
|
236 case ECmmUpdateBearerPriorityArray: |
|
237 { |
|
238 UpdateBearerPriorityArrayL( aMessage ); |
|
239 } |
|
240 break; |
|
241 case ECmmCopyConnMethod: |
|
242 { |
|
243 CopyConnMethodL( aMessage ); |
|
244 } |
|
245 break; |
|
246 case ECmmMoveConnMethod: |
|
247 { |
|
248 MoveConnMethodL( aMessage ); |
|
249 } |
|
250 break; |
|
251 case ECmmRemoveConnMethod: |
|
252 { |
|
253 RemoveConnMethodL( aMessage ); |
|
254 } |
|
255 break; |
|
256 |
|
257 case EDestGetDestination: |
|
258 case EDestRefresh: |
|
259 case EDestCreateDestinationWithName: |
|
260 case EDestCreateDestinationWithNameAndId: |
|
261 case EDestCloseDestination: |
|
262 case EDestGetConnMethodCount: |
|
263 case EDestGetConnMethodPriority: |
|
264 case EDestGetName: |
|
265 case EDestGetId: |
|
266 case EDestGetElementId: |
|
267 case EDestMetadata: |
|
268 case EDestGetProtectionLevel: |
|
269 case EDestIsConnected: |
|
270 case EDestIsHidden: |
|
271 case EDestIsEqual: |
|
272 case EDestAddConnMethod: |
|
273 case EDestAddEmbeddedDestination: |
|
274 case EDestDeleteConnMethod: |
|
275 case EDestRemoveConnMethod: |
|
276 case EDestModifyPriority: |
|
277 case EDestSetName: |
|
278 case EDestSetMetadata: |
|
279 case EDestSetProtection: |
|
280 case EDestSetHidden: |
|
281 case EDestUpdate: |
|
282 case EDestDelete: |
|
283 { |
|
284 ServiceDestinationL( aMessage ); |
|
285 } |
|
286 break; |
|
287 |
|
288 case ECMGetConnMethodWithId: |
|
289 case ECMRefresh: |
|
290 case ECMCreateConnMethod: |
|
291 case ECMCreateConnMethodWithId: |
|
292 case ECMGetConnMethodFromDestWithIndex: |
|
293 case ECMGetConnMethodFromDestWithId: |
|
294 case ECMCreateConnMethodToDest: |
|
295 case ECMCreateConnMethodToDestWithId: |
|
296 case ECMCreateCopyOfExisting: |
|
297 case ECMCloseConnMethod: |
|
298 case ECMGetIntAttribute: |
|
299 case ECMGetBoolAttribute: |
|
300 case ECMGetStringAttribute: |
|
301 case ECMGetString8Attribute: |
|
302 case ECMIsEqual: |
|
303 case ECMSetIntAttribute: |
|
304 case ECMSetBoolAttribute: |
|
305 case ECMSetStringAttribute: |
|
306 case ECMSetString8Attribute: |
|
307 case ECMDelete: |
|
308 case ECMUpdate: |
|
309 case EDestGetEmbeddedDestination: |
|
310 { |
|
311 ServiceConnMethodL( aMessage ); |
|
312 } |
|
313 break; |
|
314 default: |
|
315 { |
|
316 result = KErrNotSupported; |
|
317 } |
|
318 break; |
|
319 } |
|
320 |
|
321 aMessage.Complete( result ); |
|
322 |
|
323 OstTraceFunctionExit0( CCMMSESSION_SERVICEL_EXIT ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // Finds a connection method instance that belongs to this session and matches |
|
328 // the provided ID. Return NULL if no match is found. |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 CCmmConnMethodInstance* CCmmSession::FindConnMethodInstanceById( |
|
332 const TUint32& aConnMethodId ) |
|
333 { |
|
334 OstTraceFunctionEntry0( CCMMSESSION_FINDCONNMETHODINSTANCEBYID_ENTRY ); |
|
335 |
|
336 CCmmConnMethodInstance* wantedConnMethodInstance( NULL ); |
|
337 |
|
338 for ( TInt i = 0; i < iConnMethodObjects->Count(); i++ ) |
|
339 { |
|
340 CCmmConnMethodInstance* connMethodInstance = |
|
341 ( CCmmConnMethodInstance* )( ( *iConnMethodObjects )[i] ); |
|
342 if ( connMethodInstance && connMethodInstance->GetId() == aConnMethodId ) |
|
343 { |
|
344 wantedConnMethodInstance = connMethodInstance; |
|
345 break; |
|
346 } |
|
347 } |
|
348 |
|
349 OstTraceFunctionExit0( CCMMSESSION_FINDCONNMETHODINSTANCEBYID_EXIT ); |
|
350 return wantedConnMethodInstance; |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // Finds a destination instance that belongs to this session and matches |
|
355 // the provided handle. |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 CCmmDestinationInstance* CCmmSession::FindDestinationInstanceByHandleL( |
|
359 const TInt& aDestinationHandle ) |
|
360 { |
|
361 OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYHANDLEL_ENTRY ); |
|
362 |
|
363 return (CCmmDestinationInstance*)iDestinationObjects->AtL( aDestinationHandle ); |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // Finds a destination instance that belongs to this session and matches |
|
368 // the provided ID. Return NULL if no match is found. |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 CCmmDestinationInstance* CCmmSession::FindDestinationInstanceById( |
|
372 const TUint32& aDestinationId ) |
|
373 { |
|
374 OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYID_ENTRY ); |
|
375 |
|
376 CCmmDestinationInstance* wantedDestinationInstance( NULL ); |
|
377 |
|
378 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
379 { |
|
380 CCmmDestinationInstance* destinationInstance = |
|
381 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
382 if ( destinationInstance && destinationInstance->GetId() == aDestinationId ) |
|
383 { |
|
384 wantedDestinationInstance = destinationInstance; |
|
385 break; |
|
386 } |
|
387 } |
|
388 |
|
389 OstTraceFunctionExit0( CCMMSESSION_FINDDESTINATIONINSTANCEBYID_EXIT ); |
|
390 return wantedDestinationInstance; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // Check from all open destination handles in this session if the given |
|
395 // connection method is inside any of them. The given destination is skipped. |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 TBool CCmmSession::ConnMethodInOtherDestination( |
|
399 const TUint32& aConnMethodId, |
|
400 const TUint32& aDestinationId ) |
|
401 { |
|
402 OstTraceFunctionEntry0( CCMMSESSION_CONNMETHODINOTHERDESTINATION_ENTRY ); |
|
403 |
|
404 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
405 { |
|
406 CCmmDestinationInstance* destinationInstance = |
|
407 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
408 if ( destinationInstance && destinationInstance->GetId() != aDestinationId ) |
|
409 { |
|
410 for ( TInt j = 0; j < destinationInstance->iConnMethodItemArray.Count(); j++ ) |
|
411 { |
|
412 if ( destinationInstance->iConnMethodItemArray[i].iId == aConnMethodId ) |
|
413 { |
|
414 OstTraceFunctionExit0( CCMMSESSION_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
415 return ETrue; |
|
416 } |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 OstTraceFunctionExit0( DUP1_CCMMSESSION_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
422 return EFalse; |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // Check for restrictions for adding an embedded destination from destination |
|
427 // instances of all clients. |
|
428 // - aDestinationId is the ID of the destination where a destination is beeing |
|
429 // embedded. |
|
430 // - aEmbeddedDestinationId is the ID of the destination that is beeing |
|
431 // embedded. |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 TBool CCmmSession::EmbeddedDestinationConflictsFromAllSessions( |
|
435 const TUint32& aDestinationId, |
|
436 const TUint32& aEmbeddedDestinationId ) |
|
437 { |
|
438 OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY ); |
|
439 |
|
440 return iServer.EmbeddedDestinationConflictsFromAllSessions( aDestinationId, aEmbeddedDestinationId ); |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // Check for restrictions for adding an embedded destination from destination |
|
445 // instances of this session. |
|
446 // - aDestinationId is the ID of the destination where a destination is beeing |
|
447 // embedded. |
|
448 // - aEmbeddedDestinationId is the ID of the destination that is beeing |
|
449 // embedded. |
|
450 // |
|
451 // - Check that any destination instance does not contain aDestinationId as |
|
452 // embedded destination. |
|
453 // - Check that any destination instance for aEmbeddedDestinationId does not |
|
454 // contain an embedded destination. |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 TBool CCmmSession::EmbeddedDestinationConflicts( |
|
458 const TUint32& aDestinationId, |
|
459 const TUint32& aEmbeddedDestinationId ) |
|
460 { |
|
461 OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTS_ENTRY ); |
|
462 |
|
463 TBool result( EFalse ); |
|
464 |
|
465 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
466 { |
|
467 CCmmDestinationInstance* destinationInstance = |
|
468 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
469 if ( destinationInstance ) |
|
470 { |
|
471 if ( destinationInstance->HasEmbeddedWithId( aDestinationId ) || |
|
472 ( destinationInstance->GetId() == aEmbeddedDestinationId && |
|
473 destinationInstance->HasEmbedded() ) ) |
|
474 { |
|
475 result = ETrue; |
|
476 break; |
|
477 } |
|
478 } |
|
479 } |
|
480 |
|
481 OstTraceFunctionExit0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTS_EXIT ); |
|
482 return result; |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------------------------- |
|
486 // After update to database, refresh temporary ID to real ID if necessary and |
|
487 // refresh status information for any related handles for all client sessions. |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 void CCmmSession::RefreshHandlesForAllSessions( const TCmmIdStruct& aIdStruct ) |
|
491 { |
|
492 OstTraceFunctionEntry0( CCMMSESSION_REFRESHHANDLESFORALLSESSIONS_ENTRY ); |
|
493 |
|
494 // If the ID structure contains a temporary ID, we need to update the |
|
495 // temporary ID to the real ID for all relevant handles in this session and |
|
496 // cache. |
|
497 if ( aIdStruct.iTemporaryId ) |
|
498 { |
|
499 // Real ID tells if this is a destination or connection method. |
|
500 |
|
501 if ( aIdStruct.iRealId < KCmmConnMethodIdIntervalMax ) |
|
502 { |
|
503 // Connection method. Need to iterate through all destination and |
|
504 // connection method handles. |
|
505 |
|
506 // Update the ID of the connection method on session side. |
|
507 for ( TInt i = 0; i < iConnMethodObjects->Count(); i++ ) |
|
508 { |
|
509 CCmmConnMethodInstance* connMethodInstance = |
|
510 ( CCmmConnMethodInstance* )( ( *iConnMethodObjects )[i] ); |
|
511 if ( connMethodInstance && |
|
512 connMethodInstance->GetId() == aIdStruct.iTemporaryId ) |
|
513 { |
|
514 connMethodInstance->SetId( aIdStruct.iRealId ); //TODO, need to set ID inside records? |
|
515 break; // Can only be 1 match. |
|
516 } |
|
517 } |
|
518 // Update the ID of the connection method in cache side also. |
|
519 iCache.RefreshConnMethodId( aIdStruct ); |
|
520 |
|
521 // Iterate all destinations. If the connection method is in them, |
|
522 // update the ID to real ID. |
|
523 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
524 { |
|
525 CCmmDestinationInstance* destinationInstance = |
|
526 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
527 if ( destinationInstance ) |
|
528 { |
|
529 destinationInstance->RefreshConnMethodId( aIdStruct ); |
|
530 } |
|
531 } |
|
532 } |
|
533 else |
|
534 { |
|
535 // Destination. Need to iterate through all destination handles. |
|
536 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
537 { |
|
538 CCmmDestinationInstance* destinationInstance = |
|
539 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
540 if ( destinationInstance && |
|
541 destinationInstance->GetId() == aIdStruct.iTemporaryId ) |
|
542 { |
|
543 destinationInstance->SetId( aIdStruct.iRealId ); |
|
544 break; // Can only be 1 match. |
|
545 } |
|
546 } |
|
547 // Update the ID of the destination in cache side also. |
|
548 iCache.RefreshDestinationId( aIdStruct ); |
|
549 } |
|
550 } |
|
551 |
|
552 // Update status information for all related destination/connection method |
|
553 // handles in all client sessions. |
|
554 iServer.RefreshHandlesForAllSessions( aIdStruct.iRealId ); |
|
555 |
|
556 OstTraceFunctionExit0( CCMMSESSION_REFRESHHANDLESFORALLSESSIONS_EXIT ); |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------------------------- |
|
560 // Removes a connection method from any open destination handle in this |
|
561 // session. |
|
562 // --------------------------------------------------------------------------- |
|
563 // |
|
564 void CCmmSession::RemoveConnMethodFromDestinationHandles( |
|
565 const TUint32& aConnMethodId ) |
|
566 { |
|
567 OstTraceFunctionEntry0( CCMMSESSION_REMOVECONNMETHODFROMDESTINATIONHANDLES_ENTRY ); |
|
568 |
|
569 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
570 { |
|
571 CCmmDestinationInstance* destinationInstance = |
|
572 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
573 if ( destinationInstance ) |
|
574 { |
|
575 for ( TInt j = 0; j < destinationInstance->iConnMethodItemArray.Count(); j++ ) |
|
576 { |
|
577 if ( destinationInstance->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
578 { |
|
579 destinationInstance->iConnMethodItemArray.Remove( j ); |
|
580 break; |
|
581 } |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 OstTraceFunctionExit0( CCMMSESSION_REMOVECONNMETHODFROMDESTINATIONHANDLES_EXIT ); |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // Notify this session destination/connection method handles about an |
|
591 // updated/deleted destination/connection method. |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 void CCmmSession::RefreshHandles( const TUint32& aId ) const |
|
595 { |
|
596 OstTraceFunctionEntry0( CCMMSESSION_REFRESHHANDLES_ENTRY ); |
|
597 |
|
598 // Destination or connection method. |
|
599 if ( aId < KCmmConnMethodIdIntervalMax ) |
|
600 { |
|
601 // Connection method. |
|
602 for ( TInt i = 0; i < iConnMethodObjects->Count(); i++ ) |
|
603 { |
|
604 CCmmConnMethodInstance* connMethodInstance = |
|
605 ( CCmmConnMethodInstance* )( ( *iConnMethodObjects )[i] ); |
|
606 if ( connMethodInstance && connMethodInstance->GetId() == aId ) |
|
607 { |
|
608 connMethodInstance->SetStatus( ECmmConnMethodStatusChanged ); |
|
609 } |
|
610 } |
|
611 } |
|
612 else |
|
613 { |
|
614 // Destination. |
|
615 for ( TInt i = 0; i < iDestinationObjects->Count(); i++ ) |
|
616 { |
|
617 CCmmDestinationInstance* destinationInstance = |
|
618 ( CCmmDestinationInstance* )( ( *iDestinationObjects )[i] ); |
|
619 if ( destinationInstance && destinationInstance->GetId() == aId ) |
|
620 { |
|
621 destinationInstance->SetStatus( ECmmDestinationStatusChanged ); //TODO, any record status need be set? |
|
622 } |
|
623 } |
|
624 } |
|
625 |
|
626 OstTraceFunctionExit0( CCMMSESSION_REFRESHHANDLES_EXIT ); |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CCmmSession::GetBearerInfoIntL |
|
631 // ----------------------------------------------------------------------------- |
|
632 // |
|
633 void CCmmSession::GetBearerInfoIntL( const RMessage2& aMessage ) |
|
634 { |
|
635 OstTraceFunctionEntry0( CCMMSESSION_GETBEARERINFOINTL_ENTRY ); |
|
636 |
|
637 TUint32 bearerType( aMessage.Int0() ); |
|
638 TUint32 attribute( aMessage.Int1() ); |
|
639 |
|
640 TUint32 result = iCache.GetBearerInfoIntL( bearerType, attribute ); |
|
641 TPckg<TUint32> resultPckg( result ); |
|
642 aMessage.WriteL( 2, resultPckg ); |
|
643 |
|
644 OstTraceFunctionExit0( CCMMSESSION_GETBEARERINFOINTL_EXIT ); |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // CCmmSession::GetBearerInfoBoolL |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 void CCmmSession::GetBearerInfoBoolL( const RMessage2& aMessage ) |
|
652 { |
|
653 OstTraceFunctionEntry0( CCMMSESSION_GETBEARERINFOBOOLL_ENTRY ); |
|
654 |
|
655 TUint32 bearerType( aMessage.Int0() ); |
|
656 TUint32 attribute( aMessage.Int1() ); |
|
657 |
|
658 TBool result = iCache.GetBearerInfoBoolL( bearerType, attribute ); |
|
659 TPckg<TBool> resultPckg( result ); |
|
660 aMessage.WriteL( 2, resultPckg ); |
|
661 |
|
662 OstTraceFunctionExit0( CCMMSESSION_GETBEARERINFOBOOLL_EXIT ); |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CCmmSession::GetBearerInfoStringL |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 void CCmmSession::GetBearerInfoStringL( const RMessage2& aMessage ) |
|
670 { |
|
671 OstTraceFunctionEntry0( CCMMSESSION_GETBEARERINFOSTRINGL_ENTRY ); |
|
672 |
|
673 TUint32 bearerType( aMessage.Int0() ); |
|
674 TUint32 attribute( aMessage.Int1() ); |
|
675 |
|
676 HBufC* result = iCache.GetBearerInfoStringL( bearerType, attribute ); |
|
677 if ( !result ) |
|
678 { |
|
679 OstTraceFunctionExit0( CCMMSESSION_GETBEARERINFOSTRINGL_EXIT ); |
|
680 return; |
|
681 } |
|
682 CleanupStack::PushL( result ); |
|
683 |
|
684 TInt bufferLen = aMessage.GetDesMaxLength( 2 ); |
|
685 if ( result && result->Length() > bufferLen ) |
|
686 { |
|
687 User::Leave( KErrArgument ); |
|
688 } |
|
689 |
|
690 TPtrC resultPtr = result->Des(); |
|
691 aMessage.WriteL( 2, resultPtr ); |
|
692 CleanupStack::PopAndDestroy( result ); |
|
693 |
|
694 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETBEARERINFOSTRINGL_EXIT ); |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CCmmSession::GetBearerInfoString8L |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 void CCmmSession::GetBearerInfoString8L( const RMessage2& aMessage ) |
|
702 { |
|
703 OstTraceFunctionEntry0( CCMMSESSION_GETBEARERINFOSTRING8L_ENTRY ); |
|
704 |
|
705 TUint32 bearerType( aMessage.Int0() ); |
|
706 TUint32 attribute( aMessage.Int1() ); |
|
707 |
|
708 HBufC8* result = iCache.GetBearerInfoString8L( bearerType, attribute ); |
|
709 if ( !result ) |
|
710 { |
|
711 OstTraceFunctionExit0( CCMMSESSION_GETBEARERINFOSTRING8L_EXIT ); |
|
712 return; |
|
713 } |
|
714 CleanupStack::PushL( result ); |
|
715 |
|
716 TInt bufferLen = aMessage.GetDesMaxLength( 2 ); |
|
717 if ( result && result->Length() > bufferLen ) |
|
718 { |
|
719 User::Leave( KErrArgument ); |
|
720 } |
|
721 |
|
722 TPtrC8 resultPtr = result->Des(); |
|
723 aMessage.WriteL( 2, resultPtr ); |
|
724 CleanupStack::PopAndDestroy( result ); |
|
725 |
|
726 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETBEARERINFOSTRING8L_EXIT ); |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CCmmSession::GetConnMethodInfoIntL |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 void CCmmSession::GetConnMethodInfoIntL( const RMessage2& aMessage ) |
|
734 { |
|
735 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODINFOINTL_ENTRY ); |
|
736 |
|
737 TUint32 cmId( aMessage.Int0() ); |
|
738 TUint32 attribute( aMessage.Int1() ); |
|
739 |
|
740 TUint32 result = iCache.GetConnectionMethodInfoIntL( cmId, attribute ); |
|
741 TPckg<TUint32> resultPckg( result ); |
|
742 aMessage.WriteL( 2, resultPckg ); |
|
743 |
|
744 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODINFOINTL_EXIT ); |
|
745 } |
|
746 |
|
747 // ----------------------------------------------------------------------------- |
|
748 // CCmmSession::GetConnMethodInfoBoolL |
|
749 // ----------------------------------------------------------------------------- |
|
750 // |
|
751 void CCmmSession::GetConnMethodInfoBoolL( const RMessage2& aMessage ) |
|
752 { |
|
753 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODINFOBOOLL_ENTRY ); |
|
754 |
|
755 TUint32 cmId( aMessage.Int0() ); |
|
756 TUint32 attribute( aMessage.Int1() ); |
|
757 |
|
758 TBool result = iCache.GetConnectionMethodInfoBoolL( cmId, attribute ); |
|
759 TPckg<TBool> resultPckg( result ); |
|
760 aMessage.WriteL( 2, resultPckg ); |
|
761 |
|
762 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODINFOBOOLL_EXIT ); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CCmmSession::GetConnMethodInfoStringL |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 void CCmmSession::GetConnMethodInfoStringL( const RMessage2& aMessage ) |
|
770 { |
|
771 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODINFOSTRINGL_ENTRY ); |
|
772 |
|
773 TUint32 cmId( aMessage.Int0() ); |
|
774 TUint32 attribute( aMessage.Int1() ); |
|
775 |
|
776 HBufC* result = iCache.GetConnectionMethodInfoStringL( cmId, attribute ); |
|
777 if ( !result ) |
|
778 { |
|
779 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODINFOSTRINGL_EXIT ); |
|
780 return; |
|
781 } |
|
782 CleanupStack::PushL( result ); |
|
783 |
|
784 TInt bufferLen = aMessage.GetDesMaxLength( 2 ); |
|
785 if ( result && result->Length() > bufferLen ) |
|
786 { |
|
787 User::Leave( KErrArgument ); |
|
788 } |
|
789 |
|
790 TPtrC resultPtr = result->Des(); |
|
791 aMessage.WriteL( 2, resultPtr ); |
|
792 CleanupStack::PopAndDestroy( result ); |
|
793 |
|
794 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETCONNMETHODINFOSTRINGL_EXIT ); |
|
795 } |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CCmmSession::GetConnMethodInfoString8L |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 void CCmmSession::GetConnMethodInfoString8L( const RMessage2& aMessage ) |
|
802 { |
|
803 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODINFOSTRING8L_ENTRY ); |
|
804 |
|
805 TUint32 cmId( aMessage.Int0() ); |
|
806 TUint32 attribute( aMessage.Int1() ); |
|
807 |
|
808 HBufC8* result = iCache.GetConnectionMethodInfoString8L( cmId, attribute ); |
|
809 if ( !result ) |
|
810 { |
|
811 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODINFOSTRING8L_EXIT ); |
|
812 return; |
|
813 } |
|
814 CleanupStack::PushL( result ); |
|
815 |
|
816 TInt bufferLen = aMessage.GetDesMaxLength( 2 ); |
|
817 if ( result && result->Length() > bufferLen ) |
|
818 { |
|
819 User::Leave( KErrArgument ); |
|
820 } |
|
821 |
|
822 TPtrC8 resultPtr = result->Des(); |
|
823 aMessage.WriteL( 2, resultPtr ); |
|
824 CleanupStack::PopAndDestroy( result ); |
|
825 |
|
826 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETCONNMETHODINFOSTRING8L_EXIT ); |
|
827 } |
|
828 |
|
829 // ----------------------------------------------------------------------------- |
|
830 // CCmmSession::GetConnMethodArrayL |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 void CCmmSession::GetConnMethodArrayL( const RMessage2& aMessage ) |
|
834 { |
|
835 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODARRAYL_ENTRY ); |
|
836 |
|
837 // Read attribute flags from client request. |
|
838 TPckgBuf<TCmmIpcStructGetConnMethods> parametersPckg; |
|
839 aMessage.ReadL( 0, parametersPckg ); |
|
840 TCmmIpcStructGetConnMethods attributes = parametersPckg(); |
|
841 |
|
842 // Create connection method ID array. |
|
843 RArray<TUint32> cmArray; |
|
844 CleanupClosePushL( cmArray ); |
|
845 iCache.GetAllConnMethodsL( cmArray, attributes.iCheckBearerType ); |
|
846 |
|
847 // Check if only legacy connection methods are needed. |
|
848 if ( attributes.iLegacyOnly ) |
|
849 { |
|
850 // Remove all referenced connection methods. |
|
851 for ( TInt i = cmArray.Count() - 1; i >= 0; i-- ) |
|
852 { |
|
853 if ( iCache.DestinationsContainingConnMethod( cmArray[i] ) ) |
|
854 { |
|
855 cmArray.Remove( i ); |
|
856 } |
|
857 } |
|
858 } |
|
859 |
|
860 // EasyWLAN handling. |
|
861 if ( !attributes.iEasyWlan ) |
|
862 { |
|
863 // If there is an EasyWLAN IAP, the ID needs to be removed from the array. |
|
864 TUint32 easyWlanId = iCache.EasyWlanIdL(); |
|
865 if ( easyWlanId != 0 ) |
|
866 { |
|
867 TInt index = cmArray.Find( easyWlanId ); |
|
868 if ( index != KErrNotFound ) |
|
869 { |
|
870 cmArray.Remove( index ); |
|
871 } |
|
872 } |
|
873 } |
|
874 |
|
875 // Check connection method ID count. |
|
876 TInt connMethodCount = cmArray.Count(); |
|
877 if ( connMethodCount > aMessage.GetDesMaxLengthL( 2 ) ) |
|
878 { |
|
879 // Client buffer is too small to contain all the informarmation. Return |
|
880 // without any answer and the client side will ask again using a bigger |
|
881 // buffer. |
|
882 CleanupStack::PopAndDestroy( &cmArray ); |
|
883 return; |
|
884 } |
|
885 |
|
886 TPckg<TInt> countPckg( connMethodCount ); |
|
887 aMessage.WriteL( 1, countPckg ); |
|
888 |
|
889 if ( connMethodCount == 0 ) |
|
890 { |
|
891 CleanupStack::PopAndDestroy( &cmArray ); |
|
892 return; |
|
893 } |
|
894 |
|
895 // Write connection method IDs to client. |
|
896 HBufC8* idBuf = HBufC8::NewLC( connMethodCount ); |
|
897 TPtr8 bufPtr( idBuf->Des() ); |
|
898 for ( TInt i = 0; i < connMethodCount; i++ ) |
|
899 { |
|
900 bufPtr.Append( (TUint8)( cmArray[i] & 0x000000FF ) ); |
|
901 } |
|
902 aMessage.WriteL( 2, bufPtr ); |
|
903 |
|
904 CleanupStack::PopAndDestroy( idBuf ); |
|
905 CleanupStack::PopAndDestroy( &cmArray ); |
|
906 |
|
907 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETCONNMETHODARRAYL_EXIT ); |
|
908 } |
|
909 |
|
910 // ----------------------------------------------------------------------------- |
|
911 // CCmmSession::GetAllDestinationsL |
|
912 // ----------------------------------------------------------------------------- |
|
913 // |
|
914 void CCmmSession::GetAllDestinationsL( const RMessage2& aMessage ) |
|
915 { |
|
916 OstTraceFunctionEntry0( CCMMSESSION_GETALLDESTINATIONSL_ENTRY ); |
|
917 |
|
918 TInt destCount = iCache.GetDestinationCount(); |
|
919 if ( destCount > aMessage.GetDesMaxLengthL( 1 ) ) |
|
920 { |
|
921 // Client buffer is too small to contain all the informarmation. Return |
|
922 // without any answer and the client side will ask again using a bigger |
|
923 // buffer. |
|
924 return; |
|
925 } |
|
926 |
|
927 // Write the destination count to client. |
|
928 TPckg<TInt> countPckg( destCount ); |
|
929 aMessage.WriteL( 0, countPckg ); |
|
930 |
|
931 if ( destCount == 0 ) |
|
932 { |
|
933 return; |
|
934 } |
|
935 |
|
936 // Get the destination IDs from database cache. |
|
937 RArray<TUint32> destArray; |
|
938 CleanupClosePushL( destArray ); |
|
939 iCache.GetDestinationsL( destArray ); |
|
940 |
|
941 HBufC16* idBuf = HBufC16::NewLC( destCount ); |
|
942 TPtr16 bufPtr( idBuf->Des() ); |
|
943 for ( TInt i = 0; i < destCount; i++ ) |
|
944 { |
|
945 bufPtr.Append( destArray[i] ); |
|
946 } |
|
947 |
|
948 // Write the destination IDs to client. |
|
949 aMessage.WriteL( 1, bufPtr ); |
|
950 |
|
951 CleanupStack::PopAndDestroy( idBuf ); |
|
952 CleanupStack::PopAndDestroy( &destArray ); |
|
953 |
|
954 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETALLDESTINATIONSL_EXIT ); |
|
955 } |
|
956 |
|
957 // ----------------------------------------------------------------------------- |
|
958 // CCmmSession::GetEasyWLANIdL |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 void CCmmSession::GetEasyWLANIdL( const RMessage2& aMessage ) |
|
962 { |
|
963 OstTraceFunctionEntry0( CCMMSESSION_GETEASYWLANIDL_ENTRY ); |
|
964 |
|
965 TUint32 id = iCache.EasyWlanIdL(); |
|
966 TPckg<TUint32> idPckg( id ); |
|
967 aMessage.WriteL( 0, idPckg ); |
|
968 |
|
969 OstTraceFunctionExit0( CCMMSESSION_GETEASYWLANIDL_EXIT ); |
|
970 } |
|
971 |
|
972 // ----------------------------------------------------------------------------- |
|
973 // CCmmSession::GetSupportedBearersL |
|
974 // ----------------------------------------------------------------------------- |
|
975 // |
|
976 void CCmmSession::GetSupportedBearersL( const RMessage2& aMessage ) |
|
977 { |
|
978 OstTraceFunctionEntry0( CCMMSESSION_GETSUPPORTEDBEARERSL_ENTRY ); |
|
979 |
|
980 // Get the supported bearer types. |
|
981 RArray<TUint32> bearerArray; |
|
982 CleanupClosePushL( bearerArray ); |
|
983 iServer.CmManager()->SupportedBearersL( bearerArray ); |
|
984 |
|
985 // Write bearer count to client. |
|
986 TInt bearerCount( bearerArray.Count() ); |
|
987 TInt neededBufferSize( bearerCount * sizeof( TUint32 ) ); |
|
988 TPckg<TInt> countPckg( bearerCount ); |
|
989 aMessage.WriteL( 0, countPckg ); |
|
990 |
|
991 // Check the client buffer size. |
|
992 if ( neededBufferSize > aMessage.GetDesMaxLengthL( 1 ) || bearerCount == 0 ) |
|
993 { |
|
994 // Client buffer is too small to contain all the information. Return |
|
995 // with only the bearer count information and the client side will ask |
|
996 // again using a big enough buffer. |
|
997 CleanupStack::PopAndDestroy( &bearerArray ); |
|
998 return; |
|
999 } |
|
1000 |
|
1001 // Add the bearer types into a buffer. |
|
1002 HBufC8* bearerBuf = HBufC8::NewLC( neededBufferSize ); |
|
1003 TPtr8 ptr( bearerBuf->Des() ); |
|
1004 for ( TInt i = 0; i < bearerCount; i++ ) |
|
1005 { |
|
1006 TUint32 a( bearerArray[i] ); |
|
1007 ptr.Append( (TUint8*)&a, 4 ); |
|
1008 } |
|
1009 |
|
1010 // Write the bearer types to client. |
|
1011 aMessage.WriteL( 1, ptr ); |
|
1012 |
|
1013 CleanupStack::PopAndDestroy( bearerBuf ); |
|
1014 CleanupStack::PopAndDestroy( &bearerArray ); |
|
1015 |
|
1016 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETSUPPORTEDBEARERSL_EXIT ); |
|
1017 } |
|
1018 |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // CCmmSession::ReadDefaultConnectionL |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // |
|
1023 void CCmmSession::ReadDefaultConnectionL( const RMessage2& aMessage ) |
|
1024 { |
|
1025 OstTraceFunctionEntry0( CCMMSESSION_READDEFAULTCONNECTIONL_ENTRY ); |
|
1026 |
|
1027 // Default connection is now simply the internet destination. |
|
1028 TCmDefConnValue defaultConnection; |
|
1029 defaultConnection.iType = ECmDefConnDestination; |
|
1030 defaultConnection.iId = 0; |
|
1031 |
|
1032 iCache.InternetDestinationIdL( defaultConnection.iId ); |
|
1033 if ( defaultConnection.iId == 0 ) |
|
1034 { |
|
1035 User::Leave( KErrNotFound ); |
|
1036 } |
|
1037 |
|
1038 TPckgBuf<TCmDefConnValue> dcPckgBuf( defaultConnection ); |
|
1039 aMessage.WriteL( 0, dcPckgBuf ); |
|
1040 |
|
1041 OstTraceFunctionExit0( CCMMSESSION_READDEFAULTCONNECTIONL_EXIT ); |
|
1042 } |
|
1043 |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // CCmmSession::ReadGenConnSettingsL |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // |
|
1048 void CCmmSession::ReadGenConnSettingsL( const RMessage2& aMessage ) |
|
1049 { |
|
1050 OstTraceFunctionEntry0( CCMMSESSION_READGENCONNSETTINGSL_ENTRY ); |
|
1051 |
|
1052 TCmGenConnSettings genConnSettings; |
|
1053 iCache.ReadGenConnSettingsL( genConnSettings ); |
|
1054 |
|
1055 TPckgBuf<TCmGenConnSettings> genConnSettingsPckgBuf( genConnSettings ); |
|
1056 aMessage.WriteL( 0, genConnSettingsPckgBuf ); |
|
1057 |
|
1058 OstTraceFunctionExit0( CCMMSESSION_READGENCONNSETTINGSL_EXIT ); |
|
1059 } |
|
1060 |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // CCmmSession::WriteGenConnSettingsL |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CCmmSession::WriteGenConnSettingsL( const RMessage2& aMessage ) |
|
1066 { |
|
1067 OstTraceFunctionEntry0( CCMMSESSION_WRITEGENCONNSETTINGSL_ENTRY ); |
|
1068 |
|
1069 // Read data from client request. |
|
1070 TPckgBuf<TCmGenConnSettings> genConnSettingsPckgBuf; |
|
1071 aMessage.ReadL( 0, genConnSettingsPckgBuf ); |
|
1072 TCmGenConnSettings genConnSettings = genConnSettingsPckgBuf(); |
|
1073 |
|
1074 iCache.WriteGenConnSettingsL( genConnSettings ); |
|
1075 |
|
1076 OstTraceFunctionExit0( CCMMSESSION_WRITEGENCONNSETTINGSL_EXIT ); |
|
1077 } |
|
1078 |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // CCmmSession::GetBearerPriorityArrayL |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 void CCmmSession::GetBearerPriorityArrayL( const RMessage2& aMessage ) |
|
1084 { |
|
1085 OstTraceFunctionEntry0( CCMMSESSION_GETBEARERPRIORITYARRAYL_ENTRY ); |
|
1086 |
|
1087 const TInt maxLength( aMessage.GetDesMaxLengthL( 0 ) ); |
|
1088 if ( maxLength < 2 ) |
|
1089 { |
|
1090 // Minimum length of 2 is needed to store count and needed length. |
|
1091 User::Leave( KErrArgument ); |
|
1092 } |
|
1093 |
|
1094 RPointerArray<CCmmBearerPriority> bearerPriorityArray; |
|
1095 CmmCleanupResetAndDestroyPushL( bearerPriorityArray ); |
|
1096 |
|
1097 iCache.CopyBearerPriorityArrayL( bearerPriorityArray ); |
|
1098 const TInt bearerCountInArray( bearerPriorityArray.Count() ); |
|
1099 TInt bearerCount( bearerCountInArray ); |
|
1100 |
|
1101 TInt maxBufLen( 2 ); |
|
1102 // Check the length needed for serializing. |
|
1103 for ( TInt i = 0; i < bearerCountInArray; i++ ) |
|
1104 { |
|
1105 // Skip if service type is not valid. |
|
1106 if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 ) |
|
1107 { |
|
1108 maxBufLen += KCmmBearerPriorityHeaderLength; // Priorities and servicetype length. |
|
1109 maxBufLen += bearerPriorityArray[i]->ServiceType()->Length(); |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 bearerCount--; |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 // If given buffer is shorter than needed, just write count and needed length. |
|
1118 if ( maxBufLen > maxLength ) |
|
1119 { |
|
1120 HBufC* buffer = HBufC::NewLC( KCmmDefaultBearerPriorityArraySize ); |
|
1121 TPtr bufferPtr( buffer->Des() ); |
|
1122 |
|
1123 bufferPtr.Append( bearerCount ); |
|
1124 bufferPtr.Append( maxBufLen ); |
|
1125 aMessage.WriteL( 0, bufferPtr ); |
|
1126 |
|
1127 CleanupStack::PopAndDestroy( buffer ); |
|
1128 CleanupStack::PopAndDestroy( &bearerPriorityArray ); |
|
1129 OstTraceFunctionExit0( CCMMSESSION_GETBEARERPRIORITYARRAYL_EXIT ); |
|
1130 return; |
|
1131 } |
|
1132 |
|
1133 // Add needed buffer + space for bearerCount and maxlength. |
|
1134 HBufC* buffer = HBufC::NewLC( maxBufLen ); |
|
1135 TPtr bufferPtr( buffer->Des() ); |
|
1136 |
|
1137 // Write count and bufmaxLen. |
|
1138 bufferPtr.Append( bearerCount ); |
|
1139 bufferPtr.Append( maxBufLen ); |
|
1140 |
|
1141 for ( TInt i = 0; i < bearerCountInArray; i++ ) |
|
1142 { |
|
1143 // Skip if service type is not valid. |
|
1144 if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 ) |
|
1145 { |
|
1146 TUint32 priority = bearerPriorityArray[i]->Priority(); |
|
1147 TUint32 uiPriority = bearerPriorityArray[i]->UiPriority(); |
|
1148 const HBufC* serviceType = bearerPriorityArray[i]->ServiceType(); |
|
1149 |
|
1150 bufferPtr.Append( priority >> KBitsInTwoBytes ); |
|
1151 bufferPtr.Append( priority & 0x0000FFFF ); |
|
1152 bufferPtr.Append( uiPriority >> KBitsInTwoBytes ); |
|
1153 bufferPtr.Append( uiPriority & 0x0000FFFF ); |
|
1154 |
|
1155 const TInt stringLength = serviceType->Length(); |
|
1156 bufferPtr.Append( stringLength ); |
|
1157 bufferPtr.Append( *serviceType ); |
|
1158 } |
|
1159 } |
|
1160 aMessage.WriteL( 0, bufferPtr ); |
|
1161 |
|
1162 CleanupStack::PopAndDestroy( buffer ); |
|
1163 CleanupStack::PopAndDestroy( &bearerPriorityArray ); |
|
1164 |
|
1165 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETBEARERPRIORITYARRAYL_EXIT ); |
|
1166 } |
|
1167 |
|
1168 // ----------------------------------------------------------------------------- |
|
1169 // CCmmSession::UpdateBearerPriorityArrayL |
|
1170 // ----------------------------------------------------------------------------- |
|
1171 // |
|
1172 void CCmmSession::UpdateBearerPriorityArrayL( const RMessage2& aMessage ) |
|
1173 { |
|
1174 OstTraceFunctionEntry0( CCMMSESSION_UPDATEBEARERPRIORITYARRAYL_ENTRY ); |
|
1175 |
|
1176 HBufC* bearerPriorityBuf = HBufC::NewLC( aMessage.GetDesMaxLengthL( 0 ) ); |
|
1177 TPtr bearerPriorityBufPtr( bearerPriorityBuf->Des() ); |
|
1178 |
|
1179 aMessage.ReadL( 0, bearerPriorityBufPtr ); |
|
1180 |
|
1181 const TInt bearerCount = bearerPriorityBufPtr[0]; |
|
1182 if ( ( bearerCount < 1 ) || ( aMessage.GetDesMaxLengthL( 0 ) < 2 ) ) |
|
1183 { |
|
1184 User::Leave( KErrArgument ); |
|
1185 } |
|
1186 |
|
1187 RPointerArray<CCmmBearerPriority> bearerPriorityArray; |
|
1188 CmmCleanupResetAndDestroyPushL( bearerPriorityArray ); |
|
1189 |
|
1190 TInt position( 2 ); // Start of first priority item. |
|
1191 for ( TInt i = 0; i < bearerCount; i++ ) |
|
1192 { |
|
1193 TUint32 priority; |
|
1194 TUint32 uiPriority; |
|
1195 priority = bearerPriorityBufPtr[position] << KBitsInTwoBytes; |
|
1196 position++; |
|
1197 priority += bearerPriorityBufPtr[position]; |
|
1198 position++; |
|
1199 uiPriority = bearerPriorityBufPtr[position] << KBitsInTwoBytes; |
|
1200 position++; |
|
1201 uiPriority += bearerPriorityBufPtr[position]; |
|
1202 position++; |
|
1203 const TInt stringLength = bearerPriorityBufPtr[position]; |
|
1204 position++; |
|
1205 if ( stringLength <= 0 ) |
|
1206 { |
|
1207 User::Leave( KErrArgument ); |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 HBufC* serviceName = HBufC::NewLC( stringLength ); |
|
1212 serviceName->Des().Append( &( bearerPriorityBufPtr[position] ), stringLength ); |
|
1213 position += stringLength; |
|
1214 |
|
1215 TPtrC tempServiceType( serviceName->Des() ); |
|
1216 CCmmBearerPriority* item = CCmmBearerPriority::NewLC( tempServiceType, priority, uiPriority ); |
|
1217 bearerPriorityArray.AppendL( item ); |
|
1218 CleanupStack::Pop( item ); |
|
1219 |
|
1220 CleanupStack::PopAndDestroy( serviceName ); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 // Update bearer priority array |
|
1225 iCache.UpdateBearerPriorityArrayL( bearerPriorityArray ); |
|
1226 |
|
1227 CleanupStack::PopAndDestroy( &bearerPriorityArray ); |
|
1228 CleanupStack::PopAndDestroy( bearerPriorityBuf ); |
|
1229 |
|
1230 OstTraceFunctionExit0( CCMMSESSION_UPDATEBEARERPRIORITYARRAYL_EXIT ); |
|
1231 } |
|
1232 |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // Copies a connection method into a destination. If the connection method is |
|
1235 // in any other destination, it becomes shared. Calls update on the target |
|
1236 // destination. |
|
1237 // ----------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CCmmSession::CopyConnMethodL( const RMessage2& aMessage ) |
|
1240 { |
|
1241 OstTraceFunctionEntry0( CCMMSESSION_COPYCONNMETHODL_ENTRY ); |
|
1242 |
|
1243 CCmmDestinationInstance* destination = ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() ); |
|
1244 CCmmConnMethodInstance* connMethod = ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() ); |
|
1245 |
|
1246 // Can't add an embedded destination this way. |
|
1247 if ( connMethod->IsEmbeddedDestination() ) |
|
1248 { |
|
1249 User::Leave( KErrArgument ); |
|
1250 } |
|
1251 |
|
1252 //TODO, capability check, what to do if anything is protected. |
|
1253 |
|
1254 // Add connection method into destination. |
|
1255 TInt index = destination->AddConnMethodL( *connMethod ); |
|
1256 |
|
1257 // Update destination into database. |
|
1258 destination->UpdateL(); |
|
1259 |
|
1260 // Write the connection method index (priority) inside the destination to client. |
|
1261 TPckg<TInt> indexPckg( index ); |
|
1262 aMessage.WriteL( 2, indexPckg ); |
|
1263 |
|
1264 OstTraceFunctionExit0( CCMMSESSION_COPYCONNMETHODL_EXIT ); |
|
1265 } |
|
1266 |
|
1267 // ----------------------------------------------------------------------------- |
|
1268 // Moves a connection method from one destination to another. Calls update on |
|
1269 // both the source and target destinations (which also updates the connection |
|
1270 // method). |
|
1271 // ----------------------------------------------------------------------------- |
|
1272 // |
|
1273 void CCmmSession::MoveConnMethodL( const RMessage2& aMessage ) |
|
1274 { |
|
1275 OstTraceFunctionEntry0( CCMMSESSION_MOVECONNMETHODL_ENTRY ); |
|
1276 |
|
1277 // Read data from client request. |
|
1278 TPckgBuf<TCmmIpcStructMoveConnMethod> attributesPckg; |
|
1279 aMessage.ReadL( 0, attributesPckg ); |
|
1280 TCmmIpcStructMoveConnMethod attributes = attributesPckg(); |
|
1281 |
|
1282 CCmmDestinationInstance* sourceDestination = |
|
1283 ( CCmmDestinationInstance* )iDestinationObjects->AtL( attributes.iSourceDestHandle ); |
|
1284 CCmmDestinationInstance* targetDestination = |
|
1285 ( CCmmDestinationInstance* )iDestinationObjects->AtL( attributes.iTargetDestHandle ); |
|
1286 CCmmConnMethodInstance* connMethod = |
|
1287 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( attributes.iConnMethodHandle ); |
|
1288 TUint32 connMethodId( connMethod->GetId() ); |
|
1289 |
|
1290 // Can't add an embedded destination this way. |
|
1291 if ( connMethod->IsEmbeddedDestination() ) |
|
1292 { |
|
1293 User::Leave( KErrArgument ); |
|
1294 } |
|
1295 // Check if the connection method is in the source destination. |
|
1296 if ( !sourceDestination->ValidConnMethodIdInDestinationIncludeEmbedded( connMethodId ) ) |
|
1297 { |
|
1298 User::Leave( KErrNotFound ); |
|
1299 } |
|
1300 // Check if the connection method is already in the target destination. |
|
1301 if ( targetDestination->ValidConnMethodIdInDestinationIncludeEmbedded( connMethodId ) ) |
|
1302 { |
|
1303 User::Leave( KErrAlreadyExists ); |
|
1304 } |
|
1305 // Check if the connection method can be removed from the source destination. |
|
1306 if ( sourceDestination->ConnMethodInDestinationButLocked( connMethodId ) ) |
|
1307 { |
|
1308 User::Leave( KErrLocked ); |
|
1309 } |
|
1310 // Check that the connection method is not in use by an active connection. |
|
1311 if ( iCache.CheckIfCmConnected( connMethodId ) ) |
|
1312 { |
|
1313 User::Leave( KErrInUse ); |
|
1314 } |
|
1315 |
|
1316 //TODO, capability checks, what to do if anything is protected. |
|
1317 |
|
1318 // Add connection method into target destination and update it. |
|
1319 attributesPckg().iIndex = targetDestination->AddConnMethodL( *connMethod ); |
|
1320 targetDestination->UpdateL(); |
|
1321 |
|
1322 // Remove connection method from source destination and update it. |
|
1323 sourceDestination->RemoveConnMethodFromDestinationL( *connMethod, EFalse ); // EFalse to not check connected state again. |
|
1324 sourceDestination->UpdateL(); |
|
1325 |
|
1326 // Write the index (priority) back to client. |
|
1327 aMessage.WriteL( 0, attributesPckg ); |
|
1328 |
|
1329 OstTraceFunctionExit0( CCMMSESSION_MOVECONNMETHODL_EXIT ); |
|
1330 } |
|
1331 |
|
1332 // ----------------------------------------------------------------------------- |
|
1333 // Remove a connection method froma destination. Does not call update on the |
|
1334 // affected destination. |
|
1335 // ----------------------------------------------------------------------------- |
|
1336 // |
|
1337 void CCmmSession::RemoveConnMethodL( const RMessage2& aMessage ) |
|
1338 { |
|
1339 OstTraceFunctionEntry0( CCMMSESSION_REMOVECONNMETHODL_ENTRY ); |
|
1340 |
|
1341 CCmmDestinationInstance* destinationInstance = |
|
1342 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() ); |
|
1343 CCmmConnMethodInstance* connMethodInstance = |
|
1344 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() ); |
|
1345 |
|
1346 //TODO, capability checks |
|
1347 |
|
1348 destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance ); |
|
1349 destinationInstance->UpdateL(); |
|
1350 |
|
1351 OstTraceFunctionExit0( CCMMSESSION_REMOVECONNMETHODL_EXIT ); |
|
1352 } |
|
1353 |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // Removes a connection method from every destination and make it uncategorized. |
|
1356 // Updates any destination that contains the connection method. |
|
1357 // ----------------------------------------------------------------------------- |
|
1358 // |
|
1359 void CCmmSession::RemoveAllReferencesL( const RMessage2& aMessage ) |
|
1360 { |
|
1361 OstTraceFunctionEntry0( CCMMSESSION_REMOVEALLREFERENCESL_ENTRY ); |
|
1362 |
|
1363 CCmmConnMethodInstance* connMethodInstance = |
|
1364 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
1365 |
|
1366 iCache.CheckIfConnMethodReferencesCanBeRemovedL( *connMethodInstance ); |
|
1367 iCache.RemoveAllReferencesToConnMethodL( *connMethodInstance ); |
|
1368 |
|
1369 OstTraceFunctionExit0( CCMMSESSION_REMOVEALLREFERENCESL_EXIT ); |
|
1370 } |
|
1371 |
|
1372 // ----------------------------------------------------------------------------- |
|
1373 // CCmmSession::ServiceDestinationL |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // |
|
1376 void CCmmSession::ServiceDestinationL( const RMessage2& aMessage ) |
|
1377 { |
|
1378 OstTraceFunctionEntry0( CCMMSESSION_SERVICEDESTINATIONL_ENTRY ); |
|
1379 |
|
1380 switch ( aMessage.Function() ) |
|
1381 { |
|
1382 case EDestGetDestination: |
|
1383 { |
|
1384 GetDestinationL( aMessage ); |
|
1385 } |
|
1386 break; |
|
1387 case EDestRefresh: |
|
1388 { |
|
1389 RefreshDestinationL( aMessage ); |
|
1390 } |
|
1391 break; |
|
1392 case EDestCreateDestinationWithName: |
|
1393 { |
|
1394 CreateDestinationWithNameL( aMessage ); |
|
1395 } |
|
1396 break; |
|
1397 case EDestCreateDestinationWithNameAndId: |
|
1398 { |
|
1399 CreateDestinationWithNameAndIdL( aMessage ); |
|
1400 } |
|
1401 break; |
|
1402 case EDestCloseDestination: |
|
1403 { |
|
1404 CloseDestination( aMessage ); |
|
1405 } |
|
1406 break; |
|
1407 case EDestGetConnMethodCount: |
|
1408 { |
|
1409 GetConnectionMehodCountL( aMessage ); |
|
1410 } |
|
1411 break; |
|
1412 case EDestGetConnMethodPriority: |
|
1413 { |
|
1414 GetConnMethodPriorityL( aMessage ); |
|
1415 } |
|
1416 break; |
|
1417 case EDestGetName: |
|
1418 { |
|
1419 GetDestinationNameL( aMessage ); |
|
1420 } |
|
1421 break; |
|
1422 case EDestGetId: |
|
1423 { |
|
1424 GetDestinationIdL( aMessage ); |
|
1425 } |
|
1426 break; |
|
1427 case EDestGetElementId: |
|
1428 { |
|
1429 GetDestinationElementIdL( aMessage ); |
|
1430 } |
|
1431 break; |
|
1432 case EDestMetadata: |
|
1433 { |
|
1434 GetDestinationMetadataL( aMessage ); |
|
1435 } |
|
1436 break; |
|
1437 case EDestGetProtectionLevel: |
|
1438 { |
|
1439 GetDestinationProtectionLevelL( aMessage ); |
|
1440 } |
|
1441 break; |
|
1442 case EDestIsConnected: |
|
1443 { |
|
1444 IsDestinationConnectedL( aMessage ); |
|
1445 } |
|
1446 break; |
|
1447 case EDestIsHidden: |
|
1448 { |
|
1449 IsDestinationHiddenL( aMessage ); |
|
1450 } |
|
1451 break; |
|
1452 case EDestIsEqual: |
|
1453 { |
|
1454 DestinationIsEqualL( aMessage ); |
|
1455 } |
|
1456 break; |
|
1457 case EDestAddConnMethod: |
|
1458 { |
|
1459 DestAddConnMethodL( aMessage ); |
|
1460 } |
|
1461 break; |
|
1462 case EDestAddEmbeddedDestination: |
|
1463 { |
|
1464 DestAddEmbeddedDestinationL( aMessage ); |
|
1465 } |
|
1466 break; |
|
1467 case EDestDeleteConnMethod: |
|
1468 { |
|
1469 DestDeleteConnMethodL( aMessage ); |
|
1470 } |
|
1471 break; |
|
1472 case EDestRemoveConnMethod: |
|
1473 { |
|
1474 DestRemoveConnMethodL( aMessage ); |
|
1475 } |
|
1476 break; |
|
1477 case EDestModifyPriority: |
|
1478 { |
|
1479 ModifyConnMethodPriorityL( aMessage ); |
|
1480 } |
|
1481 break; |
|
1482 case EDestSetName: |
|
1483 { |
|
1484 SetDestinationNameL( aMessage ); |
|
1485 } |
|
1486 break; |
|
1487 case EDestSetMetadata: |
|
1488 { |
|
1489 SetDestinationMetadataL( aMessage ); |
|
1490 } |
|
1491 break; |
|
1492 case EDestSetProtection: |
|
1493 { |
|
1494 SetDestinationProtectionL( aMessage ); |
|
1495 } |
|
1496 break; |
|
1497 case EDestSetHidden: |
|
1498 { |
|
1499 SetDestinationHiddenL( aMessage ); |
|
1500 } |
|
1501 break; |
|
1502 case EDestUpdate: |
|
1503 { |
|
1504 UpdateDestinationL( aMessage ); |
|
1505 } |
|
1506 break; |
|
1507 case EDestDelete: |
|
1508 { |
|
1509 DeleteDestinationL( aMessage ); |
|
1510 } |
|
1511 break; |
|
1512 default: |
|
1513 { |
|
1514 User::Leave( KErrNotSupported ); |
|
1515 } |
|
1516 break; |
|
1517 } |
|
1518 |
|
1519 OstTraceFunctionExit0( CCMMSESSION_SERVICEDESTINATIONL_EXIT ); |
|
1520 } |
|
1521 |
|
1522 // ----------------------------------------------------------------------------- |
|
1523 // CCmmSession::GetDestinationL |
|
1524 // ----------------------------------------------------------------------------- |
|
1525 // |
|
1526 void CCmmSession::GetDestinationL( const RMessage2& aMessage ) |
|
1527 { |
|
1528 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONL_ENTRY ); |
|
1529 |
|
1530 // Structure: |
|
1531 // - Check arguments. |
|
1532 // - Create session instance. |
|
1533 // - Ask cache to open/create target and put data to session instance. |
|
1534 // - Create subsession and complete message. |
|
1535 |
|
1536 // API side checks that ID is between 0x1000 - 0x1100, and converts if necessary. |
|
1537 TUint32 destinationId( aMessage.Int0() ); |
|
1538 |
|
1539 // Check that the ID is in valid range. |
|
1540 if ( destinationId <= KCmDefaultDestinationAPTagId || |
|
1541 destinationId >= KCmMaxDestinationAPTagId ) |
|
1542 { |
|
1543 User::Leave( KErrArgument ); |
|
1544 } |
|
1545 |
|
1546 // Check if a destination with given ID exists. |
|
1547 if ( !iCache.DestinationExistsWithId( destinationId ) ) |
|
1548 { |
|
1549 User::Leave( KErrNotFound ); |
|
1550 } |
|
1551 |
|
1552 // If this session already has a destination with matching ID open, provide |
|
1553 // the client with a reference to the already opened handle. |
|
1554 CCmmDestinationInstance* destinationInstance = FindDestinationInstanceById( destinationId ); |
|
1555 if ( destinationInstance ) |
|
1556 { |
|
1557 TPckg<TInt> existingHandlePckg( destinationInstance->GetHandle() ); |
|
1558 aMessage.WriteL( 1, existingHandlePckg ); |
|
1559 User::Leave( KErrAlreadyExists ); |
|
1560 } |
|
1561 destinationInstance = NULL; |
|
1562 TPckg<TInt> existingHandlePckg( 0 ); |
|
1563 aMessage.WriteL( 1, existingHandlePckg ); |
|
1564 |
|
1565 destinationInstance = CCmmDestinationInstance::NewLC( this, &iCache ); |
|
1566 |
|
1567 // Cache will open a handle to the destination if not already open, and |
|
1568 // copy relevant data into this destination instance. |
|
1569 iCache.OpenDestinationL( *destinationInstance, destinationId ); |
|
1570 |
|
1571 iDestinationContainer->AddL( ( CObject* ) destinationInstance ); |
|
1572 TInt handle = iDestinationObjects->AddL( ( CObject* ) destinationInstance ); |
|
1573 destinationInstance->SetHandle( handle ); |
|
1574 CleanupStack::Pop( destinationInstance ); |
|
1575 |
|
1576 TPckg<TInt> handlePckg( handle ); |
|
1577 TInt err = aMessage.Write( 3, handlePckg ); |
|
1578 if ( err ) |
|
1579 { |
|
1580 // Removes from object index and destroys the object. |
|
1581 iDestinationObjects->Remove( handle ); |
|
1582 User::Leave( err ); |
|
1583 } |
|
1584 |
|
1585 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONL_EXIT ); |
|
1586 } |
|
1587 |
|
1588 // ----------------------------------------------------------------------------- |
|
1589 // CCmmSession::RefreshDestinationL |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // |
|
1592 void CCmmSession::RefreshDestinationL( const RMessage2& aMessage ) |
|
1593 { |
|
1594 OstTraceFunctionEntry0( CCMMSESSION_REFRESHDESTINATIONL_ENTRY ); |
|
1595 |
|
1596 CCmmDestinationInstance* destinationInstance = |
|
1597 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1598 |
|
1599 iCache.RefreshDestinationL( *destinationInstance ); |
|
1600 |
|
1601 OstTraceFunctionExit0( CCMMSESSION_REFRESHDESTINATIONL_EXIT ); |
|
1602 } |
|
1603 |
|
1604 // ----------------------------------------------------------------------------- |
|
1605 // CCmmSession::CreateDestinationWithNameL |
|
1606 // ----------------------------------------------------------------------------- |
|
1607 // |
|
1608 void CCmmSession::CreateDestinationWithNameL( const RMessage2& aMessage ) |
|
1609 { |
|
1610 OstTraceFunctionEntry0( CCMMSESSION_CREATEDESTINATIONWITHNAMEL_ENTRY ); |
|
1611 |
|
1612 // Structure: |
|
1613 // - Check arguments. |
|
1614 // - Create session instance. |
|
1615 // - Ask cache to open/create target and put data to session instance. |
|
1616 // - Create subsession and complete message. |
|
1617 |
|
1618 // Load and check name. |
|
1619 TInt destNameLength = aMessage.GetDesLength( 0 ); |
|
1620 if ( destNameLength <= 0 ) |
|
1621 { |
|
1622 User::Leave( KErrArgument ); |
|
1623 } |
|
1624 |
|
1625 HBufC* destinationName = HBufC::NewLC( destNameLength ); |
|
1626 TPtr ptrDestinationName = destinationName->Des(); |
|
1627 aMessage.ReadL( 0, ptrDestinationName ); |
|
1628 |
|
1629 // Check if a destination with given name exists (or is already created but not yet saved). |
|
1630 if ( iCache.DestinationExistsWithNameL( *destinationName, 0 ) || |
|
1631 iCache.NotSavedDestinationOpenWithNameL( *destinationName, 0 ) ) |
|
1632 { |
|
1633 User::Leave( KErrAlreadyExists ); |
|
1634 } |
|
1635 |
|
1636 CCmmDestinationInstance* destinationInstance = CCmmDestinationInstance::NewLC( this, &iCache ); |
|
1637 |
|
1638 // Create a temporary ID to be used until a real one is obtained from the database. |
|
1639 TUint32 temporaryId = iCache.NextFreeTemporaryId(); |
|
1640 |
|
1641 // Cache will create the destination data structure and copy the relevant |
|
1642 // data to the session instance. |
|
1643 iCache.CreateDestinationL( *destinationInstance, *destinationName, temporaryId ); |
|
1644 |
|
1645 iDestinationContainer->AddL( ( CObject* ) destinationInstance ); |
|
1646 TInt handle = iDestinationObjects->AddL( ( CObject* ) destinationInstance ); |
|
1647 destinationInstance->SetHandle( handle ); |
|
1648 CleanupStack::Pop( destinationInstance ); |
|
1649 CleanupStack::PopAndDestroy( destinationName ); |
|
1650 |
|
1651 TPckg<TInt> handlePckg( handle ); |
|
1652 TInt err = aMessage.Write( 3, handlePckg ); |
|
1653 if ( err ) |
|
1654 { |
|
1655 // Removes from object index and destroys the object. |
|
1656 iDestinationObjects->Remove( handle ); |
|
1657 User::Leave( err ); |
|
1658 } |
|
1659 |
|
1660 OstTraceFunctionExit0( CCMMSESSION_CREATEDESTINATIONWITHNAMEL_EXIT ); |
|
1661 } |
|
1662 |
|
1663 // ----------------------------------------------------------------------------- |
|
1664 // CCmmSession::CreateDestinationWithNameAndIdL |
|
1665 // ----------------------------------------------------------------------------- |
|
1666 // |
|
1667 void CCmmSession::CreateDestinationWithNameAndIdL( const RMessage2& aMessage ) |
|
1668 { |
|
1669 OstTraceFunctionEntry0( CCMMSESSION_CREATEDESTINATIONWITHNAMEANDIDL_ENTRY ); |
|
1670 |
|
1671 // Structure: |
|
1672 // - Check arguments. |
|
1673 // - Create session instance. |
|
1674 // - Ask cache to open/create target and put data to session instance. |
|
1675 // - Create subsession and complete message. |
|
1676 |
|
1677 // API side checks that ID is between 0x1000 - 0x1100, and converts if necessary. |
|
1678 TUint32 destinationId( (TUint32)aMessage.Int1() ); |
|
1679 |
|
1680 // Check that the ID is in valid range. |
|
1681 if ( destinationId <= KCmDefaultDestinationAPTagId || |
|
1682 destinationId >= KCmMaxDestinationAPTagId ) |
|
1683 { |
|
1684 User::Leave( KErrArgument ); |
|
1685 } |
|
1686 |
|
1687 // Check if a destination with given ID exists (or is already created but not saved). |
|
1688 if ( iCache.DestinationExistsWithId( destinationId ) || |
|
1689 iCache.DestinationOpenWithId( destinationId ) ) |
|
1690 { |
|
1691 User::Leave( KErrAlreadyExists ); |
|
1692 } |
|
1693 |
|
1694 // Load and check name. |
|
1695 TInt destNameLength = aMessage.GetDesLength( 0 ); |
|
1696 if ( destNameLength <= 0 ) |
|
1697 { |
|
1698 User::Leave( KErrArgument ); |
|
1699 } |
|
1700 |
|
1701 HBufC* destinationName = HBufC::NewLC( destNameLength ); |
|
1702 |
|
1703 TPtr ptrDestinationName = destinationName->Des(); |
|
1704 aMessage.ReadL( 0, ptrDestinationName ); |
|
1705 |
|
1706 // Check if a destination with given name exists (or is already created but not yet saved). |
|
1707 if ( iCache.DestinationExistsWithNameL( *destinationName, 0 ) || |
|
1708 iCache.NotSavedDestinationOpenWithNameL( *destinationName, 0 ) ) |
|
1709 { |
|
1710 User::Leave( KErrAlreadyExists ); |
|
1711 } |
|
1712 |
|
1713 CCmmDestinationInstance* destinationInstance = CCmmDestinationInstance::NewLC( this, &iCache ); |
|
1714 |
|
1715 // Cache will create the destination data structure and copy the relevant |
|
1716 // data to the session instance. |
|
1717 iCache.CreateDestinationL( *destinationInstance, *destinationName, destinationId ); |
|
1718 |
|
1719 iDestinationContainer->AddL( ( CObject* ) destinationInstance ); |
|
1720 TInt handle = iDestinationObjects->AddL( ( CObject* ) destinationInstance ); |
|
1721 destinationInstance->SetHandle( handle ); |
|
1722 CleanupStack::Pop( destinationInstance ); |
|
1723 CleanupStack::PopAndDestroy( destinationName ); |
|
1724 |
|
1725 TPckg<TInt> handlePckg( handle ); |
|
1726 TInt err = aMessage.Write( 3, handlePckg ); |
|
1727 if ( err ) |
|
1728 { |
|
1729 // Removes from object index and destroys the object. |
|
1730 iDestinationObjects->Remove( handle ); |
|
1731 User::Leave( err ); |
|
1732 } |
|
1733 |
|
1734 OstTraceFunctionExit0( CCMMSESSION_CREATEDESTINATIONWITHNAMEANDIDL_EXIT ); |
|
1735 } |
|
1736 |
|
1737 // ----------------------------------------------------------------------------- |
|
1738 // CCmmSession::CloseDestinationL |
|
1739 // ----------------------------------------------------------------------------- |
|
1740 // |
|
1741 void CCmmSession::CloseDestination( const RMessage2& aMessage ) |
|
1742 { |
|
1743 OstTraceFunctionEntry0( CCMMSESSION_CLOSEDESTINATION_ENTRY ); |
|
1744 |
|
1745 // Check first that the destination instance exists. |
|
1746 CObject* destinationObject = iDestinationObjects->At( aMessage.Int3() ); |
|
1747 if ( destinationObject ) |
|
1748 { |
|
1749 // Destination instance destructor will notify cache. |
|
1750 iDestinationObjects->Remove( aMessage.Int3() ); |
|
1751 } |
|
1752 |
|
1753 OstTraceFunctionExit0( CCMMSESSION_CLOSEDESTINATION_EXIT ); |
|
1754 } |
|
1755 |
|
1756 // ----------------------------------------------------------------------------- |
|
1757 // Return the connection method count from the provided destination. |
|
1758 // Embedded destinations are included. |
|
1759 // ----------------------------------------------------------------------------- |
|
1760 // |
|
1761 void CCmmSession::GetConnectionMehodCountL( const RMessage2& aMessage ) |
|
1762 { |
|
1763 OstTraceFunctionEntry0( CCMMSESSION_GETCONNECTIONMEHODCOUNTL_ENTRY ); |
|
1764 |
|
1765 CCmmDestinationInstance* destinationInstance = |
|
1766 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1767 |
|
1768 TInt connMethodCount( destinationInstance->iConnMethodItemArray.Count() ); // Includes embedded destinations. |
|
1769 |
|
1770 TPckg<TInt> countPckg( connMethodCount ); |
|
1771 aMessage.WriteL( 0, countPckg ); |
|
1772 |
|
1773 OstTraceFunctionExit0( CCMMSESSION_GETCONNECTIONMEHODCOUNTL_EXIT ); |
|
1774 } |
|
1775 |
|
1776 // ----------------------------------------------------------------------------- |
|
1777 // CCmmSession::GetConnMethodPriorityL |
|
1778 // ----------------------------------------------------------------------------- |
|
1779 // |
|
1780 void CCmmSession::GetConnMethodPriorityL( const RMessage2& aMessage ) |
|
1781 { |
|
1782 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODPRIORITYL_ENTRY ); |
|
1783 |
|
1784 CCmmDestinationInstance* destinationInstance = |
|
1785 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1786 |
|
1787 CCmmConnMethodInstance* connMethodInstance = |
|
1788 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
1789 TUint32 connMethodId = connMethodInstance->GetId(); |
|
1790 |
|
1791 TInt index( KErrNotFound ); |
|
1792 for ( TInt i = 0; i < destinationInstance->iConnMethodItemArray.Count(); i++ ) |
|
1793 { |
|
1794 if ( destinationInstance->iConnMethodItemArray[i].iId == connMethodId ) |
|
1795 { |
|
1796 // Index in the connection method array is the connection method |
|
1797 // priority. But priority starts from 1, so adjust by +1. |
|
1798 index = i + 1; |
|
1799 break; |
|
1800 } |
|
1801 } |
|
1802 |
|
1803 // Leave if given connection method is not inside this destination. |
|
1804 User::LeaveIfError( index ); |
|
1805 |
|
1806 // Check if the connection method is an embedded destination. |
|
1807 if ( connMethodInstance->GetBearerType() == KUidEmbeddedDestination ) |
|
1808 { |
|
1809 index = CMManager::KDataMobilitySelectionPolicyPriorityWildCard; |
|
1810 } |
|
1811 |
|
1812 //TODO, what if CM is virtual? |
|
1813 |
|
1814 TUint priority = ( TUint )index; |
|
1815 TPckg<TUint> priorityPckg( priority ); |
|
1816 aMessage.WriteL( 1, priorityPckg ); |
|
1817 |
|
1818 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODPRIORITYL_EXIT ); |
|
1819 } |
|
1820 |
|
1821 // ----------------------------------------------------------------------------- |
|
1822 // CCmmSession::GetDestinationNameL |
|
1823 // ----------------------------------------------------------------------------- |
|
1824 // |
|
1825 void CCmmSession::GetDestinationNameL( const RMessage2& aMessage ) |
|
1826 { |
|
1827 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONNAMEL_ENTRY ); |
|
1828 |
|
1829 CCmmDestinationInstance* destinationInstance = |
|
1830 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1831 |
|
1832 HBufC* name = destinationInstance->GetLocalisedDestinationNameL(); |
|
1833 CleanupStack::PushL( name ); |
|
1834 TPtrC namePtr( name->Des() ); |
|
1835 |
|
1836 TInt bufferLen = aMessage.GetDesMaxLength( 0 ); |
|
1837 if ( namePtr.Length() > bufferLen ) |
|
1838 { |
|
1839 User::Leave( KErrArgument ); |
|
1840 } |
|
1841 |
|
1842 aMessage.WriteL( 0, namePtr ); |
|
1843 |
|
1844 CleanupStack::PopAndDestroy( name ); |
|
1845 |
|
1846 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONNAMEL_EXIT ); |
|
1847 } |
|
1848 |
|
1849 // ----------------------------------------------------------------------------- |
|
1850 // CCmmSession::GetDestinationIdL |
|
1851 // ----------------------------------------------------------------------------- |
|
1852 // |
|
1853 void CCmmSession::GetDestinationIdL( const RMessage2& aMessage ) |
|
1854 { |
|
1855 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONIDL_ENTRY ); |
|
1856 |
|
1857 CCmmDestinationInstance* destinationInstance = |
|
1858 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1859 |
|
1860 TUint32 id = destinationInstance->GetRecordTagFromApRecordL(); |
|
1861 TPckg<TUint32> idPckg( id ); |
|
1862 aMessage.WriteL( 0, idPckg ); |
|
1863 |
|
1864 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONIDL_EXIT ); |
|
1865 } |
|
1866 |
|
1867 // ----------------------------------------------------------------------------- |
|
1868 // CCmmSession::GetDestinationElementIdL |
|
1869 // ----------------------------------------------------------------------------- |
|
1870 // |
|
1871 void CCmmSession::GetDestinationElementIdL( const RMessage2& aMessage ) |
|
1872 { |
|
1873 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONELEMENTIDL_ENTRY ); |
|
1874 |
|
1875 CCmmDestinationInstance* destinationInstance = |
|
1876 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1877 |
|
1878 TUint32 elementId = destinationInstance->GetElementIdL(); |
|
1879 TPckg<TUint32> elementIdPckg( elementId ); |
|
1880 aMessage.WriteL( 0, elementIdPckg ); |
|
1881 |
|
1882 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONELEMENTIDL_EXIT ); |
|
1883 } |
|
1884 |
|
1885 // ----------------------------------------------------------------------------- |
|
1886 // CCmmSession::GetDestinationMetadataL |
|
1887 // ----------------------------------------------------------------------------- |
|
1888 // |
|
1889 void CCmmSession::GetDestinationMetadataL( const RMessage2& aMessage ) |
|
1890 { |
|
1891 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONMETADATAL_ENTRY ); |
|
1892 |
|
1893 CCmmDestinationInstance* destinationInstance = |
|
1894 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1895 CMManager::TSnapMetadataField metadataField = |
|
1896 ( CMManager::TSnapMetadataField )aMessage.Int0(); |
|
1897 |
|
1898 TUint32 metadata( 0 ); |
|
1899 destinationInstance->GetMetadataL( metadataField, metadata ); |
|
1900 |
|
1901 TPckg<TUint32> metadataPckg( metadata ); |
|
1902 aMessage.WriteL( 1, metadataPckg ); |
|
1903 |
|
1904 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONMETADATAL_EXIT ); |
|
1905 } |
|
1906 |
|
1907 // ----------------------------------------------------------------------------- |
|
1908 // CCmmSession::GetDestinationProtectionLevelL |
|
1909 // ----------------------------------------------------------------------------- |
|
1910 // |
|
1911 void CCmmSession::GetDestinationProtectionLevelL( const RMessage2& aMessage ) |
|
1912 { |
|
1913 OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONPROTECTIONLEVELL_ENTRY ); |
|
1914 |
|
1915 CCmmDestinationInstance* destinationInstance = |
|
1916 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1917 |
|
1918 CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 ); |
|
1919 destinationInstance->GetProtectionL( protLevel ); |
|
1920 |
|
1921 TPckg<TInt> protLevelPckg( protLevel ); |
|
1922 aMessage.WriteL( 0, protLevelPckg ); |
|
1923 |
|
1924 OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONPROTECTIONLEVELL_EXIT ); |
|
1925 } |
|
1926 |
|
1927 // ----------------------------------------------------------------------------- |
|
1928 // CCmmSession::IsDestinationConnectedL |
|
1929 // ----------------------------------------------------------------------------- |
|
1930 // |
|
1931 void CCmmSession::IsDestinationConnectedL( const RMessage2& aMessage ) |
|
1932 { |
|
1933 OstTraceFunctionEntry0( CCMMSESSION_ISDESTINATIONCONNECTEDL_ENTRY ); |
|
1934 |
|
1935 CCmmDestinationInstance* destinationInstance = |
|
1936 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1937 |
|
1938 if ( !iCache.DestinationExistsWithId( destinationInstance->GetId() ) ) |
|
1939 { |
|
1940 User::Leave( KErrNotFound ); |
|
1941 } |
|
1942 |
|
1943 TBool isConnected = iCache.DestinationConnectedL( destinationInstance->GetId() ); |
|
1944 TPckg<TBool> isConnectedPckg( isConnected ); |
|
1945 aMessage.WriteL( 0, isConnectedPckg ); |
|
1946 |
|
1947 OstTraceFunctionExit0( CCMMSESSION_ISDESTINATIONCONNECTEDL_EXIT ); |
|
1948 } |
|
1949 |
|
1950 // ----------------------------------------------------------------------------- |
|
1951 // CCmmSession::IsDestinationHiddenL |
|
1952 // ----------------------------------------------------------------------------- |
|
1953 // |
|
1954 void CCmmSession::IsDestinationHiddenL( const RMessage2& aMessage ) |
|
1955 { |
|
1956 OstTraceFunctionEntry0( CCMMSESSION_ISDESTINATIONHIDDENL_ENTRY ); |
|
1957 |
|
1958 CCmmDestinationInstance* destinationInstance = |
|
1959 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1960 |
|
1961 TUint32 isHiddenMetadata( 0 ); |
|
1962 destinationInstance->GetMetadataL( CMManager::ESnapMetadataHiddenAgent, isHiddenMetadata ); |
|
1963 |
|
1964 TBool isHidden( EFalse ); |
|
1965 if ( isHiddenMetadata ) |
|
1966 { |
|
1967 isHidden = ETrue; |
|
1968 } |
|
1969 |
|
1970 TPckg<TBool> isHiddenPckg( isHidden ); |
|
1971 aMessage.WriteL( 0, isHiddenPckg ); |
|
1972 |
|
1973 OstTraceFunctionExit0( CCMMSESSION_ISDESTINATIONHIDDENL_EXIT ); |
|
1974 } |
|
1975 |
|
1976 // ----------------------------------------------------------------------------- |
|
1977 // Checks if the destination given as parameter is equal to this destination |
|
1978 // ----------------------------------------------------------------------------- |
|
1979 // |
|
1980 void CCmmSession::DestinationIsEqualL( const RMessage2& aMessage ) |
|
1981 { |
|
1982 OstTraceFunctionEntry0( CCMMSESSION_DESTINATIONISEQUALL_ENTRY ); |
|
1983 |
|
1984 CCmmDestinationInstance* dest = |
|
1985 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
1986 |
|
1987 CCmmDestinationInstance* destToBeCompared = |
|
1988 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() ); |
|
1989 |
|
1990 TBool equal( EFalse ); |
|
1991 if ( dest->GetId() == destToBeCompared->GetId() ) |
|
1992 { |
|
1993 equal = ETrue; |
|
1994 } |
|
1995 |
|
1996 TPckg<TBool> equalPckg( equal ); |
|
1997 |
|
1998 aMessage.WriteL( 1, equalPckg ); |
|
1999 |
|
2000 OstTraceFunctionExit0( CCMMSESSION_DESTINATIONISEQUALL_EXIT ); |
|
2001 } |
|
2002 |
|
2003 |
|
2004 // ----------------------------------------------------------------------------- |
|
2005 // Adds a connection method into a destination. Does not add embedded |
|
2006 // destinations. |
|
2007 // ----------------------------------------------------------------------------- |
|
2008 // |
|
2009 void CCmmSession::DestAddConnMethodL( const RMessage2& aMessage ) |
|
2010 { |
|
2011 OstTraceFunctionEntry0( CCMMSESSION_DESTADDCONNMETHODL_ENTRY ); |
|
2012 |
|
2013 CCmmDestinationInstance* destination = |
|
2014 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2015 CCmmConnMethodInstance* connMethod = |
|
2016 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2017 |
|
2018 if ( connMethod->IsEmbeddedDestination() ) |
|
2019 { |
|
2020 User::Leave( KErrArgument ); |
|
2021 } |
|
2022 |
|
2023 TInt index = destination->AddConnMethodL( *connMethod ); |
|
2024 TPckg<TInt> indexPckg( index ); |
|
2025 aMessage.WriteL( 1, indexPckg ); |
|
2026 |
|
2027 OstTraceFunctionExit0( CCMMSESSION_DESTADDCONNMETHODL_EXIT ); |
|
2028 } |
|
2029 |
|
2030 // ----------------------------------------------------------------------------- |
|
2031 // Adds a destination into a destination as an embedded destination. |
|
2032 // ----------------------------------------------------------------------------- |
|
2033 // |
|
2034 void CCmmSession::DestAddEmbeddedDestinationL( const RMessage2& aMessage ) |
|
2035 { |
|
2036 OstTraceFunctionEntry0( CCMMSESSION_DESTADDEMBEDDEDDESTINATIONL_ENTRY ); |
|
2037 |
|
2038 CCmmDestinationInstance* destination = |
|
2039 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2040 CCmmDestinationInstance* embeddedDestination = |
|
2041 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() ); |
|
2042 |
|
2043 TInt index = destination->AddEmbeddedDestinationL( *embeddedDestination ); |
|
2044 TPckg<TInt> indexPckg( index ); |
|
2045 aMessage.WriteL( 1, indexPckg ); |
|
2046 |
|
2047 OstTraceFunctionExit0( CCMMSESSION_DESTADDEMBEDDEDDESTINATIONL_EXIT ); |
|
2048 } |
|
2049 |
|
2050 // ----------------------------------------------------------------------------- |
|
2051 // CCmmSession::DestDeleteConnMethodL |
|
2052 // ----------------------------------------------------------------------------- |
|
2053 // |
|
2054 void CCmmSession::DestDeleteConnMethodL( const RMessage2& aMessage ) |
|
2055 { |
|
2056 OstTraceFunctionEntry0( CCMMSESSION_DESTDELETECONNMETHODL_ENTRY ); |
|
2057 |
|
2058 CCmmDestinationInstance* destinationInstance = |
|
2059 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2060 CCmmConnMethodInstance* connMethodInstance = |
|
2061 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2062 |
|
2063 //TODO, capability checks |
|
2064 |
|
2065 destinationInstance->DeleteConnMethodFromDestinationL( *connMethodInstance ); |
|
2066 |
|
2067 OstTraceFunctionExit0( CCMMSESSION_DESTDELETECONNMETHODL_EXIT ); |
|
2068 } |
|
2069 |
|
2070 // ----------------------------------------------------------------------------- |
|
2071 // CCmmSession::DestRemoveConnMethodL |
|
2072 // ----------------------------------------------------------------------------- |
|
2073 // |
|
2074 void CCmmSession::DestRemoveConnMethodL( const RMessage2& aMessage ) |
|
2075 { |
|
2076 OstTraceFunctionEntry0( CCMMSESSION_DESTREMOVECONNMETHODL_ENTRY ); |
|
2077 |
|
2078 CCmmDestinationInstance* destinationInstance = |
|
2079 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2080 CCmmConnMethodInstance* connMethodInstance = |
|
2081 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2082 |
|
2083 //TODO, capability checks |
|
2084 |
|
2085 destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance ); |
|
2086 |
|
2087 OstTraceFunctionExit0( CCMMSESSION_DESTREMOVECONNMETHODL_EXIT ); |
|
2088 } |
|
2089 |
|
2090 // ----------------------------------------------------------------------------- |
|
2091 // CCmmSession::ModifyConnMethodPriorityL |
|
2092 // ----------------------------------------------------------------------------- |
|
2093 // |
|
2094 void CCmmSession::ModifyConnMethodPriorityL( const RMessage2& aMessage ) |
|
2095 { |
|
2096 OstTraceFunctionEntry0( CCMMSESSION_MODIFYCONNMETHODPRIORITYL_ENTRY ); |
|
2097 |
|
2098 CCmmDestinationInstance* destinationInstance = |
|
2099 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2100 CCmmConnMethodInstance* connMethodInstance = |
|
2101 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2102 |
|
2103 //TODO, capability checks |
|
2104 |
|
2105 // Index values start from 0 (0 meaning highest priority). |
|
2106 TUint index( ( TUint )aMessage.Int1() ); |
|
2107 |
|
2108 destinationInstance->ModifyConnMethodPriorityL( *connMethodInstance, index ); |
|
2109 |
|
2110 OstTraceFunctionExit0( CCMMSESSION_MODIFYCONNMETHODPRIORITYL_EXIT ); |
|
2111 } |
|
2112 |
|
2113 // ----------------------------------------------------------------------------- |
|
2114 // CCmmSession::SetDestinationNameL |
|
2115 // ----------------------------------------------------------------------------- |
|
2116 // |
|
2117 void CCmmSession::SetDestinationNameL( const RMessage2& aMessage ) |
|
2118 { |
|
2119 OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONNAMEL_ENTRY ); |
|
2120 |
|
2121 CCmmDestinationInstance* destinationInstance = |
|
2122 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2123 |
|
2124 // Load and check name. |
|
2125 TInt destNameLength = aMessage.GetDesLength( 0 ); |
|
2126 if ( destNameLength <= 0 ) |
|
2127 { |
|
2128 User::Leave( KErrArgument ); //TODO, check also max length? |
|
2129 } |
|
2130 |
|
2131 HBufC* newName = HBufC::NewLC( destNameLength ); |
|
2132 TPtr ptrNewName = newName->Des(); |
|
2133 aMessage.ReadL( 0, ptrNewName ); |
|
2134 |
|
2135 // Check if a destination with given name exists (or is already created but not yet saved). |
|
2136 if ( iCache.DestinationExistsWithNameL( *newName, destinationInstance->GetId() ) || |
|
2137 iCache.NotSavedDestinationOpenWithNameL( *newName, destinationInstance->GetId() ) ) |
|
2138 { |
|
2139 User::Leave( KErrAlreadyExists ); |
|
2140 } |
|
2141 |
|
2142 destinationInstance->SetDestinationNameL( *newName ); |
|
2143 |
|
2144 CleanupStack::PopAndDestroy( newName ); |
|
2145 |
|
2146 OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONNAMEL_EXIT ); |
|
2147 } |
|
2148 |
|
2149 // ----------------------------------------------------------------------------- |
|
2150 // CCmmSession::SetDestinationMetadataL |
|
2151 // ----------------------------------------------------------------------------- |
|
2152 // |
|
2153 void CCmmSession::SetDestinationMetadataL( const RMessage2& aMessage ) |
|
2154 { |
|
2155 OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONMETADATAL_ENTRY ); |
|
2156 |
|
2157 //TODO, Capability check. Protection level or Internet destination. |
|
2158 |
|
2159 CCmmDestinationInstance* destinationInstance = |
|
2160 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2161 |
|
2162 CMManager::TSnapMetadataField metadataField = |
|
2163 ( CMManager::TSnapMetadataField )aMessage.Int0(); |
|
2164 TUint32 metadata = aMessage.Int1(); |
|
2165 |
|
2166 destinationInstance->SetMetadataL( metadataField, metadata ); |
|
2167 |
|
2168 OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONMETADATAL_EXIT ); |
|
2169 } |
|
2170 |
|
2171 // ----------------------------------------------------------------------------- |
|
2172 // CCmmSession::SetDestinationProtectionL |
|
2173 // ----------------------------------------------------------------------------- |
|
2174 // |
|
2175 void CCmmSession::SetDestinationProtectionL( const RMessage2& aMessage ) |
|
2176 { |
|
2177 OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONPROTECTIONL_ENTRY ); |
|
2178 |
|
2179 //TODO, Capability check: ECapabilityNetworkControl |
|
2180 |
|
2181 CCmmDestinationInstance* destinationInstance = |
|
2182 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2183 CMManager::TProtectionLevel protLevel = |
|
2184 ( CMManager::TProtectionLevel )aMessage.Int0(); |
|
2185 destinationInstance->SetProtectionL( protLevel ); |
|
2186 |
|
2187 OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONPROTECTIONL_EXIT ); |
|
2188 } |
|
2189 |
|
2190 // ----------------------------------------------------------------------------- |
|
2191 // CCmmSession::SetDestinationHiddenL |
|
2192 // ----------------------------------------------------------------------------- |
|
2193 // |
|
2194 void CCmmSession::SetDestinationHiddenL( const RMessage2& aMessage ) |
|
2195 { |
|
2196 OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONHIDDENL_ENTRY ); |
|
2197 |
|
2198 CCmmDestinationInstance* destinationInstance = |
|
2199 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2200 |
|
2201 TBool hidden = aMessage.Int0(); |
|
2202 destinationInstance->SetMetadataL( CMManager::ESnapMetadataHiddenAgent, hidden ); |
|
2203 |
|
2204 OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONHIDDENL_EXIT ); |
|
2205 } |
|
2206 |
|
2207 // ----------------------------------------------------------------------------- |
|
2208 // CCmmSession::UpdateDestinationL |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // |
|
2211 void CCmmSession::UpdateDestinationL( const RMessage2& aMessage ) |
|
2212 { |
|
2213 OstTraceFunctionEntry0( CCMMSESSION_UPDATEDESTINATIONL_ENTRY ); |
|
2214 |
|
2215 CCmmDestinationInstance* destinationInstance = |
|
2216 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2217 destinationInstance->UpdateL(); |
|
2218 |
|
2219 OstTraceFunctionExit0( CCMMSESSION_UPDATEDESTINATIONL_EXIT ); |
|
2220 } |
|
2221 |
|
2222 // ----------------------------------------------------------------------------- |
|
2223 // CCmmSession::DeleteDestinationL |
|
2224 // ----------------------------------------------------------------------------- |
|
2225 // |
|
2226 void CCmmSession::DeleteDestinationL( const RMessage2& aMessage ) |
|
2227 { |
|
2228 OstTraceFunctionEntry0( CCMMSESSION_DELETEDESTINATIONL_ENTRY ); |
|
2229 |
|
2230 CCmmDestinationInstance* destinationInstance = |
|
2231 ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() ); |
|
2232 |
|
2233 iCache.CheckIfDestinationCanBeDeletedL( *destinationInstance ); |
|
2234 iCache.DeleteDestinationL( *destinationInstance ); |
|
2235 |
|
2236 // Close the destination handle. Destination instance destructor will |
|
2237 // notify cache. If the reference count for the cache side handle goes to |
|
2238 // zero, it will be deleted. |
|
2239 iDestinationObjects->Remove( aMessage.Int3() ); |
|
2240 |
|
2241 OstTraceFunctionExit0( CCMMSESSION_DELETEDESTINATIONL_EXIT ); |
|
2242 } |
|
2243 |
|
2244 // ----------------------------------------------------------------------------- |
|
2245 // CCmmSession::ServiceConnMethodL |
|
2246 // ----------------------------------------------------------------------------- |
|
2247 // |
|
2248 void CCmmSession::ServiceConnMethodL( const RMessage2& aMessage ) |
|
2249 { |
|
2250 OstTraceFunctionEntry0( CCMMSESSION_SERVICECONNMETHODL_ENTRY ); |
|
2251 |
|
2252 switch ( aMessage.Function() ) |
|
2253 { |
|
2254 case ECMCreateConnMethod: |
|
2255 { |
|
2256 CreateConnMethodL( aMessage ); |
|
2257 } |
|
2258 break; |
|
2259 case ECMUpdate: |
|
2260 { |
|
2261 UpdateConnMethodL( aMessage ); |
|
2262 } |
|
2263 break; |
|
2264 case ECMCloseConnMethod: |
|
2265 { |
|
2266 CloseConnMethod( aMessage ); // Can't leave. |
|
2267 } |
|
2268 break; |
|
2269 case ECMDelete: |
|
2270 { |
|
2271 DeleteConnMethodL( aMessage ); |
|
2272 } |
|
2273 break; |
|
2274 case ECMGetConnMethodWithId: |
|
2275 { |
|
2276 GetConnMethodWithIdL( aMessage ); |
|
2277 } |
|
2278 break; |
|
2279 case ECMRefresh: |
|
2280 { |
|
2281 RefreshConnMethodL( aMessage ); |
|
2282 } |
|
2283 break; |
|
2284 case ECMGetIntAttribute: |
|
2285 { |
|
2286 GetIntAttributeL( aMessage ); |
|
2287 } |
|
2288 break; |
|
2289 case ECMGetBoolAttribute: |
|
2290 { |
|
2291 GetBoolAttributeL( aMessage ); |
|
2292 } |
|
2293 break; |
|
2294 case ECMGetStringAttribute: |
|
2295 { |
|
2296 GetStringAttributeL( aMessage ); |
|
2297 } |
|
2298 break; |
|
2299 case ECMGetString8Attribute: |
|
2300 { |
|
2301 GetString8AttributeL( aMessage ); |
|
2302 } |
|
2303 break; |
|
2304 case ECMSetIntAttribute: |
|
2305 { |
|
2306 SetIntAttributeL( aMessage ); |
|
2307 } |
|
2308 break; |
|
2309 case ECMSetBoolAttribute: |
|
2310 { |
|
2311 SetBoolAttributeL( aMessage ); |
|
2312 } |
|
2313 break; |
|
2314 case ECMSetStringAttribute: |
|
2315 { |
|
2316 SetStringAttributeL( aMessage ); |
|
2317 } |
|
2318 break; |
|
2319 case ECMSetString8Attribute: |
|
2320 { |
|
2321 SetString8AttributeL( aMessage ); |
|
2322 } |
|
2323 break; |
|
2324 case ECMCreateConnMethodWithId: |
|
2325 { |
|
2326 CreateConnMethodWithIdL( aMessage ); |
|
2327 } |
|
2328 break; |
|
2329 case ECMGetConnMethodFromDestWithIndex: |
|
2330 { |
|
2331 GetConnMethodFromDestWithIndexL( aMessage ); |
|
2332 } |
|
2333 break; |
|
2334 case ECMGetConnMethodFromDestWithId: |
|
2335 { |
|
2336 GetConnMethodFromDestWithIdL( aMessage ); |
|
2337 } |
|
2338 break; |
|
2339 case ECMCreateConnMethodToDest: |
|
2340 { |
|
2341 CreateConnMethodToDestL( aMessage ); |
|
2342 } |
|
2343 break; |
|
2344 case ECMCreateConnMethodToDestWithId: |
|
2345 { |
|
2346 CreateConnMethodToDestWithIdL( aMessage ); |
|
2347 } |
|
2348 break; |
|
2349 case ECMIsEqual: |
|
2350 { |
|
2351 CmIsEqualL( aMessage ); |
|
2352 } |
|
2353 break; |
|
2354 case ECMCreateCopyOfExisting: |
|
2355 { |
|
2356 CreateCopyOfExistingL( aMessage ); |
|
2357 } |
|
2358 break; |
|
2359 case EDestGetEmbeddedDestination: |
|
2360 { |
|
2361 GetEmbeddedDestinationL( aMessage ); |
|
2362 } |
|
2363 break; |
|
2364 default: |
|
2365 { |
|
2366 User::Leave( KErrNotSupported ); |
|
2367 } |
|
2368 } |
|
2369 |
|
2370 OstTraceFunctionExit0( CCMMSESSION_SERVICECONNMETHODL_EXIT ); |
|
2371 } |
|
2372 |
|
2373 // ----------------------------------------------------------------------------- |
|
2374 // Create a new connection method (not embedded destination). |
|
2375 // ----------------------------------------------------------------------------- |
|
2376 // |
|
2377 void CCmmSession::CreateConnMethodL( const RMessage2& aMessage ) |
|
2378 { |
|
2379 OstTraceFunctionEntry0( CCMMSESSION_CREATECONNMETHODL_ENTRY ); |
|
2380 |
|
2381 TUint32 bearerType( aMessage.Int0() ); |
|
2382 |
|
2383 CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2384 iCache.CreateConnMethodL( *connMethod, NULL, bearerType, 0 ); |
|
2385 |
|
2386 iConnMethodContainer->AddL( ( CObject* ) connMethod ); |
|
2387 TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod ); |
|
2388 connMethod->SetHandle( handle ); |
|
2389 CleanupStack::Pop( connMethod ); |
|
2390 |
|
2391 TPckg<TInt> handlePckg( handle ); |
|
2392 TInt error = aMessage.Write( 3, handlePckg ); |
|
2393 if ( error ) |
|
2394 { |
|
2395 // Remove from object index and destroy the object. |
|
2396 iConnMethodObjects->Remove( handle ); |
|
2397 User::Leave( error ); |
|
2398 } |
|
2399 |
|
2400 OstTraceFunctionExit0( CCMMSESSION_CREATECONNMETHODL_EXIT ); |
|
2401 } |
|
2402 |
|
2403 // ----------------------------------------------------------------------------- |
|
2404 // CCmmSession::ConnMethodUpdateL |
|
2405 // ----------------------------------------------------------------------------- |
|
2406 // |
|
2407 void CCmmSession::UpdateConnMethodL( const RMessage2& aMessage ) |
|
2408 { |
|
2409 OstTraceFunctionEntry0( CCMMSESSION_UPDATECONNMETHODL_ENTRY ); |
|
2410 |
|
2411 CCmmConnMethodInstance* connMethod = |
|
2412 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2413 connMethod->UpdateL(); |
|
2414 |
|
2415 OstTraceFunctionExit0( CCMMSESSION_UPDATECONNMETHODL_EXIT ); |
|
2416 } |
|
2417 |
|
2418 // ----------------------------------------------------------------------------- |
|
2419 // CCmmSession::CloseConnMethod |
|
2420 // ----------------------------------------------------------------------------- |
|
2421 // |
|
2422 void CCmmSession::CloseConnMethod( const RMessage2& aMessage ) |
|
2423 { |
|
2424 OstTraceFunctionEntry0( CCMMSESSION_CLOSECONNMETHOD_ENTRY ); |
|
2425 |
|
2426 // Check first that the connection method instance exists. |
|
2427 CObject* connMethodObject = iConnMethodObjects->At( aMessage.Int3() ); |
|
2428 if ( connMethodObject ) |
|
2429 { |
|
2430 // Connection method instance destructor will notify cache. |
|
2431 iConnMethodObjects->Remove( aMessage.Int3() ); |
|
2432 } |
|
2433 |
|
2434 OstTraceFunctionExit0( CCMMSESSION_CLOSECONNMETHOD_EXIT ); |
|
2435 } |
|
2436 |
|
2437 // ----------------------------------------------------------------------------- |
|
2438 // CCmmSession::ConnMethodUpdateL |
|
2439 // ----------------------------------------------------------------------------- |
|
2440 // |
|
2441 void CCmmSession::DeleteConnMethodL( const RMessage2& aMessage ) |
|
2442 { |
|
2443 OstTraceFunctionEntry0( CCMMSESSION_DELETECONNMETHODL_ENTRY ); |
|
2444 |
|
2445 CCmmConnMethodInstance* connMethodInstance = |
|
2446 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2447 |
|
2448 iCache.CheckIfConnMethodCanBeDeletedL( *connMethodInstance ); |
|
2449 iCache.DeleteConnMethodL( *connMethodInstance ); |
|
2450 // Ignore the boolean return value. It is always true, or the |
|
2451 // DeleteL()-call leaves. |
|
2452 |
|
2453 // Close the connection method handle. Connection method instance |
|
2454 // destructor will notify cache. If the reference count for the cache side |
|
2455 // handle goes to zero, it will be deleted. |
|
2456 iConnMethodObjects->Remove( aMessage.Int3() ); |
|
2457 |
|
2458 OstTraceFunctionExit0( CCMMSESSION_DELETECONNMETHODL_EXIT ); |
|
2459 } |
|
2460 |
|
2461 // ----------------------------------------------------------------------------- |
|
2462 // CCmmSession::GetConnMethodWithIdL |
|
2463 // ----------------------------------------------------------------------------- |
|
2464 // |
|
2465 void CCmmSession::GetConnMethodWithIdL( const RMessage2& aMessage ) |
|
2466 { |
|
2467 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODWITHIDL_ENTRY ); |
|
2468 |
|
2469 TUint32 connMethodId = aMessage.Int0(); |
|
2470 |
|
2471 // If this session already has a connection method with matching id open, |
|
2472 // provide the client with a reference to the already opened handle. |
|
2473 CCmmConnMethodInstance* cmInstance = FindConnMethodInstanceById( connMethodId ); |
|
2474 if ( cmInstance ) |
|
2475 { |
|
2476 // Also check that the connection method exists in database. |
|
2477 if ( iCache.ConnMethodExistsWithId( connMethodId ) ) |
|
2478 { |
|
2479 TPckg<TInt> existingHandlePckg( cmInstance->GetHandle() ); |
|
2480 aMessage.WriteL( 1, existingHandlePckg ); |
|
2481 User::Leave( KErrAlreadyExists ); |
|
2482 } |
|
2483 } |
|
2484 cmInstance = NULL; |
|
2485 TPckg<TInt> existingHandlePckg( 0 ); |
|
2486 aMessage.WriteL( 1, existingHandlePckg ); |
|
2487 |
|
2488 cmInstance = CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2489 // Will check if connection method ID is valid. |
|
2490 iCache.OpenConnMethodL( *cmInstance, NULL, connMethodId ); |
|
2491 |
|
2492 iConnMethodContainer->AddL( ( CObject* ) cmInstance ); |
|
2493 TInt handle = iConnMethodObjects->AddL( ( CObject* ) cmInstance ); |
|
2494 cmInstance->SetHandle( handle ); |
|
2495 CleanupStack::Pop( cmInstance ); |
|
2496 |
|
2497 TPckg<TInt> handlePckg( handle ); |
|
2498 TInt error = aMessage.Write( 3, handlePckg ); |
|
2499 if ( error ) |
|
2500 { |
|
2501 // Remove from object index and destroy the object. |
|
2502 iConnMethodObjects->Remove( handle ); |
|
2503 User::Leave( error ); |
|
2504 } |
|
2505 |
|
2506 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODWITHIDL_EXIT ); |
|
2507 } |
|
2508 |
|
2509 // ----------------------------------------------------------------------------- |
|
2510 // CCmmSession::RefreshConnMethodL |
|
2511 // ----------------------------------------------------------------------------- |
|
2512 // |
|
2513 void CCmmSession::RefreshConnMethodL( const RMessage2& aMessage ) |
|
2514 { |
|
2515 OstTraceFunctionEntry0( CCMMSESSION_REFRESHCONNMETHODL_ENTRY ); |
|
2516 |
|
2517 CCmmConnMethodInstance* connMethodInstance = |
|
2518 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2519 |
|
2520 iCache.RefreshConnMethodL( *connMethodInstance ); |
|
2521 |
|
2522 OstTraceFunctionExit0( CCMMSESSION_REFRESHCONNMETHODL_EXIT ); |
|
2523 } |
|
2524 |
|
2525 // ----------------------------------------------------------------------------- |
|
2526 // CCmmSession::GetIntAttributeL |
|
2527 // ----------------------------------------------------------------------------- |
|
2528 // |
|
2529 void CCmmSession::GetIntAttributeL( const RMessage2& aMessage ) |
|
2530 { |
|
2531 OstTraceFunctionEntry0( CCMMSESSION_GETINTATTRIBUTEL_ENTRY ); |
|
2532 |
|
2533 CCmmConnMethodInstance* cm = |
|
2534 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2535 |
|
2536 TUint32 attribute( aMessage.Int0() ); |
|
2537 TUint32 value = cm->GetIntAttributeL( attribute ); |
|
2538 |
|
2539 TPckg<TUint32> valuePckg( value ); |
|
2540 aMessage.WriteL( 1, valuePckg ); |
|
2541 |
|
2542 OstTraceFunctionExit0( CCMMSESSION_GETINTATTRIBUTEL_EXIT ); |
|
2543 } |
|
2544 |
|
2545 // ----------------------------------------------------------------------------- |
|
2546 // CCmmSession::GetBoolAttributeL |
|
2547 // ----------------------------------------------------------------------------- |
|
2548 // |
|
2549 void CCmmSession::GetBoolAttributeL( const RMessage2& aMessage ) |
|
2550 { |
|
2551 OstTraceFunctionEntry0( CCMMSESSION_GETBOOLATTRIBUTEL_ENTRY ); |
|
2552 |
|
2553 CCmmConnMethodInstance* cm = |
|
2554 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2555 |
|
2556 TUint32 attribute( aMessage.Int0() ); |
|
2557 TBool value = cm->GetBoolAttributeL( attribute ); |
|
2558 |
|
2559 TPckg<TBool> valuePckg( value ); |
|
2560 aMessage.WriteL( 1, valuePckg ); |
|
2561 |
|
2562 OstTraceFunctionExit0( CCMMSESSION_GETBOOLATTRIBUTEL_EXIT ); |
|
2563 } |
|
2564 |
|
2565 // ----------------------------------------------------------------------------- |
|
2566 // CCmmSession::GetStringAttributeL |
|
2567 // ----------------------------------------------------------------------------- |
|
2568 // |
|
2569 void CCmmSession::GetStringAttributeL( const RMessage2& aMessage ) |
|
2570 { |
|
2571 OstTraceFunctionEntry0( CCMMSESSION_GETSTRINGATTRIBUTEL_ENTRY ); |
|
2572 |
|
2573 CCmmConnMethodInstance* cm = |
|
2574 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2575 |
|
2576 TUint32 attribute( aMessage.Int0() ); |
|
2577 HBufC* value = cm->GetStringAttributeL( attribute ); |
|
2578 if ( !value ) |
|
2579 { |
|
2580 OstTraceFunctionExit0( CCMMSESSION_GETSTRINGATTRIBUTEL_EXIT ); |
|
2581 return; |
|
2582 } |
|
2583 CleanupStack::PushL( value ); |
|
2584 TPtrC valuePtr = value->Des(); |
|
2585 |
|
2586 // check the buffer length of the given buffer |
|
2587 TInt bufferLen = aMessage.GetDesMaxLength( 1 ); |
|
2588 if ( valuePtr.Length() > bufferLen ) |
|
2589 { |
|
2590 User::Leave( KErrArgument ); |
|
2591 } |
|
2592 |
|
2593 aMessage.WriteL( 1, valuePtr ); |
|
2594 CleanupStack::PopAndDestroy( value ); |
|
2595 |
|
2596 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETSTRINGATTRIBUTEL_EXIT ); |
|
2597 } |
|
2598 |
|
2599 // ----------------------------------------------------------------------------- |
|
2600 // CCmmSession::GetString8AttributeL |
|
2601 // ----------------------------------------------------------------------------- |
|
2602 // |
|
2603 void CCmmSession::GetString8AttributeL( const RMessage2& aMessage ) |
|
2604 { |
|
2605 OstTraceFunctionEntry0( CCMMSESSION_GETSTRING8ATTRIBUTEL_ENTRY ); |
|
2606 |
|
2607 CCmmConnMethodInstance* cm = |
|
2608 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2609 |
|
2610 TUint32 attribute( aMessage.Int0() ); |
|
2611 HBufC8* value = cm->GetString8AttributeL( attribute ); |
|
2612 if ( !value ) |
|
2613 { |
|
2614 OstTraceFunctionExit0( CCMMSESSION_GETSTRING8ATTRIBUTEL_EXIT ); |
|
2615 return; |
|
2616 } |
|
2617 CleanupStack::PushL( value ); |
|
2618 TPtrC8 valuePtr = value->Des(); |
|
2619 |
|
2620 // check the buffer length of the given buffer |
|
2621 TInt bufferLen = aMessage.GetDesMaxLength( 1 ); |
|
2622 if ( valuePtr.Length() > bufferLen ) |
|
2623 { |
|
2624 User::Leave( KErrArgument ); |
|
2625 } |
|
2626 |
|
2627 aMessage.WriteL( 1, valuePtr ); |
|
2628 CleanupStack::PopAndDestroy( value ); |
|
2629 |
|
2630 OstTraceFunctionExit0( DUP1_CCMMSESSION_GETSTRING8ATTRIBUTEL_EXIT ); |
|
2631 } |
|
2632 |
|
2633 // ----------------------------------------------------------------------------- |
|
2634 // CCmmSession::SetIntAttributeL |
|
2635 // ----------------------------------------------------------------------------- |
|
2636 // |
|
2637 void CCmmSession::SetIntAttributeL( const RMessage2& aMessage ) |
|
2638 { |
|
2639 OstTraceFunctionEntry0( CCMMSESSION_SETINTATTRIBUTEL_ENTRY ); |
|
2640 |
|
2641 CCmmConnMethodInstance* cm = |
|
2642 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2643 |
|
2644 TUint32 attribute( aMessage.Int0() ); |
|
2645 TUint32 value( aMessage.Int1() ); |
|
2646 |
|
2647 cm->SetIntAttributeL( attribute, value ); |
|
2648 |
|
2649 OstTraceFunctionExit0( CCMMSESSION_SETINTATTRIBUTEL_EXIT ); |
|
2650 } |
|
2651 |
|
2652 // ----------------------------------------------------------------------------- |
|
2653 // CCmmSession::SetBoolAttributeL |
|
2654 // ----------------------------------------------------------------------------- |
|
2655 // |
|
2656 void CCmmSession::SetBoolAttributeL( const RMessage2& aMessage ) |
|
2657 { |
|
2658 OstTraceFunctionEntry0( CCMMSESSION_SETBOOLATTRIBUTEL_ENTRY ); |
|
2659 |
|
2660 CCmmConnMethodInstance* cm = |
|
2661 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2662 |
|
2663 TUint32 attribute( aMessage.Int0() ); |
|
2664 TBool value( aMessage.Int1() ); |
|
2665 |
|
2666 cm->SetBoolAttributeL( attribute, value ); |
|
2667 |
|
2668 OstTraceFunctionExit0( CCMMSESSION_SETBOOLATTRIBUTEL_EXIT ); |
|
2669 } |
|
2670 |
|
2671 // ----------------------------------------------------------------------------- |
|
2672 // CCmmSession::SetStringAttributeL |
|
2673 // ----------------------------------------------------------------------------- |
|
2674 // |
|
2675 void CCmmSession::SetStringAttributeL( const RMessage2& aMessage ) |
|
2676 { |
|
2677 OstTraceFunctionEntry0( CCMMSESSION_SETSTRINGATTRIBUTEL_ENTRY ); |
|
2678 |
|
2679 CCmmConnMethodInstance* cm = |
|
2680 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2681 |
|
2682 TUint32 attribute( aMessage.Int0() ); |
|
2683 |
|
2684 HBufC* value = HBufC::NewLC( aMessage.GetDesLengthL( 1 ) ); |
|
2685 TPtr valuePtr( value->Des() ); |
|
2686 aMessage.ReadL( 1, valuePtr ); |
|
2687 |
|
2688 cm->SetStringAttributeL( attribute, valuePtr ); |
|
2689 |
|
2690 CleanupStack::PopAndDestroy( value ); |
|
2691 |
|
2692 OstTraceFunctionExit0( CCMMSESSION_SETSTRINGATTRIBUTEL_EXIT ); |
|
2693 } |
|
2694 |
|
2695 // ----------------------------------------------------------------------------- |
|
2696 // CCmmSession::SetString8AttributeL |
|
2697 // ----------------------------------------------------------------------------- |
|
2698 // |
|
2699 void CCmmSession::SetString8AttributeL( const RMessage2& aMessage ) |
|
2700 { |
|
2701 OstTraceFunctionEntry0( CCMMSESSION_SETSTRING8ATTRIBUTEL_ENTRY ); |
|
2702 |
|
2703 CCmmConnMethodInstance* cm = |
|
2704 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2705 |
|
2706 TUint32 attribute( aMessage.Int0() ); |
|
2707 |
|
2708 HBufC8* value = HBufC8::NewLC( aMessage.GetDesLengthL( 1 ) ); |
|
2709 TPtr8 valuePtr( value->Des() ); |
|
2710 aMessage.ReadL( 1, valuePtr ); |
|
2711 |
|
2712 cm->SetString8AttributeL( attribute, valuePtr ); |
|
2713 |
|
2714 CleanupStack::PopAndDestroy( value ); |
|
2715 |
|
2716 OstTraceFunctionExit0( CCMMSESSION_SETSTRING8ATTRIBUTEL_EXIT ); |
|
2717 } |
|
2718 |
|
2719 // ----------------------------------------------------------------------------- |
|
2720 // Create a new connection method (not embedded destination) with specific ID. |
|
2721 // ----------------------------------------------------------------------------- |
|
2722 // |
|
2723 void CCmmSession::CreateConnMethodWithIdL( const RMessage2& aMessage ) |
|
2724 { |
|
2725 OstTraceFunctionEntry0( CCMMSESSION_CREATECONNMETHODWITHIDL_ENTRY ); |
|
2726 |
|
2727 TUint32 bearerType( aMessage.Int0() ); |
|
2728 TUint32 connMethodId = ( aMessage.Int1() ); |
|
2729 |
|
2730 CCmmConnMethodInstance* connMethod = |
|
2731 CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2732 // Will check if ID is available. |
|
2733 iCache.CreateConnMethodL( *connMethod, NULL, bearerType, connMethodId ); |
|
2734 |
|
2735 iConnMethodContainer->AddL( ( CObject* ) connMethod ); |
|
2736 TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod ); |
|
2737 connMethod->SetHandle( handle ); |
|
2738 CleanupStack::Pop( connMethod ); |
|
2739 |
|
2740 TPckg<TInt> handlePckg( handle ); |
|
2741 TInt error = aMessage.Write( 3, handlePckg ); |
|
2742 if ( error ) |
|
2743 { |
|
2744 // Remove from object index and destroy the object. |
|
2745 iConnMethodObjects->Remove( handle ); |
|
2746 User::Leave( error ); |
|
2747 } |
|
2748 |
|
2749 OstTraceFunctionExit0( CCMMSESSION_CREATECONNMETHODWITHIDL_EXIT ); |
|
2750 } |
|
2751 |
|
2752 // ----------------------------------------------------------------------------- |
|
2753 // Gets a Connection Method from a Destination with index number. |
|
2754 // ----------------------------------------------------------------------------- |
|
2755 // |
|
2756 void CCmmSession::GetConnMethodFromDestWithIndexL( const RMessage2& aMessage ) |
|
2757 { |
|
2758 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODFROMDESTWITHINDEXL_ENTRY ); |
|
2759 |
|
2760 TInt destinationHandle( aMessage.Int0() ); |
|
2761 TInt connMethodIndex( aMessage.Int1() ); |
|
2762 |
|
2763 CCmmDestinationInstance* destinationInstance = |
|
2764 ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle ); |
|
2765 |
|
2766 // Check index is in range. |
|
2767 if ( connMethodIndex < 0 || |
|
2768 connMethodIndex >= destinationInstance->iConnMethodItemArray.Count() ) |
|
2769 { |
|
2770 User::Leave( KErrArgument ); |
|
2771 } |
|
2772 TInt connMethodId( destinationInstance->iConnMethodItemArray[connMethodIndex].iId ); |
|
2773 |
|
2774 // If this session already has a connection method with matching id open |
|
2775 // and that connection method correctly belongs to the provided destination, |
|
2776 // provide the client with a reference to the already opened handle. |
|
2777 CCmmConnMethodInstance* cmInstance = FindConnMethodInstanceById( connMethodId ); |
|
2778 if ( cmInstance && |
|
2779 destinationInstance->ValidConnMethodIdInDestinationIncludeEmbedded( connMethodId ) ) |
|
2780 { |
|
2781 // Also check that the connection method exists in database. |
|
2782 if ( iCache.ConnMethodExistsWithId( connMethodId ) || |
|
2783 iCache.DestinationExistsWithId( connMethodId ) ) |
|
2784 { |
|
2785 TPckg<TInt> existingHandlePckg( cmInstance->GetHandle() ); |
|
2786 aMessage.WriteL( 2, existingHandlePckg ); |
|
2787 User::Leave( KErrAlreadyExists ); |
|
2788 } |
|
2789 } |
|
2790 cmInstance = NULL; |
|
2791 TPckg<TInt> existingHandlePckg( 0 ); |
|
2792 aMessage.WriteL( 2, existingHandlePckg ); |
|
2793 |
|
2794 cmInstance = CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2795 // Will check if connection method ID is valid. |
|
2796 iCache.OpenConnMethodL( *cmInstance, destinationInstance, connMethodId ); |
|
2797 |
|
2798 iConnMethodContainer->AddL( ( CObject* ) cmInstance ); |
|
2799 TInt handle = iConnMethodObjects->AddL( ( CObject* ) cmInstance ); |
|
2800 cmInstance->SetHandle( handle ); |
|
2801 CleanupStack::Pop( cmInstance ); |
|
2802 |
|
2803 TPckg<TInt> handlePckg( handle ); |
|
2804 TInt error = aMessage.Write( 3, handlePckg ); |
|
2805 if ( error ) |
|
2806 { |
|
2807 // Remove from object index and destroy the object. |
|
2808 iConnMethodObjects->Remove( handle ); |
|
2809 User::Leave( error ); |
|
2810 } |
|
2811 |
|
2812 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODFROMDESTWITHINDEXL_EXIT ); |
|
2813 } |
|
2814 |
|
2815 // ----------------------------------------------------------------------------- |
|
2816 // Gets a Connection Method from a Destination with Id. |
|
2817 // ----------------------------------------------------------------------------- |
|
2818 // |
|
2819 void CCmmSession::GetConnMethodFromDestWithIdL( const RMessage2& aMessage ) |
|
2820 { |
|
2821 OstTraceFunctionEntry0( CCMMSESSION_GETCONNMETHODFROMDESTWITHIDL_ENTRY ); |
|
2822 |
|
2823 TInt destinationHandle( aMessage.Int0() ); |
|
2824 TUint32 connMethodId( aMessage.Int1() ); |
|
2825 |
|
2826 CCmmDestinationInstance* destinationInstance = |
|
2827 ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle ); |
|
2828 |
|
2829 // If this session already has a connection method with matching id open |
|
2830 // and that connection method correctly belongs to the provided destination, |
|
2831 // provide the client with a reference to the already opened handle. |
|
2832 CCmmConnMethodInstance* cmInstance = FindConnMethodInstanceById( connMethodId ); |
|
2833 if ( cmInstance && |
|
2834 destinationInstance->ValidConnMethodIdInDestinationIncludeEmbedded( connMethodId ) ) |
|
2835 { |
|
2836 // Also check that the connection method exists in database. |
|
2837 if ( iCache.ConnMethodExistsWithId( connMethodId ) || |
|
2838 iCache.DestinationExistsWithId( connMethodId ) ) |
|
2839 { |
|
2840 TPckg<TInt> existingHandlePckg( cmInstance->GetHandle() ); |
|
2841 aMessage.WriteL( 2, existingHandlePckg ); |
|
2842 User::Leave( KErrAlreadyExists ); |
|
2843 } |
|
2844 } |
|
2845 cmInstance = NULL; |
|
2846 TPckg<TInt> existingHandlePckg( 0 ); |
|
2847 aMessage.WriteL( 2, existingHandlePckg ); |
|
2848 |
|
2849 cmInstance = CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2850 // Will check if connection method ID is valid. |
|
2851 iCache.OpenConnMethodL( *cmInstance, destinationInstance, connMethodId ); |
|
2852 |
|
2853 iConnMethodContainer->AddL( ( CObject* ) cmInstance ); |
|
2854 TInt handle = iConnMethodObjects->AddL( ( CObject* ) cmInstance ); |
|
2855 cmInstance->SetHandle( handle ); |
|
2856 CleanupStack::Pop( cmInstance ); |
|
2857 |
|
2858 TPckg<TInt> handlePckg( handle ); |
|
2859 TInt error = aMessage.Write( 3, handlePckg ); |
|
2860 if ( error ) |
|
2861 { |
|
2862 // Remove from object index and destroy the object. |
|
2863 iConnMethodObjects->Remove( handle ); |
|
2864 User::Leave( error ); |
|
2865 } |
|
2866 |
|
2867 OstTraceFunctionExit0( CCMMSESSION_GETCONNMETHODFROMDESTWITHIDL_EXIT ); |
|
2868 } |
|
2869 |
|
2870 // ----------------------------------------------------------------------------- |
|
2871 // Create a new connection method (not embedded destination) into a destination. |
|
2872 // ----------------------------------------------------------------------------- |
|
2873 // |
|
2874 void CCmmSession::CreateConnMethodToDestL( const RMessage2& aMessage ) |
|
2875 { |
|
2876 OstTraceFunctionEntry0( CCMMSESSION_CREATECONNMETHODTODESTL_ENTRY ); |
|
2877 |
|
2878 TInt destinationHandle( aMessage.Int0() ); |
|
2879 TUint32 bearerType( aMessage.Int1() ); |
|
2880 |
|
2881 CCmmDestinationInstance* destination = |
|
2882 ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle ); |
|
2883 |
|
2884 CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2885 iCache.CreateConnMethodL( *connMethod, destination, bearerType, 0 ); |
|
2886 |
|
2887 iConnMethodContainer->AddL( ( CObject* ) connMethod ); |
|
2888 TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod ); |
|
2889 connMethod->SetHandle( handle ); |
|
2890 CleanupStack::Pop( connMethod ); |
|
2891 |
|
2892 TPckg<TInt> handlePckg( handle ); |
|
2893 TInt error = aMessage.Write( 3, handlePckg ); |
|
2894 if ( error ) |
|
2895 { |
|
2896 // Remove from object index and destroy the object. |
|
2897 iConnMethodObjects->Remove( handle ); |
|
2898 User::Leave( error ); |
|
2899 } |
|
2900 |
|
2901 OstTraceFunctionExit0( CCMMSESSION_CREATECONNMETHODTODESTL_EXIT ); |
|
2902 } |
|
2903 |
|
2904 // ----------------------------------------------------------------------------- |
|
2905 // Create a new connection method (not embedded destination) with specific ID |
|
2906 // into a destination. |
|
2907 // ----------------------------------------------------------------------------- |
|
2908 // |
|
2909 void CCmmSession::CreateConnMethodToDestWithIdL( const RMessage2& aMessage ) |
|
2910 { |
|
2911 OstTraceFunctionEntry0( CCMMSESSION_CREATECONNMETHODTODESTWITHIDL_ENTRY ); |
|
2912 |
|
2913 TInt destinationHandle( aMessage.Int0() ); |
|
2914 TUint32 bearerType( aMessage.Int1() ); |
|
2915 TUint32 connMethodId( aMessage.Int2() ); |
|
2916 |
|
2917 CCmmDestinationInstance* destination = |
|
2918 ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle ); |
|
2919 |
|
2920 CCmmConnMethodInstance* connMethod = |
|
2921 CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2922 // Will check if ID is available. |
|
2923 iCache.CreateConnMethodL( *connMethod, destination, bearerType, connMethodId ); |
|
2924 |
|
2925 iConnMethodContainer->AddL( ( CObject* ) connMethod ); |
|
2926 TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod ); |
|
2927 connMethod->SetHandle( handle ); |
|
2928 CleanupStack::Pop( connMethod ); |
|
2929 |
|
2930 TPckg<TInt> handlePckg( handle ); |
|
2931 TInt error = aMessage.Write( 3, handlePckg ); |
|
2932 if ( error ) |
|
2933 { |
|
2934 // Remove from object index and destroy the object. |
|
2935 iConnMethodObjects->Remove( handle ); |
|
2936 User::Leave( error ); |
|
2937 } |
|
2938 |
|
2939 OstTraceFunctionExit0( CCMMSESSION_CREATECONNMETHODTODESTWITHIDL_EXIT ); |
|
2940 } |
|
2941 |
|
2942 // ----------------------------------------------------------------------------- |
|
2943 // Checks if the CM given as parameter is equal to this CM |
|
2944 // ----------------------------------------------------------------------------- |
|
2945 // |
|
2946 void CCmmSession::CmIsEqualL( const RMessage2& aMessage ) |
|
2947 { |
|
2948 OstTraceFunctionEntry0( CCMMSESSION_CMISEQUALL_ENTRY ); |
|
2949 |
|
2950 CCmmConnMethodInstance* cm = |
|
2951 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
2952 |
|
2953 CCmmConnMethodInstance* cmToBeCompared = |
|
2954 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2955 |
|
2956 TBool equal( EFalse ); |
|
2957 if ( cm->GetId() == cmToBeCompared->GetId() ) |
|
2958 { |
|
2959 equal = ETrue; |
|
2960 } |
|
2961 |
|
2962 TPckg<TBool> equalPckg( equal ); |
|
2963 aMessage.WriteL( 1, equalPckg ); |
|
2964 |
|
2965 OstTraceFunctionExit0( CCMMSESSION_CMISEQUALL_EXIT ); |
|
2966 } |
|
2967 |
|
2968 // ----------------------------------------------------------------------------- |
|
2969 // Creates a copy of an existing connection method and opens a handle to it. |
|
2970 // ----------------------------------------------------------------------------- |
|
2971 // |
|
2972 void CCmmSession::CreateCopyOfExistingL( const RMessage2& aMessage ) |
|
2973 { |
|
2974 OstTraceFunctionEntry0( CCMMSESSION_CREATECOPYOFEXISTINGL_ENTRY ); |
|
2975 |
|
2976 CCmmConnMethodInstance* sourceCm = |
|
2977 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() ); |
|
2978 TUint32 cmId = sourceCm->GetId(); |
|
2979 |
|
2980 CCmmConnMethodInstance* targetCm = |
|
2981 CCmmConnMethodInstance::NewLC( this, &iCache ); |
|
2982 iCache.CreateCopyOfConnMethodL( *targetCm, *sourceCm ); |
|
2983 |
|
2984 iConnMethodContainer->AddL( ( CObject* ) targetCm ); |
|
2985 TInt handle = iConnMethodObjects->AddL( ( CObject* ) targetCm ); |
|
2986 targetCm->SetHandle( handle ); |
|
2987 CleanupStack::Pop( targetCm ); |
|
2988 |
|
2989 TPckg<TInt> handlePckg( handle ); |
|
2990 TInt error = aMessage.Write( 3, handlePckg ); |
|
2991 if ( error ) |
|
2992 { |
|
2993 // Remove from object index and destroy the object. |
|
2994 iConnMethodObjects->Remove( handle ); |
|
2995 User::Leave( error ); |
|
2996 } |
|
2997 |
|
2998 OstTraceFunctionExit0( CCMMSESSION_CREATECOPYOFEXISTINGL_EXIT ); |
|
2999 } |
|
3000 |
|
3001 // ----------------------------------------------------------------------------- |
|
3002 // Creates a copy of an existing connection method and opens a handle to it. |
|
3003 // ----------------------------------------------------------------------------- |
|
3004 // |
|
3005 void CCmmSession::GetEmbeddedDestinationL( const RMessage2& aMessage ) |
|
3006 { |
|
3007 OstTraceFunctionEntry0( CCMMSESSION_GETEMBEDDEDDESTINATIONL_ENTRY ); |
|
3008 |
|
3009 CCmmConnMethodInstance* connMethodInstance = |
|
3010 ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() ); |
|
3011 |
|
3012 if ( connMethodInstance->GetBearerType() != KUidEmbeddedDestination ) |
|
3013 { |
|
3014 User::Leave( KErrNotSupported ); |
|
3015 } |
|
3016 |
|
3017 TUint32 destinationId = connMethodInstance->GetId(); |
|
3018 |
|
3019 // Check that the ID is in valid range. |
|
3020 if ( destinationId <= KCmDefaultDestinationAPTagId || |
|
3021 destinationId >= KCmMaxDestinationAPTagId ) |
|
3022 { |
|
3023 User::Leave( KErrCorrupt ); |
|
3024 } |
|
3025 |
|
3026 // If this session already has a destination with matching ID open, provide |
|
3027 // the client with a reference to the already opened handle. |
|
3028 CCmmDestinationInstance* destinationInstance = FindDestinationInstanceById( destinationId ); |
|
3029 if ( destinationInstance ) |
|
3030 { |
|
3031 if ( iCache.DestinationExistsWithId( destinationId ) ) |
|
3032 { |
|
3033 TPckg<TInt> existingHandlePckg( destinationInstance->GetHandle() ); |
|
3034 aMessage.WriteL( 1, existingHandlePckg ); |
|
3035 User::Leave( KErrAlreadyExists ); |
|
3036 } |
|
3037 } |
|
3038 destinationInstance = NULL; |
|
3039 TPckg<TInt> existingHandlePckg( 0 ); |
|
3040 aMessage.WriteL( 1, existingHandlePckg ); |
|
3041 |
|
3042 destinationInstance = CCmmDestinationInstance::NewLC( this, &iCache ); |
|
3043 |
|
3044 // Cache will open a handle to the destination if not already open, and |
|
3045 // copy relevant data into this destination instance. |
|
3046 iCache.OpenDestinationL( *destinationInstance, destinationId ); // Checks ID is valid. |
|
3047 |
|
3048 iDestinationContainer->AddL( ( CObject* ) destinationInstance ); |
|
3049 TInt handle = iDestinationObjects->AddL( ( CObject* ) destinationInstance ); |
|
3050 destinationInstance->SetHandle( handle ); |
|
3051 CleanupStack::Pop( destinationInstance ); |
|
3052 |
|
3053 TPckg<TInt> handlePckg( handle ); |
|
3054 TInt error = aMessage.Write( 3, handlePckg ); |
|
3055 if ( error ) |
|
3056 { |
|
3057 // Removes from object index and destroys the object. |
|
3058 iDestinationObjects->Remove( handle ); |
|
3059 User::Leave( error ); |
|
3060 } |
|
3061 OstTraceFunctionExit0( CCMMSESSION_GETEMBEDDEDDESTINATIONL_EXIT ); |
|
3062 } |
|
3063 |
|
3064 // End of file |