|
1 /* |
|
2 * Copyright (c) 1997-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 * Launcher static class is used by clients (EpocInstall, Installer UI, or |
|
16 * Control Panel applet) to start installation or uninstallation. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 |
|
25 #include "swi/launcher.h" |
|
26 #include "uissclienthandler.h" |
|
27 #include "../uiss/server/uissserver.h" |
|
28 #include "sisuihandler.h" |
|
29 #include "installclientserver.h" |
|
30 #include "sishelper.h" |
|
31 #include "log.h" |
|
32 |
|
33 #include "sisregistrypackage.h" |
|
34 #include "sisregistrysession.h" |
|
35 #include "sisregistryentry.h" |
|
36 |
|
37 |
|
38 namespace Swi |
|
39 { |
|
40 |
|
41 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
42 const TFileName& aFileName, |
|
43 const CInstallPrefs& aInstallPrefs) |
|
44 { |
|
45 DEBUG_PRINTF2(_L("Sis Helper without Device supported languages - Launching Syncronous Install by filename, SIS: %S."), |
|
46 &aFileName); |
|
47 RArray<TInt> deviceSupportedLanguages; |
|
48 TRAPD(err, err=InstallL(aUiHandler, aFileName, aInstallPrefs,deviceSupportedLanguages)); |
|
49 DEBUG_PRINTF2(_L8("Sis Helper without Device supported languages - Install Result Was %d."), err); |
|
50 return err; |
|
51 |
|
52 } |
|
53 |
|
54 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
55 const TFileName& aFileName, |
|
56 const CInstallPrefs& aInstallPrefs, const RArray<TInt>& aDeviceSupportedLanguages) |
|
57 { |
|
58 DEBUG_PRINTF2(_L("Sis Helper with Device supported languages - Launching Syncronous Install by filename, SIS: %S."), |
|
59 &aFileName); |
|
60 TRAPD(err, err=InstallL(aUiHandler, aFileName, aInstallPrefs,aDeviceSupportedLanguages)); |
|
61 DEBUG_PRINTF2(_L8("Sis Helper with Device supported languages - Install Result Was %d."), err); |
|
62 return err; |
|
63 } |
|
64 |
|
65 |
|
66 TInt Launcher::InstallL(MUiHandler& aUiHandler, |
|
67 const TFileName& aFileName, |
|
68 const CInstallPrefs& aInstallPrefs, |
|
69 const RArray<TInt>& aDeviceSupportedLanguages) |
|
70 { |
|
71 TSisHelperStartParams params(aFileName); |
|
72 RThread server; |
|
73 TInt err = CSisHelperServer::StartSisHelper(params, server); |
|
74 |
|
75 if (err == KErrNone) |
|
76 { |
|
77 // Connect to UISS and start installation using asynchronous calls |
|
78 // and reverse completion |
|
79 CleanupClosePushL(server); |
|
80 CUissClientHandler* uissHandler = CUissClientHandler::NewLC(aUiHandler, false); |
|
81 CleanupStack::Pop(2,&server); |
|
82 CleanupStack::PushL(uissHandler); |
|
83 |
|
84 TRequestStatus requestStatus; |
|
85 uissHandler->InstallL(aInstallPrefs, aDeviceSupportedLanguages, requestStatus, server); |
|
86 uissHandler->WorkUntilCompleteL(); |
|
87 User::WaitForRequest(requestStatus); |
|
88 err = requestStatus.Int(); |
|
89 |
|
90 CleanupStack::PopAndDestroy(uissHandler); |
|
91 } |
|
92 return err; |
|
93 } |
|
94 |
|
95 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
96 RFile& aFileHandle, |
|
97 const CInstallPrefs& aInstallPrefs) |
|
98 { |
|
99 DEBUG_PRINTF(_L8("Sis Helper without Device supported languages - Launching Syncronous Install by filehandle.")); |
|
100 RArray<TInt> deviceSupportedLanguages; |
|
101 TRAPD(err, err=InstallL(aUiHandler, aFileHandle, aInstallPrefs,deviceSupportedLanguages)); |
|
102 DEBUG_PRINTF2(_L8("Sis Helper without Device supported languages - Install Result Was %d."), err); |
|
103 return err; |
|
104 |
|
105 } |
|
106 |
|
107 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
108 RFile& aFileHandle, |
|
109 const CInstallPrefs& aInstallPrefs, |
|
110 const RArray<TInt>& aDeviceSupportedLanguages) |
|
111 { |
|
112 DEBUG_PRINTF(_L8("Sis Helper with Device supported languages - Launching Syncronous Install by filehandle.")); |
|
113 TRAPD(err, err=InstallL(aUiHandler, aFileHandle, aInstallPrefs,aDeviceSupportedLanguages)); |
|
114 DEBUG_PRINTF2(_L8("Sis Helper with Device supported languages - Install Result Was %d."), err); |
|
115 return err; |
|
116 } |
|
117 |
|
118 |
|
119 TInt Launcher::InstallL(MUiHandler& aUiHandler, |
|
120 RFile& aFileHandle, |
|
121 const CInstallPrefs& aInstallPrefs, |
|
122 const RArray<TInt>& aDeviceSupportedLanguages) |
|
123 { |
|
124 TSisHelperStartParams params(aFileHandle); |
|
125 RThread server; |
|
126 TInt err = CSisHelperServer::StartSisHelper(params, server); |
|
127 |
|
128 if (err == KErrNone) |
|
129 { |
|
130 // Connect to UISS and start installation using asynchronous calls |
|
131 // and reverse completion |
|
132 CleanupClosePushL(server); |
|
133 CUissClientHandler* uissHandler = CUissClientHandler::NewLC(aUiHandler, false); |
|
134 CleanupStack::Pop(2,&server); |
|
135 CleanupStack::PushL(uissHandler); |
|
136 |
|
137 TRequestStatus requestStatus; |
|
138 uissHandler->InstallL(aInstallPrefs, aDeviceSupportedLanguages, requestStatus, server); |
|
139 uissHandler->WorkUntilCompleteL(); |
|
140 User::WaitForRequest(requestStatus); |
|
141 err = requestStatus.Int(); |
|
142 |
|
143 CleanupStack::PopAndDestroy(uissHandler); |
|
144 } |
|
145 return err; |
|
146 } |
|
147 |
|
148 |
|
149 // |
|
150 // An override that takes a data provider interface pointer instead of a |
|
151 // file name |
|
152 // |
|
153 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
154 MSisDataProvider& aDataProvider, |
|
155 const CInstallPrefs& aInstallPrefs) |
|
156 { |
|
157 DEBUG_PRINTF(_L8("Sis Helper without Device supported languages - Launching Syncronous Install by filehandle.")); |
|
158 RArray<TInt> deviceSupportedLanguages; |
|
159 TRAPD(err, err=InstallL(aUiHandler, aDataProvider, aInstallPrefs,deviceSupportedLanguages)); |
|
160 DEBUG_PRINTF2(_L8("Sis Helper without Device supported languages - Install Result Was %d."), err); |
|
161 return err; |
|
162 } |
|
163 |
|
164 EXPORT_C TInt Launcher::Install(MUiHandler& aUiHandler, |
|
165 MSisDataProvider& aDataProvider, |
|
166 const CInstallPrefs& aInstallPrefs, |
|
167 const RArray<TInt>& aDeviceSupportedLanguages) |
|
168 { |
|
169 DEBUG_PRINTF(_L8("Sis Helper with Device supported languages - Launching Syncronous Install by filehandle.")); |
|
170 TRAPD(err, err=InstallL(aUiHandler, aDataProvider, aInstallPrefs,aDeviceSupportedLanguages)); |
|
171 DEBUG_PRINTF2(_L8("Sis Helper with Device supported languages - Install Result Was %d."), err); |
|
172 return err; |
|
173 } |
|
174 |
|
175 |
|
176 TInt Launcher::InstallL(MUiHandler& aUiHandler, |
|
177 MSisDataProvider& aDataProvider, |
|
178 const CInstallPrefs& aInstallPrefs, |
|
179 const RArray<TInt>& aDeviceSupportedLanguages) |
|
180 { |
|
181 TSisHelperStartParams params(aDataProvider); |
|
182 RThread server; |
|
183 TInt err = CSisHelperServer::StartSisHelper(params, server); |
|
184 |
|
185 if (err == KErrNone) |
|
186 { |
|
187 // Connect to UISS and start installation using asynchronous calls |
|
188 // and reverse completion |
|
189 CleanupClosePushL(server); |
|
190 CUissClientHandler* uissHandler = CUissClientHandler::NewLC(aUiHandler, false); |
|
191 CleanupStack::Pop(2,&server); |
|
192 CleanupStack::PushL(uissHandler); |
|
193 |
|
194 TRequestStatus requestStatus; |
|
195 uissHandler->InstallL(aInstallPrefs, aDeviceSupportedLanguages, requestStatus, server); |
|
196 uissHandler->WorkUntilCompleteL(); |
|
197 User::WaitForRequest(requestStatus); |
|
198 err = requestStatus.Int(); |
|
199 |
|
200 CleanupStack::PopAndDestroy(uissHandler); |
|
201 } |
|
202 return err; |
|
203 } |
|
204 |
|
205 |
|
206 |
|
207 EXPORT_C TInt Launcher::Uninstall(MUiHandler& aUiHandler, const TUid& aUid) |
|
208 { |
|
209 DEBUG_PRINTF2(_L8("Sis Helper - Launching uninstall by UID 0x%08x."), aUid.iUid); |
|
210 |
|
211 CSisRegistryPackage* package=NULL; |
|
212 |
|
213 TRAPD(err, package = CSisHelperServer::MainPackageEntryL(aUid)); |
|
214 |
|
215 if (err==KErrNone && package) |
|
216 { |
|
217 // Uninstall base index |
|
218 package->SetIndex(0); |
|
219 |
|
220 TRAP(err, err=UninstallL(aUiHandler, *package)); |
|
221 } |
|
222 |
|
223 delete package; |
|
224 |
|
225 DEBUG_PRINTF2(_L8("Sis Helper - Uninstall Result Was %d."), err); |
|
226 return err; |
|
227 } |
|
228 |
|
229 EXPORT_C TInt Launcher::Uninstall(MUiHandler& aUiHandler, const CSisRegistryPackage& aPackage) |
|
230 { |
|
231 DEBUG_PRINTF4(_L("Sis Helper - Launching uninstall by package. UID: 0x%08x, Name: %S, Vendor: %S."), |
|
232 aPackage.Uid().iUid, &(aPackage.Name()), &(aPackage.Vendor())); |
|
233 |
|
234 TRAPD(err, err=UninstallL(aUiHandler, aPackage)); |
|
235 |
|
236 DEBUG_PRINTF2(_L8("Sis Helper - Uninstall result was %d."), err); |
|
237 return err; |
|
238 } |
|
239 |
|
240 TInt Launcher::UninstallL(MUiHandler& aUiHandler, const CSisRegistryPackage& aPackage) |
|
241 { |
|
242 // Connect to UISS and start uninstallation using asynchronous calls |
|
243 // and reverse completion |
|
244 CUissClientHandler* uissHandler = CUissClientHandler::NewLC(aUiHandler, false); |
|
245 |
|
246 TRequestStatus requestStatus; |
|
247 uissHandler->UninstallL(aPackage, requestStatus); |
|
248 uissHandler->WorkUntilCompleteL(); |
|
249 User::WaitForRequest(requestStatus); |
|
250 |
|
251 CleanupStack::PopAndDestroy(uissHandler); |
|
252 return requestStatus.Int(); |
|
253 } |
|
254 |
|
255 ///\short Cancels [un]installation in progress. |
|
256 EXPORT_C int Launcher::Cancel() |
|
257 { |
|
258 RUissSession serverSession; |
|
259 TInt err=serverSession.Connect(); |
|
260 |
|
261 if (err<0) |
|
262 { |
|
263 return err; |
|
264 } |
|
265 |
|
266 err=serverSession.Cancel(); |
|
267 |
|
268 serverSession.Close(); |
|
269 return err; |
|
270 } |
|
271 |
|
272 } // namespace Swi |