22 #include <eikappui.h> |
22 #include <eikappui.h> |
23 #include <vwsdef.h> |
23 #include <vwsdef.h> |
24 #include <AknDef.h> |
24 #include <AknDef.h> |
25 #include <AknTaskList.h> |
25 #include <AknTaskList.h> |
26 |
26 |
|
27 #include <usif/usifcommon.h> |
|
28 #include <usif/scr/scr.h> |
|
29 |
27 #include "caapphandler.h" |
30 #include "caapphandler.h" |
28 #include "cainnerentry.h" |
31 #include "cainnerentry.h" |
29 #include "cauninstalloperation.h" |
32 #include "cauninstalloperation.h" |
30 #include"catasklist.h" |
33 #include "causifuninstalloperation.h" |
|
34 #include "catasklist.h" |
31 |
35 |
32 #include "cautils.h" |
36 #include "cautils.h" |
33 #include "cadef.h" |
37 #include "cadef.h" |
34 |
38 |
35 // ======== MEMBER FUNCTIONS ======== |
39 // ======== MEMBER FUNCTIONS ======== |
|
40 using namespace Usif; |
36 |
41 |
37 // --------------------------------------------------------------------------- |
42 // --------------------------------------------------------------------------- |
38 // |
43 // |
39 // --------------------------------------------------------------------------- |
44 // --------------------------------------------------------------------------- |
40 // |
45 // |
41 CCaAppHandler::~CCaAppHandler() |
46 CCaAppHandler::~CCaAppHandler() |
42 { |
47 { |
43 delete iUninstallOperation; |
48 delete iUninstallOperation; |
|
49 delete iUsifUninstallOperation; |
44 } |
50 } |
45 |
51 |
46 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
47 // |
53 // |
48 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
86 // --------------------------------------------------------------------------- |
80 // |
87 // |
81 void CCaAppHandler::HandleCommandL( |
88 void CCaAppHandler::HandleCommandL( |
82 CCaInnerEntry &aEntry, const TDesC8 &aCommand ) |
89 CCaInnerEntry &aEntry, const TDesC8 &aCommand ) |
83 { |
90 { |
|
91 |
84 if( aCommand == KCaCmdOpen() |
92 if( aCommand == KCaCmdOpen() |
85 && aEntry.GetEntryTypeName() == KCaTypeApp() ) |
93 && aEntry.GetEntryTypeName() == KCaTypeApp() ) |
86 { |
94 { |
87 TInt viewId(-1); |
95 TInt viewId(-1); |
88 TBuf<KCaMaxAttrValueLen> viewIdValue; |
96 TPtrC viewIdValue; |
89 if( aEntry.FindAttribute( KCaAttrView(), viewIdValue ) ) |
97 if( aEntry.FindAttribute( KCaAttrView(), viewIdValue ) ) |
90 { |
98 { |
91 if( MenuUtils::GetTUint( viewIdValue, (TUint &) viewId ) |
99 if( MenuUtils::GetTUint( viewIdValue, (TUint &) viewId ) |
92 != KErrNone ) |
100 != KErrNone ) |
93 { |
101 { |
100 else if ( aCommand == KCaCmdClose() |
108 else if ( aCommand == KCaCmdClose() |
101 && aEntry.GetEntryTypeName() == KCaTypeApp() ) |
109 && aEntry.GetEntryTypeName() == KCaTypeApp() ) |
102 { |
110 { |
103 CloseApplicationL( aEntry ); |
111 CloseApplicationL( aEntry ); |
104 } |
112 } |
105 else if ( aCommand == KCaCmdRemove() |
113 else if ( aCommand == KCaCmdRemove() ) |
106 && ( aEntry.GetEntryTypeName() == KCaTypeApp() |
114 { |
107 || aEntry.GetEntryTypeName() == KCaTypeWidget() ) ) |
115 HandleRemoveL(aEntry); |
108 { |
|
109 if ( iUninstallOperation && iUninstallOperation->IsActive() ) |
|
110 { |
|
111 User::Leave( KErrInUse ); |
|
112 } |
|
113 delete iUninstallOperation; |
|
114 iUninstallOperation = NULL; |
|
115 iUninstallOperation = CCaUninstallOperation::NewL( aEntry ); |
|
116 } |
116 } |
117 else |
117 else |
118 { |
118 { |
119 User::Leave( KErrNotSupported ); |
119 User::Leave( KErrNotSupported ); |
120 } |
120 } |
147 { |
147 { |
148 task.BringToForeground(); |
148 task.BringToForeground(); |
149 } |
149 } |
150 else |
150 else |
151 { |
151 { |
152 TApaAppInfo appInfo; |
152 // TApaAppInfo size is greater then 1024 bytes |
|
153 // so its instances should not be created on the stack. |
|
154 TApaAppInfo* appInfo = new( ELeave ) TApaAppInfo; |
|
155 CleanupStack::PushL( appInfo ); |
153 TApaAppCapabilityBuf capabilityBuf; |
156 TApaAppCapabilityBuf capabilityBuf; |
154 RApaLsSession appArcSession; |
157 RApaLsSession appArcSession; |
155 User::LeaveIfError( appArcSession.Connect() ); |
158 User::LeaveIfError( appArcSession.Connect() ); |
156 CleanupClosePushL<RApaLsSession>( appArcSession ); |
159 CleanupClosePushL<RApaLsSession>( appArcSession ); |
157 |
160 |
158 User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) ); |
161 User::LeaveIfError( appArcSession.GetAppInfo( *appInfo, aUid ) ); |
159 User::LeaveIfError( appArcSession.GetAppCapability( |
162 User::LeaveIfError( appArcSession.GetAppCapability( |
160 capabilityBuf, aUid ) ); |
163 capabilityBuf, aUid ) ); |
161 |
164 |
162 TApaAppCapability &caps = capabilityBuf(); |
165 TApaAppCapability &caps = capabilityBuf(); |
163 TFileName appName = appInfo.iFullName; |
|
164 CApaCommandLine *cmdLine = CApaCommandLine::NewLC(); |
166 CApaCommandLine *cmdLine = CApaCommandLine::NewLC(); |
165 cmdLine->SetExecutableNameL( appName ); |
167 cmdLine->SetExecutableNameL( appInfo->iFullName ); |
166 |
168 |
167 if( caps.iLaunchInBackground ) |
169 if( caps.iLaunchInBackground ) |
168 { |
170 { |
169 cmdLine->SetCommandL( EApaCommandBackground ); |
171 cmdLine->SetCommandL( EApaCommandBackground ); |
170 } |
172 } |
216 } |
219 } |
217 |
220 |
218 CleanupStack::PopAndDestroy( &wsSession ); |
221 CleanupStack::PopAndDestroy( &wsSession ); |
219 } |
222 } |
220 |
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CCaAppHandler::HandleRemoveL( CCaInnerEntry &aEntry ) |
|
229 { |
|
230 if (!( aEntry.GetFlags() & ERemovable ) ) |
|
231 { |
|
232 User::Leave( KErrAccessDenied ); |
|
233 } |
|
234 if ( aEntry.GetEntryTypeName() == KCaTypeApp() ) |
|
235 { |
|
236 TComponentId componentId( GetComponentIdL( aEntry,KSoftwareTypeJava ) ); |
|
237 if ( componentId != KErrNotFound ) |
|
238 { |
|
239 StartUsifUninstallL( componentId ); |
|
240 } |
|
241 else |
|
242 { |
|
243 StartSwiUninstallL( aEntry ); |
|
244 } |
|
245 } |
|
246 else if ( aEntry.GetEntryTypeName() == KCaTypeWidget() ) |
|
247 { |
|
248 StartSwiUninstallL( aEntry ); |
|
249 } |
|
250 else if( aEntry.GetEntryTypeName() == KCaTypePackage() ) |
|
251 { |
|
252 TPtrC componentId; |
|
253 if ( aEntry.FindAttribute( KCaAttrComponentId, componentId ) ) |
|
254 { |
|
255 TInt32 id ; |
|
256 TLex idDesc; |
|
257 idDesc.Assign( componentId ); |
|
258 User::LeaveIfError( idDesc.Val( id ) ); |
|
259 StartUsifUninstallL( id ); |
|
260 } |
|
261 } |
|
262 else |
|
263 { |
|
264 User::Leave( KErrNotSupported ); |
|
265 } |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 TInt CCaAppHandler::GetComponentIdL( const CCaInnerEntry &aEntry, |
|
273 const TDesC& aSoftwareType ) |
|
274 { |
|
275 TInt id(KErrNotFound); |
|
276 RSoftwareComponentRegistry scr; |
|
277 CleanupClosePushL(scr); |
|
278 User::LeaveIfError(scr.Connect()); |
|
279 CComponentFilter* compFilter = CComponentFilter::NewLC(); |
|
280 compFilter->AddPropertyL(_L("Uid"), aEntry.GetUid()); |
|
281 compFilter->SetSoftwareTypeL(aSoftwareType); |
|
282 RArray<TComponentId> componentIdList; |
|
283 CleanupClosePushL(componentIdList); |
|
284 scr.GetComponentIdsL(componentIdList, compFilter); |
|
285 if (componentIdList.Count() > 0) |
|
286 { |
|
287 id = componentIdList[0]; |
|
288 } |
|
289 CleanupStack::PopAndDestroy(&componentIdList); |
|
290 CleanupStack::PopAndDestroy(compFilter); |
|
291 CleanupStack::PopAndDestroy(&scr); |
|
292 return id; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 void CCaAppHandler::StartUsifUninstallL( TInt aComponentId ) |
|
300 { |
|
301 if ( iUsifUninstallOperation && iUsifUninstallOperation->IsActive() ) |
|
302 { |
|
303 User::Leave( KErrInUse ); |
|
304 } |
|
305 delete iUsifUninstallOperation; |
|
306 iUsifUninstallOperation = NULL; |
|
307 iUsifUninstallOperation = CCaUsifUninstallOperation::NewL( aComponentId ); |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 void CCaAppHandler::StartSwiUninstallL(CCaInnerEntry &aEntry ) |
|
315 { |
|
316 if ( iUninstallOperation && iUninstallOperation->IsActive() ) |
|
317 { |
|
318 User::Leave( KErrInUse ); |
|
319 } |
|
320 delete iUninstallOperation; |
|
321 iUninstallOperation = NULL; |
|
322 iUninstallOperation = CCaUninstallOperation::NewL( aEntry ); |
|
323 } |