|
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 <ssm/ssmsuscli.h> |
|
17 #include "susutilclisrv.h" |
|
18 |
|
19 /** |
|
20 Connect this session without pre-allocating any async message slots. |
|
21 This version of @c Connect signifies that the session has no dedicated pool of asynchronous message |
|
22 objects but should use the global pool, reducing the kernel memory required to create the session. |
|
23 This is the best value to use unless either: |
|
24 1. The session never sends asynchronous messages, in which case you should specify '0', OR |
|
25 2. The session makes guarantees on at least one asynchronous API that it cannot fail with KErrNoMemory - |
|
26 in which case you need to work out the maximum number of concurrent asynchronous messages that may |
|
27 be outstanding on a single session and use that value. |
|
28 |
|
29 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
30 */ |
|
31 EXPORT_C TInt RSsmSusCli::Connect() |
|
32 { |
|
33 const TInt KTryAllocSlotsFromSystemPoolInRuntime = -1; |
|
34 return Connect(KTryAllocSlotsFromSystemPoolInRuntime); |
|
35 } |
|
36 |
|
37 /** |
|
38 Connect this session and pre-allcocate the number of async message slots you will need. |
|
39 I.e. the max number of async calls to @c RequestLoadSup waiting for completion you will ever need. |
|
40 |
|
41 Use this version of @c Connect if you want to be quaranteed slots rather than relying |
|
42 on slots being allocated in runtime from the system wide pool. |
|
43 |
|
44 @see RSessionBase::CreateSession |
|
45 @publishedPartner |
|
46 @released |
|
47 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
48 */ |
|
49 EXPORT_C TInt RSsmSusCli::Connect(TInt aAsyncMessageSlots) |
|
50 { |
|
51 return DoConnect(KSusUtilServerName, Version(), aAsyncMessageSlots); |
|
52 } |
|
53 |
|
54 /** |
|
55 This exists for testing purposes only. |
|
56 @internalComponent |
|
57 */ |
|
58 TInt RSsmSusCli::DoConnect(const TDesC& aServerName, TVersion aVersion, TInt aAsyncMessageSlots) |
|
59 { |
|
60 if(!Handle()) |
|
61 { |
|
62 return CreateSession(aServerName, aVersion, aAsyncMessageSlots); |
|
63 } |
|
64 |
|
65 return KErrAlreadyExists; |
|
66 } //lint !e1746 suppress parameter 'aVersion' could be made const reference |
|
67 |
|
68 /** |
|
69 Close this session. |
|
70 @publishedPartner |
|
71 @released |
|
72 */ |
|
73 EXPORT_C void RSsmSusCli::Close() |
|
74 { |
|
75 RSessionBase::Close(); |
|
76 } |
|
77 |
|
78 /** |
|
79 */ |
|
80 TVersion RSsmSusCli::Version() const |
|
81 { |
|
82 return(TVersion(KSusUtilServMajorVersionNumber, KSusUtilServMinorVersionNumber, KSusUtilServBuildVersionNumber)); |
|
83 } |
|
84 |
|
85 /** |
|
86 Use this function to synchronously load a utility plugin. When this function returns, |
|
87 the plugin have been loaded, initialized and started in the Utility Server thread. |
|
88 |
|
89 @param aUtilityPluginDetails The information needed to identify and load the utility plugin. |
|
90 @return KErrNone or one of the system wide errorcodes. |
|
91 @publishedPartner |
|
92 @released |
|
93 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
94 */ |
|
95 EXPORT_C TInt RSsmSusCli::RequestLoadSup(const TSsmSupInfo& aUtilityPluginDetails) |
|
96 { |
|
97 if(Handle()) |
|
98 { |
|
99 const TPckgC<TSsmSupInfo> pckg(aUtilityPluginDetails); |
|
100 return SendReceive(ERequestLoadSup, TIpcArgs(&pckg)); |
|
101 } |
|
102 |
|
103 return KErrDisconnected; |
|
104 } |
|
105 |
|
106 /** |
|
107 Use this function to request asynchronous loading of a utility plugin. |
|
108 |
|
109 Usage pattern: |
|
110 @code |
|
111 RSsmSusCli session; |
|
112 session.Connect(); |
|
113 CleanupStackClosePushL(session); |
|
114 TPckgC<TSsmSupInfo>* infoBuf = new (ELeave) TPckgC<TSsmSupInfo>(info); |
|
115 session.RequestLoadSup(*infoBuf, status); |
|
116 ... |
|
117 //It is expected that production code will use an active-object instead of User::WaitForRequest. |
|
118 //You might be interested in the technique employed in CSsmStartSafe. See activewaiter.h/cpp and its usage in ssmstartsafe.cpp |
|
119 User::WaitForRequest(status); |
|
120 delete infoBuf; |
|
121 CleanupStack::PopAndDestroy(&session); |
|
122 @endcode |
|
123 |
|
124 @param aTSsmSupInfoPckgC A TSsmSupInfo wrapped in a TPckgC descriptor. Needs to be |
|
125 valid until this request (@c aStatus) has been completed. |
|
126 @param aStatus The status for this request. Will when completed contain |
|
127 KErrNone or one of the system wide errorcodes. |
|
128 @publishedPartner |
|
129 @released |
|
130 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
131 */ |
|
132 EXPORT_C void RSsmSusCli::RequestLoadSup(const TDesC8& aTSsmSupInfoPckgC, TRequestStatus& aStatus) |
|
133 { |
|
134 if(Handle()) |
|
135 { |
|
136 SendReceive(ERequestLoadSup, TIpcArgs(&aTSsmSupInfoPckgC), aStatus); |
|
137 } |
|
138 else |
|
139 { |
|
140 aStatus = KRequestPending; |
|
141 TRequestStatus* clientStatus = &aStatus; |
|
142 User::RequestComplete(clientStatus, KErrDisconnected); |
|
143 } |
|
144 } |
|
145 |
|
146 /** |
|
147 Cancel an asynchronous request to load a utility plugin. Note that a preceding asynchronous request |
|
148 to load a plugin will still be handled before this request to cancel. |
|
149 @publishedPartner |
|
150 @released |
|
151 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
152 */ |
|
153 EXPORT_C void RSsmSusCli::RequestLoadSupCancel() |
|
154 { |
|
155 if(Handle()) |
|
156 { |
|
157 SendReceive(ERequestLoadSupCancel); |
|
158 } |
|
159 } |
|
160 |
|
161 /** |
|
162 @internalComponent |
|
163 @released |
|
164 @capability DiskAdmin PowerMgmt ProtServ SwEvent WriteDeviceData ReadDeviceData |
|
165 */ |
|
166 TInt RSsmSusCli::RequestUnLoadSup(const TSsmSupInfo& aUtilityPluginDetails) |
|
167 { |
|
168 if(Handle()) |
|
169 { |
|
170 const TPckgC<TSsmSupInfo> pckg(aUtilityPluginDetails); |
|
171 return SendReceive(ERequestUnLoadSup, TIpcArgs(&pckg)); |
|
172 } |
|
173 |
|
174 return KErrDisconnected; |
|
175 } |