|
1 /* |
|
2 * Copyright (c) 2004-2009 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 the License "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 * Common definitions for sishelper server and client |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef __SISHELPERCLIENT_H__ |
|
26 #define __SISHELPERCLIENT_H__ |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <f32file.h> |
|
30 #include <caf/caf.h> |
|
31 |
|
32 #include "swi/siscontroller.h" |
|
33 #include "writestream.h" |
|
34 |
|
35 namespace Swi |
|
36 { |
|
37 |
|
38 _LIT(KSisHelperServerName, "!SISHELPER"); |
|
39 const TUid KSisHelperServerUid3={0x101F7293}; |
|
40 const TInt KSisHelperVersionMajor=1; |
|
41 const TInt KSisHelperVersionMinor=0; |
|
42 const TInt KSisHelperVersionBuild=0; |
|
43 |
|
44 class CSisHelperStream; |
|
45 class RUiHandler; |
|
46 class MSisDataProvider; |
|
47 |
|
48 /** |
|
49 Panic code for panicking a badly written client |
|
50 @internalTechnology |
|
51 @released |
|
52 */ |
|
53 enum TSisHelperPanic |
|
54 { |
|
55 EPanicBadDescriptor, |
|
56 EPanicIllegalFunction, |
|
57 EPanicAlreadyReceiving, |
|
58 /** |
|
59 Unknown startup data type (see TSisHelperStartParams::TType) |
|
60 */ |
|
61 EPanicBadStartupDataType, |
|
62 /** |
|
63 Bad interface pointer passed in startup data |
|
64 */ |
|
65 EPanicBadDataProvider |
|
66 }; |
|
67 |
|
68 /** |
|
69 Start params can be either a file name or a data provider interface pointer. |
|
70 This struct encapsulates SisHelper startup params, supporting both types of params. |
|
71 @internalTechnology |
|
72 @released |
|
73 */ |
|
74 struct TSisHelperStartParams |
|
75 { |
|
76 /** |
|
77 Type of contained pointer |
|
78 */ |
|
79 enum TType |
|
80 { |
|
81 ETypeFileName, ///< Pointer to a SISX file name |
|
82 ETypeDataProvider, ///< Pointer to a data provider interface |
|
83 ETypeFileHandle, ///< Pointer to a file handle. |
|
84 ETypeNull, ///< No Pointer to any handle . |
|
85 }; |
|
86 TType iType; ///< determines what kind of pointer we have |
|
87 union |
|
88 { |
|
89 const TFileName* iFileName; ///< Pointer to a file name |
|
90 MSisDataProvider* iDataProvider; ///< Data provider interface pointer |
|
91 RFile* iFileHandle; |
|
92 }; |
|
93 |
|
94 /** |
|
95 Constructs parameters structure with a file name |
|
96 @param aFileName File name to pass to SISHelper |
|
97 */ |
|
98 inline TSisHelperStartParams(const TFileName& aFileName); |
|
99 |
|
100 /** |
|
101 Constructs parameters structure with a file handle |
|
102 @param aFileHandle File handle to pass to SISHelper |
|
103 */ |
|
104 inline TSisHelperStartParams(RFile& aFileHandle); |
|
105 |
|
106 /** |
|
107 Constructs parameters structure with a data provider interface |
|
108 @param aDataProvider Data provider interface implementation pointer |
|
109 */ |
|
110 inline TSisHelperStartParams(MSisDataProvider& aDataProvider); |
|
111 |
|
112 /** |
|
113 Constructs parameters for ETypeNull |
|
114 */ |
|
115 inline TSisHelperStartParams(); |
|
116 }; |
|
117 |
|
118 inline TSisHelperStartParams::TSisHelperStartParams(const TFileName& aFileName) |
|
119 : iType(ETypeFileName), |
|
120 iFileName(&aFileName) |
|
121 { |
|
122 } |
|
123 |
|
124 inline TSisHelperStartParams::TSisHelperStartParams(RFile& aFileHandle) |
|
125 : iType(ETypeFileHandle), |
|
126 iFileHandle(&aFileHandle) |
|
127 { |
|
128 } |
|
129 |
|
130 inline TSisHelperStartParams::TSisHelperStartParams( |
|
131 MSisDataProvider& aDataProvider) |
|
132 : iType(ETypeDataProvider), |
|
133 iDataProvider(&aDataProvider) |
|
134 { |
|
135 } |
|
136 |
|
137 inline TSisHelperStartParams::TSisHelperStartParams() |
|
138 : iType(ETypeNull) |
|
139 { |
|
140 } |
|
141 |
|
142 /** |
|
143 SISHelper server messages |
|
144 @released |
|
145 @internalTechnology |
|
146 */ |
|
147 enum TSisHelperMessage |
|
148 { |
|
149 ESisHelperGetController, ///< Retrieve SISController |
|
150 ESisHelperExtractFile, ///< Copy / decompress a file |
|
151 ESisHelperFillDrivesAndSpaces, ///< Return available disk drives and spaces |
|
152 ESisHelperOpenDrmContent, ///< Evaluate the intent for this installation |
|
153 ESisHelperExecuteDrmIntent, ///< Execute the intent for this installation |
|
154 ESisHelperSetupAsyncExtraction, ///< Begin copy / decompress part of a file |
|
155 ESisHelperAsyncExtraction, ///< Continue copy / decompress part of a file |
|
156 ESisHelperEndAsyncExtraction, ///< End copy / decompress part of a file |
|
157 ESisHelperCreateSisStub, ///< Create a .SIS stub file |
|
158 ESisHelperIsStub, ///< Query whether the SIS file contains any data, if not it's a stub (preinstalled) |
|
159 ESisHelperGetSisFileDrive, ///< Find the drive letter the SIS is installed from. (-1) if unknown |
|
160 ESisHelperIsSisFileReadOnly, ///< Check if the SIS file is read only (affects whether to delete on uninstall of preinstalled package.) |
|
161 ESisHelperGetSisFileName, ///< Get name with path of SIS file. |
|
162 ESisHelperGetControllerFromSis, ///< Retrieve SISController from the specified SISX file |
|
163 ESisHelperGetEquivalentLanguages, ///< Retrieve fetching equivalent languages |
|
164 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
165 ESisHelperIsDrmProtected // Says whether the SIS controller is DRM protected or not |
|
166 #endif |
|
167 }; |
|
168 |
|
169 /** |
|
170 * RClass which is used to make calls to the SIS Helper server using |
|
171 * the client-server framework. The ExecuteL() method is passed a |
|
172 * command in order to perform the appropriate action |
|
173 * |
|
174 * @internalTechnology |
|
175 * @released |
|
176 */ |
|
177 class RSisHelper : public RSessionBase |
|
178 { |
|
179 public: |
|
180 /** |
|
181 * Open the connection to the SIS Helper Server |
|
182 * |
|
183 * @return KErrNone or an error code |
|
184 */ |
|
185 IMPORT_C TInt Connect(); |
|
186 |
|
187 /** |
|
188 * Close the connection to the SIS Helper Server |
|
189 * |
|
190 * @return KErrNone or an error code |
|
191 */ |
|
192 IMPORT_C void Close(); |
|
193 |
|
194 /** |
|
195 * Retrieves a SISController from SISHelper |
|
196 * |
|
197 * @return Pointer to a new SISController (caller owns it) |
|
198 */ |
|
199 IMPORT_C HBufC8* SisControllerLC(); |
|
200 |
|
201 /** |
|
202 * Extracts the specified file from SISX file |
|
203 * |
|
204 * @param aRfs The RFs used by aFile |
|
205 * @param aFile An already opened file handle |
|
206 * @param aFileIndex Index of the file in the SISX |
|
207 * @param aDataUnit Data unit index |
|
208 * @param aUiHandler UiHandler |
|
209 * |
|
210 * @return KErrNone on success, or an error code |
|
211 */ |
|
212 IMPORT_C TInt ExtractFileL(RFs& aFs, RFile& aFile, TInt aFileIndex, |
|
213 TInt aDataUnit, RUiHandler& aUiHandler); |
|
214 |
|
215 /** |
|
216 * Fills arrays with drive letter and free space information. Takes into |
|
217 * account drive availability and suitability for installation. |
|
218 * |
|
219 * @param aDriveLetters Array of available drive letters |
|
220 * @param aDriveSpaces Array of free disk space values for the drives |
|
221 */ |
|
222 IMPORT_C void FillDrivesAndSpacesL(RArray<TChar>& aDriveLetters, |
|
223 RArray<TInt64>& aDriveSpaces); |
|
224 |
|
225 /** |
|
226 * This function is used to open drm content, provided by the MSisDataProvider implementation. |
|
227 * SisHelper server owns an implementation of the MSisDataProvider interface, and acting as |
|
228 * a proxy, forwards this call to the implementation. |
|
229 * |
|
230 * @param aIntent the intent to evaluate |
|
231 */ |
|
232 IMPORT_C void OpenDrmContentL(ContentAccess::TIntent aIntent); |
|
233 |
|
234 /** |
|
235 * This function is used to execute DRM intent on data provided by the MSisDataProvider implementation. |
|
236 * SisHelper server owns an implementation of the MSisDataProvider interface, and acting as |
|
237 * a proxy, forwards this call to the implementation. |
|
238 * |
|
239 * @param aIntent the intent to execute |
|
240 */ |
|
241 IMPORT_C void ExecuteDrmIntentL(ContentAccess::TIntent aIntent); |
|
242 |
|
243 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
244 /** |
|
245 * Find out whether the SIS file is DRM protected one. |
|
246 * @return ETrue if the SIS file is a DRM protected. |
|
247 */ |
|
248 TBool IsDrmProtectedL(); |
|
249 #endif |
|
250 /** |
|
251 * Find out the equivalent languages for a given language ID. |
|
252 * @return list of the equivalent languages. |
|
253 */ |
|
254 void GetEquivalentLanguageListL(TLanguage aLangId,RArray<TLanguage>& aEquivLangs); |
|
255 |
|
256 /** |
|
257 * Create a .SIS stub file from the existing SIS file. |
|
258 * In reality this just saves the SIS header followed by the controller |
|
259 * in order to create a stub. |
|
260 */ |
|
261 TInt CreateSisStub(RFile& aFile); |
|
262 |
|
263 /** Find out whether the SIS file handled by SisHelperServer is a stub |
|
264 This means it is either a removable media stub, a PreInstalledApp or a PreInstalledPatch |
|
265 @return ETrue if the SIS file is a stub |
|
266 */ |
|
267 TBool IsStubL(); |
|
268 |
|
269 /** Find out which drive the SIS file used for this installation is coming from |
|
270 @return The drive where the SIS file is located or -1 if the drive is unknown |
|
271 */ |
|
272 TChar GetSisFileDriveL(); |
|
273 |
|
274 /** |
|
275 * Find out whether the SIS file handled by SisHelperServer is read only |
|
276 * @return ETrue if the SIS file is read only |
|
277 */ |
|
278 TBool IsSisFileReadOnlyL(); |
|
279 |
|
280 /** |
|
281 * Get the name of the SIS file handled by SisHelperServer. |
|
282 * |
|
283 * @param aFileName - A writable descriptor which should be large enough to |
|
284 * hold the filename. |
|
285 */ |
|
286 void GetSisFileNameL(TDes& aFileName); |
|
287 |
|
288 /** |
|
289 * Retrieves a SISController from the specified SISX file |
|
290 * |
|
291 * @param aFileName A controller file to read the row controller data. |
|
292 * @return Pointer to a new SISController (caller owns it) |
|
293 */ |
|
294 IMPORT_C HBufC8* GetControllerFromSisFileLC(const TDesC& aFileName); |
|
295 |
|
296 // Async Extraction Functions |
|
297 |
|
298 void SetupAsyncExtractionL(RFs& aFs, RFile& aFile, TInt aFileIndex,TInt aDataUnit); |
|
299 void AsyncExtractionL(TInt64 length, TRequestStatus& aStatus); |
|
300 void EndAsyncExtractionL(); |
|
301 |
|
302 |
|
303 private: |
|
304 TBuf8<32> iBuffer; // enough space for all the arguments to ExtractPartialFileL |
|
305 }; |
|
306 |
|
307 } // namespace Swi |
|
308 |
|
309 #endif // __SISHELPERCLIENT_H__ |