|
1 /* |
|
2 * Copyright (c) 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 "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 * |
|
16 */ |
|
17 #include <e32base.h> |
|
18 #include <e32cons.h> |
|
19 #include <hal.h> |
|
20 #include <cinidata.h> |
|
21 |
|
22 // Epoc Includes |
|
23 #include <swi/launcher.h> |
|
24 // S60 specific headers |
|
25 #ifdef __S60__ |
|
26 #include <SWInstApi.h> |
|
27 #endif |
|
28 |
|
29 #include "TrkSwInstall.h" |
|
30 #include "TrkSwInstUIHandler.h" |
|
31 |
|
32 #define SafeDelete(x) { if (x) delete x; x = NULL; } |
|
33 |
|
34 CTrkSwInstall::CTrkSwInstall() |
|
35 { |
|
36 } |
|
37 |
|
38 TInt CTrkSwInstall::Install(const TDesC& aFileName) |
|
39 { |
|
40 #ifdef __S60__ |
|
41 TInt error = KErrNone; |
|
42 |
|
43 SwiUI::RSWInstLauncher swInstLauncher; |
|
44 |
|
45 error = swInstLauncher.Connect(); |
|
46 if (!error) |
|
47 { |
|
48 error = swInstLauncher.Install(aFileName); |
|
49 |
|
50 swInstLauncher.Close(); |
|
51 } |
|
52 |
|
53 return error; |
|
54 #else |
|
55 return KErrNotSupported; |
|
56 #endif |
|
57 } |
|
58 |
|
59 TInt CTrkSwInstall::SilentInstallL(const TDesC& aFileName, const TChar aInstallDrive) |
|
60 { |
|
61 TInt error = KErrNone; |
|
62 |
|
63 TFileName fileName(aFileName); |
|
64 |
|
65 fileName.PtrZ(); |
|
66 |
|
67 Swi::CInstallPrefs* iInstallPrefs = Swi::CInstallPrefs::NewL(); |
|
68 |
|
69 CTrkSWInstUIHandler* iUIHandler = CTrkSWInstUIHandler::NewL(aInstallDrive); |
|
70 |
|
71 error = Swi::Launcher::Install(*iUIHandler, fileName, *iInstallPrefs); |
|
72 |
|
73 if ((KErrNone == error) && (KErrNothing != iUIHandler->iErrCode)) |
|
74 error = KErrGeneral; |
|
75 |
|
76 SafeDelete(iUIHandler); |
|
77 SafeDelete(iInstallPrefs); |
|
78 |
|
79 return error; |
|
80 } |
|
81 |
|
82 TInt CTrkSwInstall::UninstallL(const TDesC& aUid) |
|
83 { |
|
84 |
|
85 TInt error = KErrNone; |
|
86 |
|
87 TLex conv(aUid); |
|
88 |
|
89 TUint32 id; |
|
90 |
|
91 error = conv.Val(id,EHex); |
|
92 |
|
93 if (error != KErrNone) |
|
94 { |
|
95 return error; |
|
96 } |
|
97 |
|
98 TUid uid = TUid::Uid(id); |
|
99 |
|
100 |
|
101 CTrkSWInstUIHandler* iUIHandler = CTrkSWInstUIHandler::NewL(); |
|
102 |
|
103 error = Swi::Launcher::Uninstall(*iUIHandler, uid); |
|
104 |
|
105 SafeDelete(iUIHandler); |
|
106 |
|
107 return error; |
|
108 } |
|
109 |