|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32capability.h> |
|
17 |
|
18 #include "clesrv.h" |
|
19 #include "clesess.h" |
|
20 #include "cleconst.h" |
|
21 #include "ssmcommandutilprovider.h" |
|
22 |
|
23 |
|
24 /** |
|
25 In the case of ECleSrvExecuteCmdList, the RMessage is completed by the |
|
26 Executor call into the server's ListExecutionComplete method. |
|
27 */ |
|
28 void CCleSession::ServiceL( const RMessage2& aMessage ) |
|
29 { |
|
30 switch( aMessage.Function() ) |
|
31 { |
|
32 |
|
33 case ECleSrvExecuteCmdList: |
|
34 { |
|
35 ExecuteCommandListL( aMessage ); |
|
36 } |
|
37 break; |
|
38 |
|
39 case ECleSrvExecuteCmdListCancel: |
|
40 { |
|
41 aMessage.Complete( KErrNone ); |
|
42 ExecuteCommandListCancel(); |
|
43 } |
|
44 break; |
|
45 |
|
46 case EDebugMarkHeap: |
|
47 { |
|
48 #ifdef _DEBUG |
|
49 __UHEAP_MARK; |
|
50 DEBUGPRINT2(_L("CCleSession - EDebugMarkHeap: Alloc Cells: %d."), User::CountAllocCells()); |
|
51 #endif |
|
52 aMessage.Complete(KErrNone); |
|
53 break; |
|
54 } |
|
55 |
|
56 case EDebugMarkHeapEnd: |
|
57 { |
|
58 #ifdef _DEBUG |
|
59 DEBUGPRINT2(_L("CCleSession - EDebugMarkHeapEnd: Alloc Cells: %d."), User::CountAllocCells()); |
|
60 __UHEAP_MARKEND; |
|
61 #endif |
|
62 aMessage.Complete(KErrNone); |
|
63 break; |
|
64 } |
|
65 |
|
66 case EDebugSetHeapFailure: |
|
67 { |
|
68 #ifdef _DEBUG |
|
69 __UHEAP_SETFAIL(RAllocator::EFailNext,aMessage.Int0()); |
|
70 DEBUGPRINT2(_L("CCleSession - EDebugSetHeapFailure: Value of Failure Rate: %d."), aMessage.Int0()); |
|
71 #endif |
|
72 aMessage.Complete(KErrNone); |
|
73 break; |
|
74 } |
|
75 |
|
76 case EDebugHeapReset: |
|
77 { |
|
78 #ifdef _DEBUG |
|
79 __UHEAP_RESET; |
|
80 DEBUGPRINT1(_L("CCleSession - EDebugHeapReset")); |
|
81 #endif |
|
82 aMessage.Complete(KErrNone); |
|
83 break; |
|
84 } |
|
85 |
|
86 case EDebugCloseNeverUnloadLibs: |
|
87 { |
|
88 TInt ret = KErrNone; |
|
89 #ifdef _DEBUG |
|
90 ret = iCleSvr.CloseNeverUnloadLibrariesL(); |
|
91 DEBUGPRINT2(_L("CCleSession - EDebugReleaseNeverUnloadLibs: # of libraries released: %d."), ret); |
|
92 #endif |
|
93 aMessage.Complete(ret); |
|
94 break; |
|
95 } |
|
96 |
|
97 default: |
|
98 aMessage.Complete( KErrUnknown ); |
|
99 break; |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 void CCleSession::ExecuteCommandListL( const RMessage2& aMessage ) |
|
106 { |
|
107 const CSsmCommandList* srcCmdList = reinterpret_cast<const CSsmCommandList*>(aMessage.Ptr0()); |
|
108 __ASSERT_DEBUG(srcCmdList, User::Panic(KCleCmdListEmpty, KCleSrvBadCmdList)); |
|
109 |
|
110 CSsmCommandList* cmdList = CSsmCommandList::NewLC(srcCmdList, iCommandUtilProvider); |
|
111 // The CSsmCmdListExecutor takes ownership of cmdList |
|
112 iCleSvr.ExecuteCommandListL( cmdList, aMessage, iSessionIndex ); |
|
113 CleanupStack::Pop( cmdList ); |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 void CCleSession::ExecuteCommandListCancel() |
|
119 { |
|
120 iCleSvr.ExecuteCommandListCancel( iSessionIndex ); |
|
121 } |
|
122 |
|
123 |
|
124 |
|
125 CCleSession* CCleSession::NewL( CCleServer& aCleServer ) |
|
126 { |
|
127 CCleSession* self = new(ELeave) CCleSession( aCleServer ); |
|
128 CleanupStack::PushL( self ); |
|
129 self->ConstructL(); |
|
130 CleanupStack::Pop(); |
|
131 return self; |
|
132 } |
|
133 |
|
134 |
|
135 |
|
136 CCleSession::CCleSession( CCleServer& aCleServer ) |
|
137 : iCleSvr( aCleServer ) |
|
138 { |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 void CCleSession::ConstructL() |
|
144 { |
|
145 iCleSvr.RegisterSessionL( iSessionIndex ); |
|
146 iCommandUtilProvider = CSsmCommandUtilProvider::NewL(); |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 CCleSession::~CCleSession() |
|
152 { |
|
153 iCleSvr.DeregisterSession( iSessionIndex ); |
|
154 delete iCommandUtilProvider; |
|
155 } |
|
156 |