|
1 // Copyright (c) 2008-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 <ssm/ssmsuscli.h> |
|
17 |
|
18 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
19 #include <ssm/ssmpatchableconstants.h> |
|
20 #include <e32uid.h> |
|
21 #include <e32property.h> |
|
22 #endif // SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
23 |
|
24 #include "susutilserver.h" |
|
25 #include "susutilsession.h" |
|
26 #include "susutilclisrv.h" |
|
27 #include "ssmdebug.h" |
|
28 |
|
29 CSusUtilSession::~CSusUtilSession() |
|
30 { |
|
31 } |
|
32 |
|
33 CSusUtilSession::CSusUtilSession() |
|
34 { |
|
35 } |
|
36 |
|
37 CSusUtilSession* CSusUtilSession::NewL() |
|
38 { |
|
39 CSusUtilSession* session = new(ELeave) CSusUtilSession(); |
|
40 return session; |
|
41 } |
|
42 |
|
43 void CSusUtilSession::ServiceL(const RMessage2& aMessage) |
|
44 { |
|
45 const TBool allowed = (aMessage.SecureId() == UtilServer()->ClientSecureId()); |
|
46 SSMLOGLEAVEIFFALSE( allowed, KErrPermissionDenied); |
|
47 |
|
48 switch (aMessage.Function()) |
|
49 { |
|
50 case ERequestLoadSup: |
|
51 { |
|
52 DEBUGPRINT1(_L ("CSusUtilSession received: ERequestLoadSup ")); |
|
53 |
|
54 if (sizeof(TSsmSupInfo) != aMessage.GetDesLengthL(0)) |
|
55 { |
|
56 //Leave with KErrArgument if client passes other than TSsmSupInfo |
|
57 DEBUGPRINT2(_L ("size of TSsmSupInfo - %d "),sizeof(TSsmSupInfo)); |
|
58 User::Leave(KErrArgument); |
|
59 } |
|
60 |
|
61 TSsmSupInfo pluginInfo; |
|
62 TPckg<TSsmSupInfo> pckg(pluginInfo); |
|
63 aMessage.ReadL(0, pckg); |
|
64 |
|
65 UtilServer()->LoadUtilityPluginL(pluginInfo); |
|
66 aMessage.Complete(KErrNone); |
|
67 break; |
|
68 } |
|
69 case ERequestLoadSupCancel: |
|
70 { |
|
71 DEBUGPRINT1(_L ("CSusUtilSession received: ERequestLoadSupCancel ")); |
|
72 //Current design will never have any pending async operations |
|
73 aMessage.Complete(KErrNone); |
|
74 break; |
|
75 } |
|
76 case ERequestUnLoadSup: |
|
77 { |
|
78 DEBUGPRINT1(_L ("CSusUtilSession received: ERequestUnLoadSup ")); |
|
79 |
|
80 if (sizeof(TSsmSupInfo) != aMessage.GetDesLengthL(0)) |
|
81 { |
|
82 //Leave with KErrArgument if client passes other than TSsmSupInfo |
|
83 User::Leave(KErrArgument); |
|
84 } |
|
85 |
|
86 TSsmSupInfo pluginInfo; |
|
87 TPckg<TSsmSupInfo> pckg(pluginInfo); |
|
88 aMessage.ReadL(0, pckg); |
|
89 |
|
90 const TInt index = UtilServer()->UnLoadUtilityPluginL(pluginInfo); |
|
91 aMessage.Complete( (index>KErrNotFound) ? KErrNone : KErrNotFound ); |
|
92 break; |
|
93 } |
|
94 #ifdef _DEBUG |
|
95 case (EEndOfSusUtilOpCodes): |
|
96 { |
|
97 DEBUGPRINT1(_L ("CSusUtilSession received: EEndOfSusUtilOpCodes, shutting down ")); |
|
98 aMessage.Complete (KErrNone); |
|
99 CActiveScheduler::Stop(); |
|
100 break; |
|
101 } |
|
102 #endif //_DEBUG |
|
103 //Only for testing purpose |
|
104 case EDebugMarkHeap: |
|
105 #ifdef _DEBUG |
|
106 DEBUGPRINT1(_L ("CSusUtilSession received EDebugMarkHeap(start Heap mark)")); |
|
107 __UHEAP_MARK; |
|
108 #endif |
|
109 aMessage.Complete(KErrNone); |
|
110 break; |
|
111 //Only for testing purpose |
|
112 case EDebugMarkHeapEnd: |
|
113 #ifdef _DEBUG |
|
114 DEBUGPRINT1(_L ("CSusUtilSession received EDebugMarkHeapEnd(end Heap mark)")); |
|
115 __UHEAP_MARKEND; |
|
116 #endif |
|
117 aMessage.Complete(KErrNone); |
|
118 break; |
|
119 //Only for testing purpose |
|
120 case EDebugCompressPluginArray: |
|
121 #ifdef _DEBUG |
|
122 UtilServer()->CompressPluginArray(); |
|
123 #endif |
|
124 aMessage.Complete(KErrNone); |
|
125 break; |
|
126 default: |
|
127 //Should never come here if policy-server configuraion is correct in susutilserver.cpp |
|
128 DEBUGPRINT2(_L("CSusUtilSession received unsupported request: %d "), aMessage.Function()); |
|
129 aMessage.Complete (KErrNotSupported); |
|
130 break; |
|
131 } |
|
132 } |
|
133 |
|
134 void CSusUtilSession::ServiceError(const RMessage2 &aMessage, TInt aError) |
|
135 { |
|
136 DEBUGPRINT2(_L ("CSusUtilSession: ServiceError %d"), aError); |
|
137 aMessage.Complete (aError); |
|
138 } |
|
139 |
|
140 /** |
|
141 Returns a pointer to the server object |
|
142 */ |
|
143 CSusUtilServer* CSusUtilSession::UtilServer() |
|
144 { |
|
145 return static_cast<CSusUtilServer*> (const_cast<CServer2*> (Server())); |
|
146 } |