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