|
1 /* |
|
2 * Copyright (c) 2007-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 * TESTAPPWITHRC.CPP |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <e32uid.h> |
|
22 #include <e32base.h> |
|
23 #include <e32test.h> |
|
24 #include <swi/pkgremover.h> |
|
25 #include "cleanuputils.h" |
|
26 |
|
27 using namespace Swi; |
|
28 |
|
29 _LIT(KTxtEPOC32EX," mainL failed"); |
|
30 |
|
31 LOCAL_C void mainL(); |
|
32 TInt E32Main() // main function called by E32 |
|
33 { |
|
34 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
35 TRAPD(error,mainL()); // more initialization, then do example |
|
36 __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error)); |
|
37 delete cleanup; // destroy clean-up stack |
|
38 return 0; // and return |
|
39 } |
|
40 |
|
41 LOCAL_C void mainL() // initialize and call example code under cleanup stack |
|
42 { |
|
43 RPointerArray<CUninstalledPackageEntry> uninstalledPkgEntry; |
|
44 CleanupResetAndDestroy<RPointerArray<CUninstalledPackageEntry> >::PushL(uninstalledPkgEntry); |
|
45 |
|
46 TDriveNumber drive = EDriveX; |
|
47 TRAPD(err,UninstalledSisPackages::ListL(drive, uninstalledPkgEntry)); |
|
48 if(err==KErrPermissionDenied) |
|
49 { |
|
50 User::LeaveIfError(KErrPermissionDenied); |
|
51 } |
|
52 for(TInt loopCnt=0;loopCnt<uninstalledPkgEntry.Count();loopCnt++) |
|
53 { |
|
54 CUninstalledPackageEntry* uninstallPkg= uninstalledPkgEntry[loopCnt]; |
|
55 TRAPD(err,UninstalledSisPackages::RemoveL(*uninstallPkg)); |
|
56 if(err==KErrPermissionDenied) |
|
57 { |
|
58 User::LeaveIfError(KErrPermissionDenied); |
|
59 } |
|
60 } |
|
61 |
|
62 CleanupStack::PopAndDestroy(&uninstalledPkgEntry); |
|
63 } |
|
64 |