1 /* |
|
2 * Copyright (c) 2005 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 "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: fotaengines server side session |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "FotasrvSession.h" |
|
22 #include "FotaSrvDebug.h" |
|
23 #include <eikenv.h> |
|
24 #include <eikappui.h> |
|
25 #include <s32mem.h> |
|
26 #include <e32base.h> |
|
27 #include <centralrepository.h> |
|
28 #include "FotaServer.h" |
|
29 #include "FotaSrvApp.h" |
|
30 // ============================= MEMBER FUNCTIONS ============================ |
|
31 |
|
32 class CFotaServer; |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CFotaSrvSession::CheckClientSecureIdL |
|
36 // Returns True if caller is syncml framework. False for fotasrv. |
|
37 // Leaves if client is unknown |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CFotaSrvSession::TClient CFotaSrvSession::CheckClientSecureIdL ( |
|
41 const RMessage2& aMessage) |
|
42 { |
|
43 //TClient client(EUnknown); |
|
44 TUid dmhostserver1 = TUid::Uid( KDMHostServer1Uid ); |
|
45 TUid fota = TUid::Uid( KFotaServerUid ); |
|
46 TUid omadmappui = TUid::Uid( KOmaDMAppUid ); |
|
47 TUid starter = TUid::Uid( KStarterUid ); |
|
48 TUid fscheduler = TUid::Uid( KFotaScheduler ); |
|
49 TUid fms = TUid::Uid( KFMSServerUid ); |
|
50 TUid softwarechecker = TUid::Uid( 0x2000BB96 ); |
|
51 TUid softwarecheckerbackground = TUid::Uid( 0x2000BB97 ); |
|
52 TUid testapp = TUid::Uid( 0x102073E4); |
|
53 |
|
54 TUid iadclient = TUid::Uid( 0x2000F85A ); |
|
55 |
|
56 // Syncml |
|
57 if ( aMessage.SecureId() == dmhostserver1.iUid ) |
|
58 { |
|
59 FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is \ |
|
60 DmHostserver!")); |
|
61 return EDMHostServer; |
|
62 } |
|
63 |
|
64 // OmaDMAPpui |
|
65 if ( aMessage.SecureId() == omadmappui.iUid ) |
|
66 { |
|
67 FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is \ |
|
68 omadmappui!")); |
|
69 return EOMADMAppUi; |
|
70 } |
|
71 |
|
72 // Fotaserver |
|
73 if ( aMessage.SecureId() == fota.iUid ) |
|
74 { |
|
75 FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is \ |
|
76 fotaserver!")); |
|
77 return EFotaServer; |
|
78 } |
|
79 |
|
80 // Starter |
|
81 if ( aMessage.SecureId() == starter.iUid ) |
|
82 { |
|
83 return EStarter; |
|
84 } |
|
85 |
|
86 |
|
87 |
|
88 // Software Checker app |
|
89 if ( aMessage.SecureId() == softwarechecker.iUid || aMessage.SecureId() == iadclient.iUid) |
|
90 { |
|
91 return ESoftwareChecker; |
|
92 } |
|
93 |
|
94 // Software Checker Background app |
|
95 if ( aMessage.SecureId() == softwarecheckerbackground.iUid ) |
|
96 { |
|
97 return ESoftwareCheckerBackground; |
|
98 } |
|
99 |
|
100 |
|
101 // *3* <- |
|
102 |
|
103 |
|
104 // Tester app for testing purp. |
|
105 if ( aMessage.SecureId() == 0x0323231 || aMessage.SecureId() == testapp.iUid) |
|
106 { |
|
107 return EFotaTestApp; |
|
108 } |
|
109 if ( aMessage.SecureId() == fms.iUid ) |
|
110 { |
|
111 return EFMSServer; |
|
112 } |
|
113 // schedulehandler |
|
114 if ( aMessage.SecureId() == fscheduler.iUid) |
|
115 { |
|
116 return EFotaTestApp; |
|
117 } |
|
118 |
|
119 FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client 0x%X is unknown \ |
|
120 (msg %d), bailing out"),aMessage.SecureId().iId, aMessage.Function()); |
|
121 User::Leave( KErrAccessDenied ); |
|
122 return EFotaTestApp; // compiler warning otherwise |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CFotaSrvSession::CFotaSrvSession |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CFotaSrvSession::CFotaSrvSession( ) |
|
131 { |
|
132 FLOG( _L( "CFotaSrvSession::CFotaSrvSession( )" ) ); |
|
133 iError = KErrNone; |
|
134 //iDoc = CEikonEnv::Static()->EikAppUi()->Document(); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CFotaSrvSession::~CFotaSrvSession |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 CFotaSrvSession::~CFotaSrvSession() |
|
142 { |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CFotaSrvSession::CreateL |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CFotaSrvSession::CreateL() |
|
150 { |
|
151 FLOG( _L( "CFotaSrvSession::CreateL() >>" ) ); |
|
152 CAknAppServiceBase::CreateL(); |
|
153 FLOG( _L( "CFotaSrvSession::CreateL() <<" ) ); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CFotaSrvSession::ServiceL |
|
158 // Handle client request |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CFotaSrvSession::ServiceL(const RMessage2& aMessage) |
|
162 { |
|
163 TInt err(KErrNone); |
|
164 TInt pkgid = 0; |
|
165 TPackageState state; |
|
166 RThread clt; aMessage.ClientL(clt); |
|
167 TFullName cltnm = clt.FullName(); |
|
168 FLOG(_L( "CFotaSrvSession::ServiceL %d serving for %S?" ) |
|
169 ,aMessage.Function(), &cltnm ); |
|
170 |
|
171 TInt cmd = aMessage.Function(); |
|
172 if(( cmd!= EGetState ) && (cmd!= EGetResult )) |
|
173 { |
|
174 TInt fotaValue(1); |
|
175 CRepository* centrep( NULL); |
|
176 TUid uidValue = {0x101F9A08}; // KCRFotaAdapterEnabled |
|
177 centrep = CRepository::NewL( uidValue); |
|
178 if(centrep ) |
|
179 { |
|
180 FLOG(_L("centralrepository found ")); |
|
181 centrep->Get( 1 , fotaValue ); // KCRFotaAdapterEnabled |
|
182 delete centrep; |
|
183 } |
|
184 if ( ! fotaValue ) |
|
185 { |
|
186 User::Leave( KErrNotSupported ); |
|
187 } |
|
188 } |
|
189 |
|
190 TClient client = CheckClientSecureIdL ( aMessage ); |
|
191 |
|
192 switch( aMessage.Function() ) |
|
193 { |
|
194 case EFotaFirstCommand: |
|
195 { |
|
196 } |
|
197 aMessage.Complete(KErrNone); |
|
198 break; |
|
199 case EFotaDownload: |
|
200 { |
|
201 FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOAD") ); |
|
202 TDownloadIPCParams ipc; |
|
203 TPckg<TDownloadIPCParams> pkg(ipc); |
|
204 aMessage.Read (0, pkg); |
|
205 TInt deslen = aMessage.GetDesLengthL (1); |
|
206 HBufC8* urlbuf = HBufC8::NewLC(deslen); |
|
207 TPtr8 urlptr = urlbuf->Des(); |
|
208 aMessage.Read (1,urlptr); |
|
209 FotaServer()->DownloadL(ipc,urlptr); |
|
210 CleanupStack::PopAndDestroy(); // urlbuf |
|
211 aMessage.Complete( KErrNone ); |
|
212 break; |
|
213 } |
|
214 case EFotaUpdate: |
|
215 { |
|
216 FLOG(_L( "CFotaSrvSession::ServiceL UPDATE" )); |
|
217 TDownloadIPCParams ipc; |
|
218 TPckg<TDownloadIPCParams> pkg(ipc); |
|
219 aMessage.Read( 0 ,pkg ); |
|
220 FotaServer()->SetInstallUpdateClientL(client); |
|
221 // If update started from omadmappui, no alert should be sent if |
|
222 // update is cancelled |
|
223 if ( client == EOMADMAppUi ) |
|
224 { |
|
225 ipc.iSendAlert = EFalse; |
|
226 } |
|
227 FotaServer()->UpdateL(ipc); |
|
228 aMessage.Complete( KErrNone ); |
|
229 break; |
|
230 } |
|
231 case EFotaDownloadAndUpdate: |
|
232 { |
|
233 FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOADANDUPDATE" )); |
|
234 TDownloadIPCParams ipc; |
|
235 TPckg<TDownloadIPCParams> pkg(ipc); |
|
236 aMessage.Read (0, pkg); |
|
237 TInt deslen = aMessage.GetDesLengthL (1); |
|
238 HBufC8* urlbuf = HBufC8::NewLC(deslen); |
|
239 TPtr8 urlptr = urlbuf->Des(); |
|
240 aMessage.Read (1,urlptr); |
|
241 FotaServer()->DownloadAndUpdateL(ipc,urlptr); |
|
242 CleanupStack::PopAndDestroy( urlbuf ); |
|
243 aMessage.Complete( KErrNone ); |
|
244 } |
|
245 break; |
|
246 case EFotaOpenUpdatePackageStore: |
|
247 { |
|
248 FLOG(_L("CFotaSrvSession::ServiceL OPENUPDATEPACKAGESTORE")); |
|
249 FotaServer()->OpenUpdatePackageStoreL( aMessage ); |
|
250 aMessage.Complete( KErrNone ); |
|
251 } |
|
252 break; |
|
253 |
|
254 case EFotaGetDownloadUpdatePackageSize: |
|
255 { |
|
256 TInt dlsize = 0; |
|
257 TInt totalsize = 0; |
|
258 pkgid = aMessage.Int0(); |
|
259 //err is already KErrNone. |
|
260 FotaServer()->GetDownloadUpdatePackageSizeL( pkgid, dlsize, totalsize ); |
|
261 TPckg<TInt> pkg2(dlsize); |
|
262 TPckg<TInt> pkg3 (totalsize); |
|
263 aMessage.Write (1,pkg2); |
|
264 aMessage.Write (2,pkg3); |
|
265 aMessage.Complete( KErrNone ); |
|
266 } |
|
267 break; |
|
268 |
|
269 case EFotaSendChunk: |
|
270 { |
|
271 FotaServer()->ReadChunkL( aMessage.Int0(),iError ); |
|
272 iError = KErrNone; |
|
273 aMessage.Complete( KErrNone ); |
|
274 } |
|
275 break; |
|
276 case EFotaReleaseChunkHandle: |
|
277 { |
|
278 FLOG(_L("CFotaSrvSession::ServiceL EFotaReleaseChunkHandle")); |
|
279 FotaServer()->UpdateDBdataL(); |
|
280 aMessage.Complete( KErrNone ); |
|
281 } |
|
282 break; |
|
283 |
|
284 case EFotaTryResumeDownload: |
|
285 { |
|
286 if (client == EOMADMAppUi ) |
|
287 { |
|
288 FotaServer()->TryResumeDownloadL(ETrue); // user initiated |
|
289 aMessage.Complete( KErrNone ); |
|
290 } |
|
291 else if (client == EFMSServer) |
|
292 { |
|
293 FotaServer()->TryResumeDownloadL(EFalse); // fms initiated |
|
294 aMessage.Complete( KErrNone ); |
|
295 } |
|
296 else if(client == EFotaTestApp) |
|
297 { |
|
298 FotaServer()->TryResumeDownloadL(EFalse); // fms initiated |
|
299 aMessage.Complete( KErrNone ); |
|
300 } |
|
301 else |
|
302 { |
|
303 aMessage.Complete ( KErrAccessDenied ); |
|
304 } |
|
305 } |
|
306 break; |
|
307 |
|
308 case EUpdatePackageDownloadComplete: |
|
309 { |
|
310 FLOG(_L("CFotaSrvSession::ServiceL \ |
|
311 UPDATEPACKAGEDOWNLOADCOMPLETE")); |
|
312 // If caller is syncmlDM framework, download is largeobject |
|
313 // download. If caller is other, download is Oma DL/http |
|
314 |
|
315 TBool largeobj = (client == EDMHostServer)? ETrue : EFalse; |
|
316 pkgid = aMessage.Int0(); |
|
317 FotaServer()->UpdatePackageDownloadCompleteL(largeobj |
|
318 , pkgid); |
|
319 aMessage.Complete( KErrNone ); |
|
320 } |
|
321 break; |
|
322 case EDeletePackage: |
|
323 { |
|
324 FLOG(_L( "CFotaSrvSession::ServiceL DELETEPACKAGE") ); |
|
325 pkgid = aMessage.Int0(); |
|
326 FotaServer()->DeletePackageL(pkgid); |
|
327 aMessage.Complete( KErrNone ); |
|
328 } |
|
329 break; |
|
330 case EGetState: |
|
331 { |
|
332 FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE >>" )); |
|
333 pkgid = aMessage.Int0(); |
|
334 |
|
335 // NSC_DM: commented out 2 strings below, otherwise it crashes from NSC with Kern-Exec 44 -> |
|
336 if (client != EOMADMAppUi && client != ESoftwareChecker && client != ESoftwareCheckerBackground && client != EFotaTestApp && pkgid < 0) |
|
337 aMessage.Complete (KErrArgument); |
|
338 // <- |
|
339 state = FotaServer()->GetStateL(pkgid); |
|
340 //Protecting state 25. If any client other than DM UI queries for state, 25 should not be sent and |
|
341 //20 will be sent instead. |
|
342 if (client != EOMADMAppUi && state.iState == RFotaEngineSession::EDownloadProgressingWithResume) |
|
343 state.iState = RFotaEngineSession::EDownloadProgressing; |
|
344 FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE << %d" ) |
|
345 ,state.iState); |
|
346 TPckg<RFotaEngineSession::TState> pkg2(state.iState); |
|
347 aMessage.Write (1, pkg2); |
|
348 aMessage.Complete (KErrNone); |
|
349 } |
|
350 break; |
|
351 case EGetResult: |
|
352 { |
|
353 FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT >>" )); |
|
354 pkgid = aMessage.Int0(); |
|
355 state = FotaServer()->GetStateL(pkgid); |
|
356 TPckg<TInt> pkg2(state.iResult); |
|
357 FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT << %d" ) |
|
358 ,state.iResult); |
|
359 aMessage.Write (1, pkg2); |
|
360 aMessage.Complete (err); |
|
361 break; |
|
362 } |
|
363 case EIsPackageStoreSizeAvailable: |
|
364 { |
|
365 FLOG(_L( "CFotaSrvSession::ServiceL \ |
|
366 ISPACKAGESTORESIZEAVAILABLE" )); |
|
367 |
|
368 TInt size = aMessage.Int0(); |
|
369 TBool avail; |
|
370 // In UI evolution, size of file will be checked by fotaserver itself. Keep following |
|
371 // until codhandler skips size check itself |
|
372 //#ifdef RD_OMADMAPPUI_UI_EVOLUTION |
|
373 if ( client == EFotaServer ) avail = ETrue; |
|
374 else avail = FotaServer()->IsPackageStoreSizeAvailableL( size ); |
|
375 /*#else |
|
376 avail = FotaServer()->IsPackageStoreSizeAvailableL( size ); |
|
377 #endif*/ |
|
378 TPckg<TBool> pavail(avail); |
|
379 aMessage.Write (1, pavail); |
|
380 aMessage.Complete (KErrNone); |
|
381 break; |
|
382 } |
|
383 |
|
384 case EGetUpdatePackageIds: |
|
385 { |
|
386 FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATEPACKAGEIDS" )); |
|
387 TPkgIdList pkgids; |
|
388 FotaServer()->GetUpdatePackageIdsL(pkgids); |
|
389 TPckg<TPkgIdList> pkgids_pkg(pkgids); |
|
390 aMessage.Write(0, pkgids_pkg); |
|
391 aMessage.Complete(KErrNone); |
|
392 } |
|
393 break; |
|
394 |
|
395 case EGetUpdateTimestamp: |
|
396 { |
|
397 FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATETIMESTAMP" )); |
|
398 TBuf16<15> timestamp; |
|
399 FotaServer()->GetUpdateTimeStampL(timestamp); |
|
400 aMessage.Write(0, timestamp ); |
|
401 aMessage.Complete(KErrNone); |
|
402 } |
|
403 break; |
|
404 |
|
405 case EGenericAlertSentForPackage: |
|
406 { |
|
407 FLOG(_L( "CFotaSrvSession::ServiceL EGENERICALERTSENT FOR PKGID" )); |
|
408 TInt pkgid = aMessage.Int0(); |
|
409 FotaServer()->GenericAlertSentL( pkgid ); |
|
410 aMessage.Complete( err ); |
|
411 } |
|
412 break; |
|
413 |
|
414 case EScheduledUpdate: |
|
415 { |
|
416 FLOG(_L( "CFotaSrvSession::ServiceL ESCHEDULEDUPDATE" )); |
|
417 TFotaScheduledUpdate sched(-1,-1); |
|
418 TPckg<TFotaScheduledUpdate> p(sched); |
|
419 aMessage.Read (0, p); |
|
420 FotaServer()->SetInstallUpdateClientL(client); |
|
421 FLOG(_L(" pkgid: %d scheduleid:%d"), sched.iPkgId,sched.iScheduleId); |
|
422 FotaServer()->ScheduledUpdateL( sched ); |
|
423 aMessage.Complete( KErrNone ); |
|
424 } |
|
425 break; |
|
426 |
|
427 default: |
|
428 { |
|
429 CAknAppServiceBase::ServiceL( aMessage ); |
|
430 } |
|
431 break; |
|
432 } |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------------------------- |
|
436 // CFotaSrvSession::ServiceError |
|
437 // --------------------------------------------------------------------------- |
|
438 // |
|
439 void CFotaSrvSession::ServiceError( const RMessage2& aMessage,TInt aError ) |
|
440 { |
|
441 FLOG(_L( "CFotaSrvSession::ServiceError %d" ),aError ); |
|
442 iError = aError; |
|
443 CFotaServer* f = FotaServer(); |
|
444 TRAPD(err2, f->iParentApp->SetUIVisibleL ( EFalse,ETrue ) ); |
|
445 if(err2); // remove compiler warning |
|
446 CAknAppServiceBase::ServiceError( aMessage, aError ); |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CFotaSrvSession::FotaServer |
|
451 // Helper function |
|
452 // --------------------------------------------------------------------------- |
|
453 // |
|
454 |
|
455 CFotaServer* CFotaSrvSession::FotaServer() const |
|
456 { |
|
457 return (CFotaServer* ) Server(); |
|
458 } |
|