51
|
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: Client for fotaserver
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDES
|
|
20 |
#include <bldvariant.hrh>
|
|
21 |
#include <fotaengine.h>
|
|
22 |
#include "FotaIPCTypes.h"
|
|
23 |
#include "fotaConst.h"
|
|
24 |
#include "fotaenginedebug.h"
|
|
25 |
#include <apgcli.h>
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
// =================== LOCAL FUNCTIONS ========================================
|
|
30 |
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
// StartServerL()
|
|
34 |
// Starts Fota Downlaod Interrupt Monitory server
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
TInt StartServerL()
|
|
37 |
{
|
|
38 |
FLOG(_L("StartServerLt Started"));
|
|
39 |
TInt res = KErrNone;
|
|
40 |
|
|
41 |
RProcess server;
|
|
42 |
RSemaphore sem;
|
|
43 |
res = sem.CreateGlobal(KFotaServerScem, EOwnerProcess);
|
|
44 |
|
|
45 |
res=server.Create(KFotaServerName,KNullDesC);
|
|
46 |
FLOG(_L("StartServerL-- create server error as %d"),res);
|
|
47 |
if (res!=KErrNone)
|
|
48 |
{
|
|
49 |
return res;
|
|
50 |
}
|
|
51 |
|
|
52 |
server.Resume(); // logon OK - start the server
|
|
53 |
|
|
54 |
sem.Wait();
|
|
55 |
sem.Close();
|
|
56 |
server.Close();
|
|
57 |
|
|
58 |
FLOG(_L("StartServerL-- server.ExitType() returns %d"),res);
|
|
59 |
|
|
60 |
return res;
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Connects to the server using 4 message slots.
|
|
65 |
*/
|
|
66 |
TBool RFotaEngineSession::connectToHbServer()
|
|
67 |
{
|
|
68 |
FLOG(_L("RFotaEngineSession::connectToHbServer >>"));
|
|
69 |
|
|
70 |
TInt error = CreateSession(KFotaServerName,TVersion(1,0,0),2);
|
|
71 |
|
|
72 |
if (KErrNone != error) {
|
|
73 |
FLOG(_L("RFotaEngineSession::Error: %d"), error);
|
|
74 |
}
|
|
75 |
FLOG(_L("RFotaEngineSession::connectToHbServer <<"));
|
|
76 |
return (KErrNone == error);
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// RFotaEngineSession::OpenL( )
|
|
81 |
// Opens session to fotaserver.
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
EXPORT_C void RFotaEngineSession::OpenL( )
|
|
84 |
{
|
|
85 |
RProcess pr; TFullName fn = pr.FullName();
|
|
86 |
|
|
87 |
TInt res = KErrNone;
|
|
88 |
FLOG(_L("[RFotaEngineSession] OpenL\tcalled by '%S' >>"),&fn );
|
|
89 |
|
|
90 |
res = connectToHbServer();
|
|
91 |
if(!res)
|
|
92 |
{
|
|
93 |
FLOG(_L("Creation of session failed with error: %d; starting the server now..."), res);
|
|
94 |
res = StartServerL();
|
|
95 |
|
|
96 |
FLOG(_L("Starting of the server, error = %d"), res);
|
|
97 |
User::LeaveIfError( res );
|
|
98 |
|
|
99 |
res = CreateSession( KFotaServerName,TVersion(1,0,0),2 );
|
|
100 |
FLOG(_L("Creation of session, error: %d; "), res);
|
|
101 |
User::LeaveIfError (res);
|
|
102 |
|
|
103 |
}
|
|
104 |
|
|
105 |
FLOG(_L("[RFotaEngineSession]\tconnected <<") );
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// RFotaEngineSession::Close( )
|
|
111 |
// Closes session to fotaserver
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
EXPORT_C void RFotaEngineSession::Close( )
|
|
114 |
{
|
|
115 |
RProcess pr; TFullName fn = pr.FullName();
|
|
116 |
FLOG(_L("[RFotaEngineSession] RFotaEngineSession::Close() >> called by '%S'"),&fn );
|
|
117 |
|
|
118 |
// Tell server that generic alert is sent for this pkg, so state is
|
|
119 |
// cleaned up
|
|
120 |
FLOG(_L("iGenericAlertSentPkgID = %d"), iGenericAlertSentPkgID);
|
|
121 |
if ( iGenericAlertSentPkgID != -1 )
|
|
122 |
{
|
|
123 |
TInt err = SendReceive( EGenericAlertSentForPackage
|
|
124 |
, TIpcArgs(iGenericAlertSentPkgID) );
|
|
125 |
}
|
|
126 |
|
|
127 |
RSessionBase::Close();
|
|
128 |
FLOG(_L("[RFotaEngineSession] RFotaEngineSession::Close() <<") );
|
|
129 |
}
|
|
130 |
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// RFotaEngineSession::Download
|
|
134 |
// Starts download of upd package.
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
EXPORT_C TInt RFotaEngineSession::Download(const TInt aPkgId
|
|
137 |
, const TDesC8& aPkgURL, const TSmlProfileId aProfileId
|
|
138 |
, const TDesC8& aPkgName, const TDesC8& aPkgVersion, TBool aSilent)
|
|
139 |
{
|
|
140 |
TInt err;
|
|
141 |
TDownloadIPCParams ipcparam;
|
|
142 |
ipcparam.iPkgId = aPkgId;
|
|
143 |
ipcparam.iProfileId = aProfileId;
|
|
144 |
ipcparam.iPkgName.Copy (aPkgName);
|
|
145 |
ipcparam.iPkgVersion.Copy (aPkgVersion);
|
|
146 |
TPckg<TDownloadIPCParams> pkg(ipcparam);
|
|
147 |
err = SendReceive ( EFotaDownload , TIpcArgs(&pkg, &aPkgURL, aSilent));
|
|
148 |
return err;
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
// RFotaEngineSession::DownloadAndUpdate
|
|
153 |
// Starts download and update of update pakcage
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
EXPORT_C TInt RFotaEngineSession::DownloadAndUpdate(const TInt aPkgId
|
|
156 |
,const TDesC8& aPkgURL, const TSmlProfileId aProfileId
|
|
157 |
,const TDesC8& aPkgName, const TDesC8& aPkgVersion, TBool aSilent)
|
|
158 |
{
|
|
159 |
TInt err;
|
|
160 |
TDownloadIPCParams ipcparam;
|
|
161 |
ipcparam.iPkgId = aPkgId;
|
|
162 |
ipcparam.iProfileId = aProfileId;
|
|
163 |
ipcparam.iPkgName.Copy (aPkgName);
|
|
164 |
ipcparam.iPkgVersion.Copy (aPkgVersion);
|
|
165 |
TPckg<TDownloadIPCParams> pkg(ipcparam);
|
|
166 |
err = SendReceive( EFotaDownloadAndUpdate, TIpcArgs(&pkg, &aPkgURL, aSilent));
|
|
167 |
return err;
|
|
168 |
}
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// RFotaEngineSession::Update
|
|
172 |
// Starts update of update package
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
EXPORT_C TInt RFotaEngineSession::Update(const TInt aPkgId
|
|
175 |
,const TSmlProfileId aProfileId, const TDesC8& aPkgName
|
|
176 |
,const TDesC8& aPkgVersion)
|
|
177 |
{
|
|
178 |
TInt err;
|
|
179 |
TDownloadIPCParams ipcparam;
|
|
180 |
ipcparam.iPkgId = aPkgId;
|
|
181 |
ipcparam.iProfileId = aProfileId;
|
|
182 |
ipcparam.iPkgName.Copy (aPkgName);
|
|
183 |
ipcparam.iPkgVersion.Copy (aPkgVersion);
|
|
184 |
TPckg<TDownloadIPCParams> pkg(ipcparam);
|
|
185 |
err = SendReceive ( EFotaUpdate , TIpcArgs(&pkg));
|
|
186 |
return err;
|
|
187 |
}
|
|
188 |
|
|
189 |
// --------------------------------------------------------------------------
|
|
190 |
// RFotaEngineSession::PauseDownload
|
|
191 |
// To pause the download
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
EXPORT_C TInt RFotaEngineSession::PauseDownload ( )
|
|
194 |
{
|
|
195 |
TInt err(KErrNotSupported);
|
|
196 |
|
|
197 |
err = SendReceive( EPauseDownload );
|
|
198 |
|
|
199 |
return err;
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
// RFotaEngineSession::TryResumeDownload
|
|
204 |
// Requests to resume the suspended download of the update package.
|
|
205 |
// Implementation is not ready and will be provided later.
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
EXPORT_C TInt RFotaEngineSession::TryResumeDownload(TBool aSilent)
|
|
208 |
{
|
|
209 |
FLOG(_L("RFotaEngineSession::TryResumeDownload >>"));
|
|
210 |
|
|
211 |
TInt err = KErrNone;
|
|
212 |
|
|
213 |
err = SendReceive( EFotaTryResumeDownload, TIpcArgs( aSilent) );
|
|
214 |
|
|
215 |
FLOG(_L("RFotaEngineSession::TryResumeDownload << err = %d" ),err);
|
|
216 |
return err;
|
|
217 |
}
|
|
218 |
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
// RFotaEngineSession::GetState
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
EXPORT_C RFotaEngineSession::TState RFotaEngineSession::GetState(
|
|
224 |
const TInt aPkgId)
|
|
225 |
{
|
|
226 |
FLOG(_L("RFotaEngineSession::GetState >>"));
|
|
227 |
|
|
228 |
RFotaEngineSession::TState state;
|
|
229 |
TPckg<RFotaEngineSession::TState> pkgstate(state);
|
|
230 |
SendReceive ( EGetState , TIpcArgs(aPkgId, &pkgstate));
|
|
231 |
FLOG(_L("RFotaEngineSession::GetState <<"));
|
|
232 |
|
|
233 |
return state;
|
|
234 |
}
|
|
235 |
|
|
236 |
// ---------------------------------------------------------------------------
|
|
237 |
// RFotaEngineSession::GetResult
|
|
238 |
// ---------------------------------------------------------------------------
|
|
239 |
EXPORT_C TInt RFotaEngineSession::GetResult(const TInt aPkgId)
|
|
240 |
{
|
|
241 |
FLOG(_L("RFotaEngineSession::GetResult"));
|
|
242 |
TInt result;
|
|
243 |
TPckg<TInt> pkgresult(result);
|
|
244 |
SendReceive ( EGetResult , TIpcArgs(aPkgId, &pkgresult));
|
|
245 |
return result;
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
// RFotaEngineSession::DeleteUpdatePackage
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
EXPORT_C TInt RFotaEngineSession::DeleteUpdatePackage(const TInt aPkgId)
|
|
253 |
{
|
|
254 |
TInt err = SendReceive(EDeletePackage, TIpcArgs(aPkgId) );
|
|
255 |
return err;
|
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
// RFotaEngineSession::LastUpdate
|
|
261 |
// ---------------------------------------------------------------------------
|
|
262 |
EXPORT_C TInt RFotaEngineSession::LastUpdate(TTime& aUpdates)
|
|
263 |
{
|
|
264 |
TInt err;
|
|
265 |
FLOG(_L("RFotaEngineSession::LastUpdate >>"));
|
|
266 |
TBuf<15> timestamp;
|
|
267 |
err = SendReceive ( EGetUpdateTimestamp, TIpcArgs(×tamp) );
|
|
268 |
|
|
269 |
if ( timestamp.Length() > 0 )
|
|
270 |
{
|
|
271 |
TInt year = timestamp[0];
|
|
272 |
TInt month = timestamp[1];
|
|
273 |
TInt day = timestamp[2];
|
|
274 |
TInt hour = timestamp[3];
|
|
275 |
TInt minute = timestamp[4];
|
|
276 |
aUpdates = TDateTime (year,(TMonth)month,day,hour,minute,0,0 );
|
|
277 |
}
|
|
278 |
else
|
|
279 |
{
|
|
280 |
aUpdates.Set( _L( "19900327:101010.000000" ) );
|
|
281 |
err = KErrUnknown;
|
|
282 |
}
|
|
283 |
FLOG(_L("RFotaEngineSession::LastUpdate <<"));
|
|
284 |
return err;
|
|
285 |
}
|
|
286 |
|
|
287 |
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
// RFotaEngineSession::CurrentVersion
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
EXPORT_C TInt RFotaEngineSession::CurrentVersion(TDes& aSWVersion)
|
|
292 |
{
|
|
293 |
aSWVersion.Copy(_L("1.0"));
|
|
294 |
return KErrNone;
|
|
295 |
}
|
|
296 |
|
|
297 |
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
// RFotaEngineSession::RFotaEngineSession
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
EXPORT_C RFotaEngineSession::RFotaEngineSession() : iGenericAlertSentPkgID(-1)
|
|
302 |
{
|
|
303 |
FLOG(_L("RFotaEngineSession::RFotaEngineSession() >>"));
|
|
304 |
FLOG(_L("RFotaEngineSession::RFotaEngineSession() <<"));
|
|
305 |
}
|
|
306 |
|
|
307 |
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// RFotaEngineSession::GetUpdatePackageIds
|
|
310 |
// Gets ids of the update packages present in the system.
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
EXPORT_C TInt RFotaEngineSession::GetUpdatePackageIds(TDes16& aPackageIdList)
|
|
313 |
{
|
|
314 |
TInt err;
|
|
315 |
FLOG(_L("RFotaEngineSession::GetUpdatePackageIds >>"));
|
|
316 |
TBuf<10> b; b.Copy(_L("dkkd"));
|
|
317 |
TPkgIdList pkgids;
|
|
318 |
TPckg<TPkgIdList> pkgids_pkg(pkgids);
|
|
319 |
TIpcArgs args ( &pkgids_pkg);
|
|
320 |
err = SendReceive ( EGetUpdatePackageIds, args);
|
|
321 |
aPackageIdList.Copy(pkgids);
|
|
322 |
FLOG(_L("RFotaEngineSession::GetUpdatePackageIds <<"));
|
|
323 |
return err;
|
|
324 |
}
|
|
325 |
|
|
326 |
|
|
327 |
EXPORT_C TVersion RFotaEngineSession::Version() const
|
|
328 |
{
|
|
329 |
TVersion version (1,0,0);
|
|
330 |
|
|
331 |
return version;
|
|
332 |
}
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// RFotaEngineSession::GenericAlertSentL
|
|
336 |
// marks genereic alert being sent
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
EXPORT_C void RFotaEngineSession::GenericAlertSentL ( const TInt aPackageID )
|
|
339 |
{
|
|
340 |
FLOG(_L("RFotaEngineSession::GenericAlertSentL, aPackageID = %d >>"),aPackageID);
|
|
341 |
iGenericAlertSentPkgID = aPackageID;
|
|
342 |
FLOG(_L("RFotaEngineSession::GenericAlertSentL, iGenericAlertSentPkgID = %d <<"), iGenericAlertSentPkgID);
|
|
343 |
}
|
|
344 |
|
|
345 |
// ---------------------------------------------------------------------------
|
|
346 |
// RFotaEngineSession::ScheduledUpdateL
|
|
347 |
// Update fw
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
EXPORT_C TInt RFotaEngineSession::ScheduledUpdateL ( const TFotaScheduledUpdate aSchedule )
|
|
350 |
{
|
|
351 |
TInt err(KErrNotSupported);
|
|
352 |
|
|
353 |
TPckg<TFotaScheduledUpdate> p(aSchedule);
|
|
354 |
err = SendReceive( EScheduledUpdate, TIpcArgs(&p) );
|
|
355 |
|
|
356 |
return err;
|
|
357 |
}
|
|
358 |
|
|
359 |
EXPORT_C void RFotaEngineSession::GetCurrentFirmwareDetailsL(TDes8& aName, TDes8& aVersion, TInt& aSize)
|
|
360 |
{
|
|
361 |
FLOG(_L("RFotaEngineSession::GetCurrentFirmwareDetailsL >>"));
|
|
362 |
|
|
363 |
TPckg<TInt> pkgsize(aSize);
|
|
364 |
|
|
365 |
__ASSERT_ALWAYS(aName.MaxLength() >= KFotaMaxPkgNameLength, User::Leave(KErrArgument) );
|
|
366 |
__ASSERT_ALWAYS(aName.MaxLength() >= KFotaMaxPkgVersionLength, User::Leave(KErrArgument) );
|
|
367 |
|
|
368 |
TInt err = SendReceive(EGetCurrFwDetails, TIpcArgs(&aName, &aVersion, &pkgsize));
|
|
369 |
|
|
370 |
FLOG(_L("RFotaEngineSession::GetCurrentFirmwareDetailsL, err = %d <<"), err);
|
|
371 |
User::LeaveIfError(err);
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------------------------
|
|
375 |
// RFotaEngineSession::ServiceUid
|
|
376 |
// Apparc asks which session class to create in server side
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
TUid RFotaEngineSession::ServiceUid() const
|
|
379 |
{
|
|
380 |
RProcess pr; TFullName fn = pr.FullName();
|
|
381 |
FLOG(_L( "RFotaEngineSession::ServiceUid() >> called by: %S" ), &fn );
|
|
382 |
FLOG(_L( "RFotaEngineSession::ServiceUid() << ret: 0x%X" ),
|
|
383 |
KFotaServiceUid );
|
|
384 |
return TUid::Uid( KFotaServiceUid );
|
|
385 |
}
|
|
386 |
|
|
387 |
/*
|
|
388 |
* The following exported functions are not supported in SF4
|
|
389 |
* They would be removed once stakeholder remove dependency with them.
|
|
390 |
* Polonium CR: 530
|
|
391 |
*/
|
|
392 |
|
|
393 |
EXPORT_C TBool RFotaEngineSession::IsPackageStoreSizeAvailable(
|
|
394 |
const TInt aSize)
|
|
395 |
{
|
|
396 |
return EFalse;
|
|
397 |
}
|
|
398 |
|
|
399 |
EXPORT_C TInt RFotaEngineSession::OpenUpdatePackageStore(const TInt aPkgId,
|
|
400 |
RWriteStream*& aPkgStore)
|
|
401 |
{
|
|
402 |
return KErrNotSupported;
|
|
403 |
}
|
|
404 |
|
|
405 |
EXPORT_C TInt RFotaEngineSession::GetDownloadUpdatePackageSize(
|
|
406 |
const TInt aPkgId, TInt& aDownloadedSize, TInt& aTotalSize)
|
|
407 |
{
|
|
408 |
return KErrNotSupported;
|
|
409 |
}
|
|
410 |
|
|
411 |
EXPORT_C void RFotaEngineSession::UpdatePackageDownloadComplete(
|
|
412 |
const TInt aPkgId)
|
|
413 |
{
|
|
414 |
|
|
415 |
}
|
|
416 |
|