56
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: This file defines the app removal handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <apgcli.h>
|
|
21 |
#include <apaid.h>
|
|
22 |
#include <apgnotif.h>
|
|
23 |
#include <driveinfo.h>
|
|
24 |
|
|
25 |
#include "lbttriggerfilterbyattribute.h"
|
|
26 |
#include "lbtappchangehandler.h"
|
|
27 |
#include "lbtcontainertriggerfilter.h"
|
|
28 |
#include "lbtcontainerupdatefilter.h"
|
|
29 |
#include "lbtcontainer.h"
|
|
30 |
#include "lbtcleanuphandler.h"
|
|
31 |
#include "lbtserverlogictriggerchangeobserver.h"
|
|
32 |
#include "lbtlogger.h"
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
_LIT(KMMCErrorChar, "<"); //if MMC card char retrieval failed, it is assigned.
|
|
36 |
_LIT(KCharColon, ":");
|
|
37 |
|
|
38 |
// LOCAL ENUMS
|
|
39 |
|
|
40 |
enum
|
|
41 |
{
|
|
42 |
EOpNone,
|
|
43 |
EOpRegiseteredForInitialListPoplulation,
|
|
44 |
EOpRegiseteredForListPoplulation,
|
|
45 |
EOpRemovalTriggerDeletion,
|
|
46 |
EOpDeletionStartupProcessTriggers,
|
|
47 |
EOpRemovalListingStartupProcessTriggers,
|
|
48 |
EOpRemovalDeletingStartupProcessTriggers,
|
|
49 |
EOpRemovalTriggerInvalidation,
|
|
50 |
EOpMMCRemovalListingTriggers,
|
|
51 |
EOpMMCRemovalListingTriggerForStartupProcess,
|
|
52 |
EOpMMCInsertionListingTriggers,
|
|
53 |
EOpMMCInsertionListingTriggerForStartupProcess,
|
|
54 |
EOpRequestValidityChange
|
|
55 |
};
|
|
56 |
|
|
57 |
|
|
58 |
// LOCAL STRUCTURES
|
|
59 |
struct TLbtAppInfo
|
|
60 |
{
|
|
61 |
TFileName iFullName;
|
|
62 |
TUid iUid;
|
|
63 |
};
|
|
64 |
|
|
65 |
// ======== LOCAL FUNCTIONS ========
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// CLbtAppRemovalHandler::NewL
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
CLbtAppChangeHandler* CLbtAppChangeHandler::NewL(CLbtContainer& aContainer, CLbtCleanupHandler& aCleanupHandler,
|
|
72 |
MLbtServerLogicTriggerChangeObserver& aTriggerChangeObserver)
|
|
73 |
{
|
|
74 |
FUNC_ENTER("CLbtAppChangeHandler::NewL");
|
|
75 |
CLbtAppChangeHandler* self = new (ELeave) CLbtAppChangeHandler(aContainer,aCleanupHandler,
|
|
76 |
aTriggerChangeObserver);
|
|
77 |
CleanupStack::PushL( self );
|
|
78 |
self->ConstructL();
|
|
79 |
CleanupStack::Pop( self );
|
|
80 |
return self;
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CLbtAppChangeHandler::ConstructL
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CLbtAppChangeHandler::ConstructL()
|
|
88 |
{
|
|
89 |
FUNC_ENTER("CLbtAppChangeHandler::ConstructL");
|
|
90 |
User::LeaveIfError(iAppArcSession.Connect());
|
|
91 |
MemoryCardChar();
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
// CLbtAppChangeHandler::StartListeningL
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CLbtAppChangeHandler::StartListeningL()
|
|
99 |
{
|
|
100 |
FUNC_ENTER("CLbtAppChangeHandler::StartListeningL");
|
|
101 |
if(!iAppListNotifier)
|
|
102 |
{
|
|
103 |
iAppListNotifier = CApaAppListNotifier::NewL(this, CActive::EPriorityStandard);
|
|
104 |
|
|
105 |
iAppArcSession.RegisterListPopulationCompleteObserver(iStatus);
|
|
106 |
iOperation = EOpRegiseteredForInitialListPoplulation;
|
|
107 |
SetActive();
|
|
108 |
}
|
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
// CLbtAppChangeHandler::FindElementInArray
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
TInt CLbtAppChangeHandler::FindElementInArray(RArray<TLbtAppInfo>& aArray, TLbtAppInfo& aElement)
|
|
116 |
{
|
|
117 |
FUNC_ENTER("CLbtAppChangeHandler::FindElementInArray");
|
|
118 |
// Parse the array to find out if the element is present
|
|
119 |
for(TInt i=0;i<aArray.Count();++i)
|
|
120 |
{
|
|
121 |
if(aArray[i].iUid == aElement.iUid)
|
|
122 |
{
|
|
123 |
return i;
|
|
124 |
}
|
|
125 |
}
|
|
126 |
return KErrNotFound;
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
// CLbtAppChangeHandler::HandleAppListRemovalEvent
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CLbtAppChangeHandler::HandleAppListRemovalEvent(RArray<TLbtAppInfo>& aNewAppList)
|
|
134 |
{
|
|
135 |
FUNC_ENTER("CLbtAppChangeHandler::HandleAppListRemovalEvent");
|
|
136 |
|
|
137 |
RArray<TUid> appRemovalList;
|
|
138 |
TBool appsInMMC = EFalse;
|
|
139 |
|
|
140 |
/// Check which apps is un-installed/removed
|
|
141 |
for(TInt i=0;i<iCurrentInstalledApps.Count();++i)
|
|
142 |
{
|
|
143 |
TInt index = FindElementInArray(aNewAppList, iCurrentInstalledApps[i]);
|
|
144 |
|
|
145 |
if(KErrNotFound == index)
|
|
146 |
{
|
|
147 |
// This application has be uninstalled/removed
|
|
148 |
TLbtAppInfo appInfo = iCurrentInstalledApps[i];
|
|
149 |
|
|
150 |
// The removed application resided in the MMC card
|
|
151 |
iAppList.Append( appInfo );
|
|
152 |
|
|
153 |
// Check if the application resides in MMC
|
|
154 |
if( appInfo.iFullName.FindC(iMMCDriveChar) >= 0 )
|
|
155 |
{
|
|
156 |
appsInMMC = ETrue;
|
|
157 |
}
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
if( iAppList.Count() == 0 )
|
|
162 |
{
|
|
163 |
iAppList.Reset();
|
|
164 |
LOG("No application found removed");
|
|
165 |
return;
|
|
166 |
}
|
|
167 |
|
|
168 |
TInt error = KErrNone;
|
|
169 |
if( appsInMMC )
|
|
170 |
{
|
|
171 |
TRAP(error, HandleMMCApplicationRemovalL() );
|
|
172 |
}
|
|
173 |
else
|
|
174 |
{
|
|
175 |
TRAP(error, HandleApplicationUninstallationL());
|
|
176 |
}
|
|
177 |
|
|
178 |
if( error != KErrNone )
|
|
179 |
{
|
|
180 |
iOperation = EOpNone;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
// CLbtAppChangeHandler::HandleAppListAdditionEvent
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CLbtAppChangeHandler::HandleAppListAdditionEvent(RArray<TLbtAppInfo>& aNewAppList)
|
|
189 |
{
|
|
190 |
FUNC_ENTER("CLbtAppChangeHandler::HandleAppListAdditionEvent");
|
|
191 |
// Check which all app(s) have been added back
|
|
192 |
for(TInt i=0;i<aNewAppList.Count();++i)
|
|
193 |
{
|
|
194 |
TInt index = FindElementInArray(iCurrentInstalledApps, aNewAppList[i]);
|
|
195 |
|
|
196 |
if(KErrNotFound == index)
|
|
197 |
{
|
|
198 |
// This application has been added
|
|
199 |
TLbtAppInfo appInfo = aNewAppList[i];
|
|
200 |
|
|
201 |
if( appInfo.iFullName.FindC( iMMCDriveChar ) >= 0 )
|
|
202 |
{
|
|
203 |
// Append to the array only if the application resides on the MMC
|
|
204 |
iAppList.Append( appInfo );
|
|
205 |
}
|
|
206 |
}
|
|
207 |
}
|
|
208 |
if(iAppList.Count() > 0)
|
|
209 |
{
|
|
210 |
TRAPD(error, SetValidTriggersOfApplicationsL());
|
|
211 |
|
|
212 |
if(error != KErrNone)
|
|
213 |
{
|
|
214 |
ERROR("SetValidTriggersOfApplicationsL error = %d", error);
|
|
215 |
iAppList.Close();
|
|
216 |
iOperation = EOpNone;
|
|
217 |
}
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
// CLbtAppChangeHandler::SetValidTriggersOfApplicationsL
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CLbtAppChangeHandler::SetValidTriggersOfApplicationsL()
|
|
226 |
{
|
|
227 |
FUNC_ENTER("CLbtAppChangeHandler::SetValidTriggersOfApplicationsL");
|
|
228 |
// First do a list triggers to get the list of triggers owned by that application
|
|
229 |
iOperation = EOpMMCInsertionListingTriggers;
|
|
230 |
|
|
231 |
CLbtListTriggerOptions* listOptions = CLbtListTriggerOptions::NewL();
|
|
232 |
CleanupStack::PushL(listOptions);
|
|
233 |
|
|
234 |
CLbtTriggerFilterByAttribute* attributeFilter =
|
|
235 |
CLbtTriggerFilterByAttribute::NewL();
|
|
236 |
CleanupStack::PushL(attributeFilter);
|
|
237 |
attributeFilter->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
238 |
|
|
239 |
listOptions->SetFilter(attributeFilter);
|
|
240 |
|
|
241 |
// Retreive only the trigger id of the trigger
|
|
242 |
TLbtTriggerAttributeFieldsMask mask = CLbtTriggerEntry::EAttributeId;
|
|
243 |
listOptions->SetRetrievedFields(mask, 0);
|
|
244 |
|
|
245 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
246 |
CleanupStack::PushL(containerFilter);
|
|
247 |
|
|
248 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
249 |
{
|
|
250 |
containerFilter->AddOwnerSidInFilterL(iAppList[i].iUid);
|
|
251 |
}
|
|
252 |
|
|
253 |
CLbtContainerListOptions* containerListOptions = CLbtContainerListOptions::NewL(listOptions, containerFilter);
|
|
254 |
CleanupStack::PushL(containerListOptions);
|
|
255 |
|
|
256 |
CleanupStack::Pop(4); // containerListOptions, containerFilter, attributeFilter & listOptions
|
|
257 |
|
|
258 |
iContainer.ListTriggers(containerListOptions, iTriggerEntries, iOpId, iStatus);
|
|
259 |
SetActive();
|
|
260 |
}
|
|
261 |
|
|
262 |
// ---------------------------------------------------------------------------
|
|
263 |
// CLbtAppChangeHandler::HandleAppListEvent
|
|
264 |
// ---------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
void CLbtAppChangeHandler::HandleAppListEvent(TInt /*aEvent*/)
|
|
267 |
{
|
|
268 |
FUNC_ENTER("CLbtAppChangeHandler::HandleAppListEvent");
|
|
269 |
if( iOperation == EOpNone && !IsActive() )
|
|
270 |
{
|
|
271 |
iOperation = EOpRegiseteredForListPoplulation;
|
|
272 |
iAppArcSession.RegisterListPopulationCompleteObserver(iStatus);
|
|
273 |
SetActive();
|
|
274 |
return;
|
|
275 |
}
|
|
276 |
iOperation = EOpNone;
|
|
277 |
RArray<TLbtAppInfo> newAppList;
|
|
278 |
|
|
279 |
// First get the set of installed applications in the system
|
|
280 |
iAppArcSession.GetAllApps();
|
|
281 |
|
|
282 |
TApaAppInfo appInfo;
|
|
283 |
TInt error = iAppArcSession.GetNextApp(appInfo);
|
|
284 |
|
|
285 |
while(KErrNone == error)
|
|
286 |
{
|
|
287 |
TLbtAppInfo lbtAppInfo;
|
|
288 |
lbtAppInfo.iUid = appInfo.iUid;
|
|
289 |
lbtAppInfo.iFullName.Zero();
|
|
290 |
lbtAppInfo.iFullName.Copy( appInfo.iFullName );
|
|
291 |
|
|
292 |
TRAPD(err, newAppList.AppendL(lbtAppInfo));
|
|
293 |
if(err != KErrNone)
|
|
294 |
{
|
|
295 |
break;
|
|
296 |
}
|
|
297 |
error = iAppArcSession.GetNextApp(appInfo);
|
|
298 |
}
|
|
299 |
|
|
300 |
LOG1("newAppList.Count():%d",newAppList.Count());
|
|
301 |
LOG1("iCurrentInstalledApps.Count():%d",iCurrentInstalledApps.Count());
|
|
302 |
|
|
303 |
if(newAppList.Count() > iCurrentInstalledApps.Count())
|
|
304 |
{
|
|
305 |
HandleAppListAdditionEvent(newAppList);
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
LOG("newAppList.Count() < iCurrentInstalledApps.Count()");
|
|
310 |
HandleAppListRemovalEvent(newAppList);
|
|
311 |
}
|
|
312 |
|
|
313 |
iCurrentInstalledApps.Reset();
|
|
314 |
|
|
315 |
for( TInt i=0;i<newAppList.Count();i++ )
|
|
316 |
{
|
|
317 |
iCurrentInstalledApps.Append( newAppList[i] );
|
|
318 |
}
|
|
319 |
newAppList.Close();
|
|
320 |
}
|
|
321 |
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
// CLbtAppChangeHandler::StopListening
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
void CLbtAppChangeHandler::StopListening()
|
|
327 |
{
|
|
328 |
FUNC_ENTER("CLbtAppChangeHandler::StopListening");
|
|
329 |
delete iAppListNotifier;
|
|
330 |
iAppListNotifier = NULL;
|
|
331 |
iCurrentInstalledApps.Close();
|
|
332 |
}
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// CLbtAppChangeHandler::HandleMMCApplicationRemovalL
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
void CLbtAppChangeHandler::HandleMMCApplicationRemovalL()
|
|
339 |
{
|
|
340 |
FUNC_ENTER("CLbtAppChangeHandler::HandleMMCApplicationRemovalL");
|
|
341 |
|
|
342 |
if( IsMemoryCardPresent() )
|
|
343 |
{
|
|
344 |
// If memory card is present it means to say that the application
|
|
345 |
// has been un-installed
|
|
346 |
HandleApplicationUninstallationL( );
|
|
347 |
}
|
|
348 |
else
|
|
349 |
{
|
|
350 |
// MMC card has been removed. Hence invalidate all the triggers that
|
|
351 |
// belong to the application.
|
|
352 |
|
|
353 |
// First do a list triggers to get the list of triggers owned by that application
|
|
354 |
iOperation = EOpMMCRemovalListingTriggers;
|
|
355 |
|
|
356 |
CLbtListTriggerOptions* listOptions = CLbtListTriggerOptions::NewL();
|
|
357 |
CleanupStack::PushL(listOptions);
|
|
358 |
|
|
359 |
CLbtTriggerFilterByAttribute* attributeFilter =
|
|
360 |
CLbtTriggerFilterByAttribute::NewL();
|
|
361 |
CleanupStack::PushL(attributeFilter);
|
|
362 |
attributeFilter->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
363 |
|
|
364 |
listOptions->SetFilter(attributeFilter);
|
|
365 |
|
|
366 |
// Retreive only the trigger id of the trigger
|
|
367 |
TLbtTriggerAttributeFieldsMask mask = CLbtTriggerEntry::EAttributeId;
|
|
368 |
listOptions->SetRetrievedFields(mask, 0);
|
|
369 |
|
|
370 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
371 |
CleanupStack::PushL(containerFilter);
|
|
372 |
|
|
373 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
374 |
{
|
|
375 |
containerFilter->AddOwnerSidInFilterL(iAppList[i].iUid);
|
|
376 |
}
|
|
377 |
|
|
378 |
CLbtContainerListOptions* containerListOptions = CLbtContainerListOptions::NewL(listOptions, containerFilter);
|
|
379 |
CleanupStack::PushL(containerListOptions);
|
|
380 |
|
|
381 |
CleanupStack::Pop(4); // containerListOptions, containerFilter, attributeFilter & listOptions
|
|
382 |
|
|
383 |
iContainer.ListTriggers(containerListOptions, iTriggerEntries, iOpId, iStatus);
|
|
384 |
SetActive();
|
|
385 |
}
|
|
386 |
}
|
|
387 |
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
// CLbtAppChangeHandler::ListTriggersOfStartupProcessL
|
|
390 |
// ---------------------------------------------------------------------------
|
|
391 |
//
|
|
392 |
void CLbtAppChangeHandler::ListTriggersOfStartupProcessL()
|
|
393 |
{
|
|
394 |
FUNC_ENTER("CLbtAppChangeHandler::ListTriggersOfStartupProcessL");
|
|
395 |
CLbtListTriggerOptions* listOptions = CLbtListTriggerOptions::NewL();
|
|
396 |
CleanupStack::PushL(listOptions);
|
|
397 |
|
|
398 |
CLbtTriggerFilterByAttribute* attributeFilter =
|
|
399 |
CLbtTriggerFilterByAttribute::NewL();
|
|
400 |
CleanupStack::PushL(attributeFilter);
|
|
401 |
attributeFilter->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
402 |
|
|
403 |
listOptions->SetFilter(attributeFilter);
|
|
404 |
|
|
405 |
// Retreive only the trigger id of the trigger
|
|
406 |
TLbtTriggerAttributeFieldsMask mask = CLbtTriggerEntry::EAttributeId;
|
|
407 |
listOptions->SetRetrievedFields(mask, 0);
|
|
408 |
|
|
409 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
410 |
CleanupStack::PushL(containerFilter);
|
|
411 |
|
|
412 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
413 |
{
|
|
414 |
containerFilter->AddStartupProcessInFilterL( iAppList[i].iFullName );
|
|
415 |
}
|
|
416 |
|
|
417 |
CLbtContainerListOptions* containerListOptions = CLbtContainerListOptions::NewL(listOptions, containerFilter);
|
|
418 |
CleanupStack::PushL(containerListOptions);
|
|
419 |
|
|
420 |
CleanupStack::Pop(4); // containerListOptions, containerFilter, attributeFilter & listOptions
|
|
421 |
|
|
422 |
iContainer.ListTriggers(containerListOptions, iTriggerEntries, iOpId, iStatus);
|
|
423 |
SetActive();
|
|
424 |
}
|
|
425 |
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
// CLbtAppChangeHandler::DeleteTriggersOfStartupProcessL
|
|
428 |
// ---------------------------------------------------------------------------
|
|
429 |
//
|
|
430 |
void CLbtAppChangeHandler::DeleteTriggersOfStartupProcessL()
|
|
431 |
{
|
|
432 |
FUNC_ENTER("CLbtAppChangeHandler::DeleteTriggersOfStartupProcessL");
|
|
433 |
CLbtContainerUpdateFilter* updateOptions = CLbtContainerUpdateFilter::NewL();
|
|
434 |
CleanupStack::PushL(updateOptions);
|
|
435 |
|
|
436 |
CLbtTriggerFilterByAttribute* attributeFilter =
|
|
437 |
CLbtTriggerFilterByAttribute::NewL();
|
|
438 |
CleanupStack::PushL(attributeFilter);
|
|
439 |
attributeFilter->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
440 |
|
|
441 |
updateOptions->SetTrigInfoFilter(attributeFilter);
|
|
442 |
|
|
443 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
444 |
CleanupStack::PushL(containerFilter);
|
|
445 |
|
|
446 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
447 |
{
|
|
448 |
containerFilter->AddStartupProcessInFilterL( iAppList[i].iFullName );
|
|
449 |
}
|
|
450 |
updateOptions->SetContainerFilter(containerFilter);
|
|
451 |
|
|
452 |
CleanupStack::Pop(3); // containerFilter, attributeFilter & updateOptions
|
|
453 |
|
|
454 |
iContainer.DeleteTriggers(updateOptions, iOpId, iStatus);
|
|
455 |
SetActive();
|
|
456 |
}
|
|
457 |
|
|
458 |
|
|
459 |
// ---------------------------------------------------------------------------
|
|
460 |
// CLbtAppChangeHandler::IsMemoryCardPresent
|
|
461 |
// ---------------------------------------------------------------------------
|
|
462 |
//
|
|
463 |
TBool CLbtAppChangeHandler::IsMemoryCardPresent()
|
|
464 |
{
|
|
465 |
FUNC_ENTER("CLbtAppChangeHandler::IsMemoryCardPresent");
|
|
466 |
|
|
467 |
//retrieve memory card identifier
|
|
468 |
TInt drive;
|
|
469 |
TInt err = DriveInfo::GetDefaultDrive(
|
|
470 |
DriveInfo::EDefaultRemovableMassStorage, drive);
|
|
471 |
if( err != KErrNone )
|
|
472 |
return EFalse;
|
|
473 |
|
|
474 |
//connect to file server
|
|
475 |
RFs fs;
|
|
476 |
err = fs.Connect();
|
|
477 |
|
|
478 |
if(err != KErrNone)
|
|
479 |
{
|
|
480 |
return EFalse;
|
|
481 |
}
|
|
482 |
|
|
483 |
//check if memory card is present
|
|
484 |
TUint status;
|
|
485 |
err = DriveInfo::GetDriveStatus( fs, drive, status );
|
|
486 |
fs.Close();
|
|
487 |
|
|
488 |
if( err != KErrNone )
|
|
489 |
return EFalse;
|
|
490 |
return ( status & DriveInfo::EDrivePresent );
|
|
491 |
|
|
492 |
}
|
|
493 |
|
|
494 |
// ---------------------------------------------------------------------------
|
|
495 |
// void CLbtAppChangeHandler::MemoryCardChar()
|
|
496 |
// ---------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
void CLbtAppChangeHandler::MemoryCardChar()
|
|
499 |
{
|
|
500 |
TInt drive;
|
|
501 |
TInt err = DriveInfo::GetDefaultDrive(
|
|
502 |
DriveInfo::EDefaultRemovableMassStorage, drive);
|
|
503 |
//if memory card is not supported
|
|
504 |
if( err!=KErrNone )
|
|
505 |
{
|
|
506 |
iMMCDriveChar.Copy(KMMCErrorChar);
|
|
507 |
return;
|
|
508 |
}
|
|
509 |
|
|
510 |
//retrieve memory card character
|
|
511 |
RFs fs;
|
|
512 |
err = fs.Connect();
|
|
513 |
if( err==KErrNone )
|
|
514 |
{
|
|
515 |
TChar memChar;
|
|
516 |
fs.DriveToChar(drive,memChar);
|
|
517 |
iMMCDriveChar.Zero();
|
|
518 |
iMMCDriveChar.Append( memChar );
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
iMMCDriveChar.Copy(KMMCErrorChar);
|
|
523 |
}
|
|
524 |
iMMCDriveChar.Append(KCharColon);
|
|
525 |
fs.Close();
|
|
526 |
}
|
|
527 |
|
|
528 |
// ---------------------------------------------------------------------------
|
|
529 |
// CLbtAppChangeHandler::RunL
|
|
530 |
// ---------------------------------------------------------------------------
|
|
531 |
//
|
|
532 |
void CLbtAppChangeHandler::RunL()
|
|
533 |
{
|
|
534 |
FUNC_ENTER("CLbtAppChangeHandler::RunL");
|
|
535 |
switch(iOperation)
|
|
536 |
{
|
|
537 |
case EOpRegiseteredForInitialListPoplulation:
|
|
538 |
{
|
|
539 |
// First get the set of installed applications in the system
|
|
540 |
iAppArcSession.GetAllApps();
|
|
541 |
|
|
542 |
TApaAppInfo appInfo;
|
|
543 |
TInt error = iAppArcSession.GetNextApp(appInfo);
|
|
544 |
|
|
545 |
while(KErrNone == error)
|
|
546 |
{
|
|
547 |
TLbtAppInfo lbtAppInfo;
|
|
548 |
lbtAppInfo.iUid = appInfo.iUid;
|
|
549 |
lbtAppInfo.iFullName.Zero();
|
|
550 |
lbtAppInfo.iFullName.Copy( appInfo.iFullName );
|
|
551 |
|
|
552 |
iCurrentInstalledApps.AppendL(lbtAppInfo);
|
|
553 |
error = iAppArcSession.GetNextApp(appInfo);
|
|
554 |
}
|
|
555 |
iOperation = EOpNone;
|
|
556 |
break;
|
|
557 |
}
|
|
558 |
case EOpRegiseteredForListPoplulation:
|
|
559 |
{
|
|
560 |
HandleAppListEvent(KErrNone);
|
|
561 |
break;
|
|
562 |
}
|
|
563 |
case EOpRemovalTriggerDeletion:
|
|
564 |
{
|
|
565 |
// Here the observer is set to the get the information pertaining
|
|
566 |
// triggers that were deleted.
|
|
567 |
TLbtTriggerEventMask eventMask = 0;
|
|
568 |
eventMask|= CLbtContainer::ELbtConTriggerDeleted;
|
|
569 |
iContainer.SetChangeObserver( this,eventMask );
|
|
570 |
|
|
571 |
// Delete triggers for which the un-installed application is the
|
|
572 |
// startup process
|
|
573 |
iOperation = EOpDeletionStartupProcessTriggers;
|
|
574 |
DeleteTriggersOfStartupProcessL();
|
|
575 |
break;
|
|
576 |
}
|
|
577 |
case EOpRemovalListingStartupProcessTriggers:
|
|
578 |
{
|
|
579 |
// Here the observer is set to the get the information pertaining
|
|
580 |
// triggers that were deleted.
|
|
581 |
TLbtTriggerEventMask eventMask = 0;
|
|
582 |
eventMask|= CLbtContainer::ELbtConTriggerDeleted;
|
|
583 |
iContainer.SetChangeObserver( this,eventMask );
|
|
584 |
|
|
585 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
586 |
CleanupStack::PushL(containerFilter);
|
|
587 |
|
|
588 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
589 |
{
|
|
590 |
containerFilter->AddOwnerSidInFilterL(iAppList[i].iUid);
|
|
591 |
}
|
|
592 |
|
|
593 |
CLbtTriggerFilterByAttribute* filterByAttribute =
|
|
594 |
CLbtTriggerFilterByAttribute::NewL();
|
|
595 |
CleanupStack::PushL(filterByAttribute);
|
|
596 |
filterByAttribute->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
597 |
|
|
598 |
CLbtContainerUpdateFilter* updateFilter = CLbtContainerUpdateFilter::NewL(filterByAttribute ,containerFilter);
|
|
599 |
|
|
600 |
iContainer.DeleteTriggers(updateFilter, iOpId, iStatus);
|
|
601 |
SetActive();
|
|
602 |
iOperation = EOpRemovalDeletingStartupProcessTriggers;
|
|
603 |
break;
|
|
604 |
}
|
|
605 |
case EOpRemovalDeletingStartupProcessTriggers:
|
|
606 |
{
|
|
607 |
// Here the observer is set to the get the information pertaining
|
|
608 |
// triggers that were deleted.
|
|
609 |
TLbtTriggerEventMask eventMask = 0;
|
|
610 |
eventMask|= CLbtContainer::ELbtConTriggerDeleted;
|
|
611 |
iContainer.SetChangeObserver( this,eventMask );
|
|
612 |
break;
|
|
613 |
}
|
|
614 |
|
|
615 |
case EOpMMCInsertionListingTriggers:
|
|
616 |
case EOpMMCRemovalListingTriggers:
|
|
617 |
{
|
|
618 |
// Listing Triggers of startup process
|
|
619 |
LOG("Listing Triggers Over");
|
|
620 |
|
|
621 |
if( iOperation == EOpMMCInsertionListingTriggers )
|
|
622 |
{
|
|
623 |
iOperation = EOpMMCInsertionListingTriggerForStartupProcess;
|
|
624 |
}
|
|
625 |
else
|
|
626 |
{
|
|
627 |
iOperation = EOpMMCRemovalListingTriggerForStartupProcess;
|
|
628 |
}
|
|
629 |
|
|
630 |
ListTriggersOfStartupProcessL();
|
|
631 |
iAppList.Close();
|
|
632 |
LOG("Listing Triggers for startup Process");
|
|
633 |
break;
|
|
634 |
}
|
|
635 |
case EOpMMCRemovalListingTriggerForStartupProcess:
|
|
636 |
case EOpMMCInsertionListingTriggerForStartupProcess:
|
|
637 |
{
|
|
638 |
LOG("Listing Trigger For startup Process Done");
|
|
639 |
LOG1("iStatus = %d", iStatus.Int());
|
|
640 |
LOG1("Triggers Count = %d", iTriggerEntries.Count());
|
|
641 |
if(KErrNone == iStatus.Int())
|
|
642 |
{
|
|
643 |
// The list operation is a success. Hence invalidate the triggers now
|
|
644 |
RArray<TLbtTriggerId> triggerIds;
|
|
645 |
|
|
646 |
for(TInt i=0;i<iTriggerEntries.Count();++i)
|
|
647 |
{
|
|
648 |
triggerIds.Append(iTriggerEntries[i]->TriggerEntry()->Id());
|
|
649 |
}
|
|
650 |
|
|
651 |
TLbtTriggerDynamicInfo::TLbtTriggerValidity validity;
|
|
652 |
|
|
653 |
if(iOperation == EOpMMCRemovalListingTriggerForStartupProcess)
|
|
654 |
{
|
|
655 |
validity = TLbtTriggerDynamicInfo::EInvalid;
|
|
656 |
iCleanupHandler.AddTriggersForCleanupL( triggerIds );
|
|
657 |
}
|
|
658 |
else
|
|
659 |
{
|
|
660 |
validity = TLbtTriggerDynamicInfo::EValid;
|
|
661 |
iCleanupHandler.RemoveTriggersFromCleanupL( triggerIds );
|
|
662 |
}
|
|
663 |
|
|
664 |
// update validity of the triggers
|
|
665 |
iContainer.UpdateTriggersValidity( validity,
|
|
666 |
triggerIds,
|
|
667 |
iOpId,
|
|
668 |
iStatus );
|
|
669 |
SetActive();
|
|
670 |
iOperation = EOpRequestValidityChange;
|
|
671 |
triggerIds.Close();
|
|
672 |
iTriggerEntries.ResetAndDestroy();
|
|
673 |
}
|
|
674 |
else
|
|
675 |
{
|
|
676 |
// Listing is not successful. Hence dont do anything
|
|
677 |
iOperation = EOpNone;
|
|
678 |
iTriggerEntries.ResetAndDestroy();
|
|
679 |
iAppList.Reset();
|
|
680 |
}
|
|
681 |
break;
|
|
682 |
}
|
|
683 |
case EOpRequestValidityChange:
|
|
684 |
{
|
|
685 |
// Here the observer is set to the get the information pertaining
|
|
686 |
// triggers that were changed to invalid
|
|
687 |
TLbtTriggerEventMask eventMask = 0;
|
|
688 |
eventMask|= CLbtContainer::ELbtConTriggerValidityFieldChanged;
|
|
689 |
iContainer.SetChangeObserver( this,eventMask );
|
|
690 |
break;
|
|
691 |
}
|
|
692 |
default:
|
|
693 |
{
|
|
694 |
// Operation complete
|
|
695 |
iTriggerEntries.ResetAndDestroy();
|
|
696 |
iAppList.Close();
|
|
697 |
iOperation = EOpNone;
|
|
698 |
break;
|
|
699 |
}
|
|
700 |
}
|
|
701 |
}
|
|
702 |
|
|
703 |
// ---------------------------------------------------------------------------
|
|
704 |
// CLbtAppChangeHandler::RunError
|
|
705 |
// ---------------------------------------------------------------------------
|
|
706 |
//
|
|
707 |
TInt CLbtAppChangeHandler::RunError(TInt aError)
|
|
708 |
{
|
|
709 |
FUNC_ENTER("CLbtAppChangeHandler::RunError");
|
|
710 |
iTriggerEntries.ResetAndDestroy();
|
|
711 |
iAppList.Reset();
|
|
712 |
ERROR("CLbtAppChangeHandler::RunError:%d", aError)
|
|
713 |
return KErrNone;
|
|
714 |
}
|
|
715 |
|
|
716 |
|
|
717 |
// ---------------------------------------------------------------------------
|
|
718 |
// CLbtAppChangeHandler::DoCancel
|
|
719 |
// ---------------------------------------------------------------------------
|
|
720 |
//
|
|
721 |
void CLbtAppChangeHandler::DoCancel()
|
|
722 |
{
|
|
723 |
FUNC_ENTER("CLbtAppChangeHandler::DoCancel");
|
|
724 |
if(IsActive())
|
|
725 |
{
|
|
726 |
switch(iOperation)
|
|
727 |
{
|
|
728 |
case EOpRegiseteredForInitialListPoplulation:
|
|
729 |
{
|
|
730 |
iAppArcSession.CancelListPopulationCompleteObserver();
|
|
731 |
break;
|
|
732 |
}
|
|
733 |
default:
|
|
734 |
{
|
|
735 |
iContainer.CancelAsyncOperation(iOpId);
|
|
736 |
break;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
}
|
|
740 |
}
|
|
741 |
|
|
742 |
// ---------------------------------------------------------------------------
|
|
743 |
// CLbtAppChangeHandler::HandleApplicationUninstallationL
|
|
744 |
// ---------------------------------------------------------------------------
|
|
745 |
//
|
|
746 |
void CLbtAppChangeHandler::HandleApplicationUninstallationL( )
|
|
747 |
{
|
|
748 |
FUNC_ENTER("CLbtAppChangeHandler::HandleApplicationUninstallationL");
|
|
749 |
// Since the application has been un-installed all the triggers that belong
|
|
750 |
// to the application has to be deleted
|
|
751 |
CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
|
|
752 |
CleanupStack::PushL(containerFilter);
|
|
753 |
|
|
754 |
for(TInt i=0;i<iAppList.Count();++i)
|
|
755 |
{
|
|
756 |
containerFilter->AddOwnerSidInFilterL(iAppList[i].iUid);
|
|
757 |
}
|
|
758 |
|
|
759 |
CLbtTriggerFilterByAttribute* filterByAttribute =
|
|
760 |
CLbtTriggerFilterByAttribute::NewL();
|
|
761 |
CleanupStack::PushL(filterByAttribute);
|
|
762 |
filterByAttribute->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
|
|
763 |
|
|
764 |
CLbtContainerUpdateFilter* updateFilter = CLbtContainerUpdateFilter::NewL(filterByAttribute ,containerFilter);
|
|
765 |
|
|
766 |
iContainer.DeleteTriggers(updateFilter, iOpId, iStatus);
|
|
767 |
SetActive();
|
|
768 |
iOperation = EOpRemovalTriggerDeletion;
|
|
769 |
CleanupStack::Pop(2); //filterByAttribute and containerFilter. Container takes ownership
|
|
770 |
}
|
|
771 |
|
|
772 |
// ---------------------------------------------------------------------------
|
|
773 |
// Default Constructor
|
|
774 |
// ---------------------------------------------------------------------------
|
|
775 |
//
|
|
776 |
CLbtAppChangeHandler::CLbtAppChangeHandler(CLbtContainer& aContainer, CLbtCleanupHandler& aCleanupHandler,
|
|
777 |
MLbtServerLogicTriggerChangeObserver& aTriggerChangeObserver):
|
|
778 |
CActive(EPriorityStandard),
|
|
779 |
iContainer(aContainer),
|
|
780 |
iCleanupHandler(aCleanupHandler),
|
|
781 |
iTriggerChangeObserver(aTriggerChangeObserver)
|
|
782 |
{
|
|
783 |
CActiveScheduler::Add(this);
|
|
784 |
}
|
|
785 |
|
|
786 |
// ---------------------------------------------------------------------------
|
|
787 |
// CLbtAppChangeHandler::TriggerStoreChanged
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
//
|
|
790 |
void CLbtAppChangeHandler::TriggerStoreChanged( RArray<TLbtTriggerId>& aTriggerIds,
|
|
791 |
TLbtTriggerEventMask aEventMask,
|
|
792 |
TLbtContainerChangedAreaType /*aAreaType*/,
|
|
793 |
RArray<TUid>& aManagerUids )
|
|
794 |
{
|
|
795 |
// Remove observer
|
|
796 |
iContainer.RemoveObserver( this );
|
|
797 |
iTriggerChangeObserver.HandleTriggersChange( aTriggerIds,aManagerUids,aEventMask );
|
|
798 |
}
|
|
799 |
|
|
800 |
// ---------------------------------------------------------------------------
|
|
801 |
// Default Destructor
|
|
802 |
// ---------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
CLbtAppChangeHandler::~CLbtAppChangeHandler()
|
|
805 |
{
|
|
806 |
FUNC_ENTER("CLbtAppChangeHandler::~CLbtAppChangeHandler");
|
|
807 |
if( IsActive() )
|
|
808 |
{
|
|
809 |
Cancel();
|
|
810 |
iContainer.RemoveObserver( this );
|
|
811 |
}
|
|
812 |
iAppArcSession.Close();
|
|
813 |
delete iAppListNotifier;
|
|
814 |
iCurrentInstalledApps.Close();
|
|
815 |
iTriggerEntries.ResetAndDestroy();
|
|
816 |
iAppList.Close();
|
|
817 |
}
|
|
818 |
// end of file
|
|
819 |
|