|
1 /* |
|
2 * Copyright (c) 2010 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <usif/usifcommon.h> |
|
19 #include <usif/scr/screntries.h> |
|
20 |
|
21 #include "t_cainstaller.h" |
|
22 |
|
23 using namespace Usif; |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // T_CaInstaller::~T_CaInstaller |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 T_CaInstaller::~T_CaInstaller() |
|
32 { |
|
33 Cancel(); |
|
34 iFs.Close(); |
|
35 delete iArguments; |
|
36 delete iResults; |
|
37 iInstaller.Close(); |
|
38 iSoftwareRegistry.Close(); |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // T_CaInstaller::NewL |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 T_CaInstaller *T_CaInstaller::NewL(TInt aPriority) |
|
46 { |
|
47 T_CaInstaller *self = new (ELeave) T_CaInstaller( |
|
48 aPriority ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // T_CaInstaller::T_CaInstaller |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 T_CaInstaller::T_CaInstaller( TInt aPriority ) : |
|
60 CActive( aPriority ), iInstaller() |
|
61 { |
|
62 CActiveScheduler::Add( this ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // T_CaInstaller::ConstructL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void T_CaInstaller::ConstructL() |
|
70 { |
|
71 User::LeaveIfError( iInstaller.Connect() ); |
|
72 User::LeaveIfError( iSoftwareRegistry.Connect() ); |
|
73 User::LeaveIfError( iFs.Connect() ); |
|
74 |
|
75 iArguments = COpaqueNamedParams::NewL(); |
|
76 iResults = COpaqueNamedParams::NewL(); |
|
77 |
|
78 iArguments->AddIntL( KSifInParam_InstallInactive, ETrue ); |
|
79 iArguments->AddIntL( KSifInParam_InstallSilently, ETrue ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // T_CaInstallOperation::ConstructL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void T_CaInstaller::InstallL( const TDesC& aFileName ) |
|
87 { |
|
88 if (IsActive()) |
|
89 { |
|
90 User::Leave(KErrInUse); |
|
91 } |
|
92 |
|
93 iInstaller.Install( aFileName, *iArguments, *iResults, iStatus ); |
|
94 |
|
95 SetActive(); |
|
96 |
|
97 iSchedulerWait.Start(); |
|
98 |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // T_CaInstaller::UnistallL |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void T_CaInstaller::UninstallL(TComponentId aComponentId) |
|
106 { |
|
107 if (IsActive()) |
|
108 { |
|
109 User::Leave( KErrInUse ); |
|
110 } |
|
111 |
|
112 if (aComponentId >= 1) |
|
113 { |
|
114 iInstaller.Uninstall( aComponentId, *iArguments, *iResults, iStatus ); |
|
115 |
|
116 SetActive(); |
|
117 |
|
118 iSchedulerWait.Start(); |
|
119 } |
|
120 |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // T_CaInstaller::UnistallL |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void T_CaInstaller::UninstallL(const TDesC& aFileName) |
|
128 { |
|
129 UninstallL( GetComponentIdL(aFileName) ); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // T_CaInstaller::UnistallL |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void T_CaInstaller::UninstallL( TUint32 aUid ) |
|
137 { |
|
138 UninstallL( GetComponentIdL( aUid ) ); |
|
139 } |
|
140 |
|
141 TComponentId T_CaInstaller::GetComponentIdL( const TDesC& aFileName ) |
|
142 { |
|
143 CComponentFilter* const fileNameFilter = CComponentFilter::NewLC(); |
|
144 fileNameFilter->SetFileL( aFileName ); |
|
145 |
|
146 RArray<TComponentId> componentIds; |
|
147 CleanupClosePushL( componentIds ); |
|
148 iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter ); |
|
149 |
|
150 TComponentId componentId( 0 ); |
|
151 |
|
152 if ( componentIds.Count() == 1 ) |
|
153 { |
|
154 componentId = componentIds[0]; |
|
155 } |
|
156 else if ( componentIds.Count() >= 2 ) |
|
157 { |
|
158 User::Leave( KErrGeneral ); |
|
159 } |
|
160 |
|
161 CleanupStack::PopAndDestroy( &componentIds ); |
|
162 CleanupStack::PopAndDestroy( fileNameFilter ); |
|
163 |
|
164 return componentId; |
|
165 } |
|
166 |
|
167 TComponentId T_CaInstaller::GetComponentIdForAppIdL( const TDesC& aAppId ) |
|
168 { |
|
169 CComponentFilter* const appIdFilter = CComponentFilter::NewLC(); |
|
170 appIdFilter->AddPropertyL( _L("AppId"), aAppId ); |
|
171 |
|
172 RArray<TComponentId> componentIds; |
|
173 CleanupClosePushL( componentIds ); |
|
174 iSoftwareRegistry.GetComponentIdsL( componentIds, appIdFilter ); |
|
175 |
|
176 TComponentId componentId( 0 ); |
|
177 |
|
178 if ( componentIds.Count() == 1 ) |
|
179 { |
|
180 componentId = componentIds[0]; |
|
181 } |
|
182 else if ( componentIds.Count() >= 2 ) |
|
183 { |
|
184 User::Leave( KErrGeneral ); |
|
185 } |
|
186 |
|
187 CleanupStack::PopAndDestroy( &componentIds ); |
|
188 CleanupStack::PopAndDestroy( appIdFilter ); |
|
189 |
|
190 return componentId; |
|
191 } |
|
192 |
|
193 |
|
194 TComponentId T_CaInstaller::GetComponentIdL( TInt32 aUid ) |
|
195 { |
|
196 TUid uid; |
|
197 TComponentId componentId = iSoftwareRegistry.GetComponentIdForAppL( |
|
198 uid.Uid( aUid ) ); |
|
199 |
|
200 if ( componentId <= 0 ) |
|
201 { |
|
202 User::Leave( KErrGeneral ); |
|
203 } |
|
204 return componentId; |
|
205 } |
|
206 // --------------------------------------------------------------------------- |
|
207 // T_CaInstaller::RunL |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void T_CaInstaller::RunL() |
|
211 { |
|
212 iSchedulerWait.AsyncStop(); |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // T_CaInstaller::DoCancel |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void T_CaInstaller::DoCancel() |
|
220 { |
|
221 iInstaller.CancelOperation(); |
|
222 iSchedulerWait.AsyncStop(); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // T_CaInstaller::RunError |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 TInt T_CaInstaller::RunError(TInt /* aError */) |
|
230 { |
|
231 return KErrNone; |
|
232 } |