1 /* |
|
2 * Copyright (c) 2008 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: WidgetAppInfo implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2widgetappinfo.h" // CAppMngr2WidgetAppInfo |
|
20 #include "appmngr2widgetruntime.h" // KAppMngr2WidgetUid |
|
21 #include "appmngr2widgetinfoiterator.h" // CAppMngr2WidgetInfoIterator |
|
22 #include "appmngr2widget.hrh" // Widget command IDs |
|
23 #include <WidgetRegistryData.h> // CWidgetInfo |
|
24 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
|
25 |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CAppMngr2WidgetAppInfo::NewL() |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CAppMngr2WidgetAppInfo* CAppMngr2WidgetAppInfo::NewL( |
|
34 CAppMngr2Runtime& aRuntime, const CWidgetInfo& aWidget, RFs& aFsSession ) |
|
35 { |
|
36 CAppMngr2WidgetAppInfo* self = new (ELeave) CAppMngr2WidgetAppInfo( aRuntime, aFsSession ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL( aWidget ); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CAppMngr2WidgetAppInfo::~CAppMngr2WidgetAppInfo() |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CAppMngr2WidgetAppInfo::~CAppMngr2WidgetAppInfo() |
|
48 { |
|
49 CancelCommand(); |
|
50 delete iName; |
|
51 delete iDetails; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CAppMngr2WidgetAppInfo::IconIndex() |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 TInt CAppMngr2WidgetAppInfo::IconIndex() const |
|
59 { |
|
60 return 0; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CAppMngr2WidgetAppInfo::Name() |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 const TDesC& CAppMngr2WidgetAppInfo::Name() const |
|
68 { |
|
69 if( iName ) |
|
70 { |
|
71 return *iName; |
|
72 } |
|
73 return KNullDesC; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CAppMngr2WidgetAppInfo::Details() |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 const TDesC& CAppMngr2WidgetAppInfo::Details() const |
|
81 { |
|
82 if( iDetails ) |
|
83 { |
|
84 return *iDetails; |
|
85 } |
|
86 return KNullDesC; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAppMngr2WidgetAppInfo::SupportsGenericCommand() |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 TBool CAppMngr2WidgetAppInfo::SupportsGenericCommand( TInt /*aCmdId*/ ) |
|
94 { |
|
95 return ETrue; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CAppMngr2WidgetAppInfo::HandleCommandL() |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CAppMngr2WidgetAppInfo::HandleCommandL( TInt aCommandId, TRequestStatus& aStatus ) |
|
103 { |
|
104 switch( aCommandId ) |
|
105 { |
|
106 case EAppMngr2CmdViewDetails: |
|
107 ShowDetailsL(); |
|
108 break; |
|
109 |
|
110 case EAppMngr2CmdUninstall: |
|
111 if( !iSWInstLauncher ) |
|
112 { |
|
113 SwiUI::RSWInstLauncher* swInstLauncher = new (ELeave) SwiUI::RSWInstLauncher; |
|
114 CleanupStack::PushL( swInstLauncher ); |
|
115 User::LeaveIfError( swInstLauncher->Connect() ); |
|
116 CleanupStack::Pop( swInstLauncher ); |
|
117 iSWInstLauncher = swInstLauncher; |
|
118 } |
|
119 iSWInstLauncher->Uninstall( aStatus, iWidgetUid, KDataTypeWidget ); |
|
120 return; // async operation started |
|
121 |
|
122 default: |
|
123 break; |
|
124 } |
|
125 |
|
126 // sync operation done, complete aStatus |
|
127 TRequestStatus* statusPtr = &aStatus; |
|
128 User::RequestComplete( statusPtr, KErrNone ); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CAppMngr2WidgetAppInfo::HandleCommandResultL() |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CAppMngr2WidgetAppInfo::HandleCommandResultL( TInt aStatus ) |
|
136 { |
|
137 if( iSWInstLauncher ) |
|
138 { |
|
139 iSWInstLauncher->Close(); |
|
140 delete iSWInstLauncher; |
|
141 iSWInstLauncher = NULL; |
|
142 } |
|
143 if( aStatus != SwiUI::KSWInstErrUserCancel && aStatus != KErrCancel ) |
|
144 { |
|
145 User::LeaveIfError( aStatus ); |
|
146 } |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CAppMngr2WidgetAppInfo::CancelCommand() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CAppMngr2WidgetAppInfo::CancelCommand() |
|
154 { |
|
155 if( iSWInstLauncher ) |
|
156 { |
|
157 iSWInstLauncher->CancelAsyncRequest( SwiUI::ERequestUninstall ); |
|
158 iSWInstLauncher->Close(); |
|
159 delete iSWInstLauncher; |
|
160 iSWInstLauncher = NULL; |
|
161 } |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CAppMngr2WidgetAppInfo::CAppMngr2WidgetAppInfo() |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 CAppMngr2WidgetAppInfo::CAppMngr2WidgetAppInfo( CAppMngr2Runtime& aRuntime, |
|
169 RFs& aFsSession ) : CAppMngr2AppInfo( aRuntime, aFsSession ) |
|
170 { |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CAppMngr2WidgetAppInfo::ConstructL() |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CAppMngr2WidgetAppInfo::ConstructL( const CWidgetInfo& aWidget ) |
|
178 { |
|
179 CAppMngr2AppInfo::ConstructL(); |
|
180 |
|
181 iWidgetUid = aWidget.iUid; |
|
182 iName = aWidget.iBundleName->AllocL(); |
|
183 iDetails = SizeStringWithUnitsL( aWidget.iFileSize ); |
|
184 |
|
185 iLocationDrive = TDriveUnit( *aWidget.iDriveName ); |
|
186 iLocation = TAppMngr2DriveUtils::LocationFromDriveL( iLocationDrive, iFs ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CAppMngr2WidgetAppInfo::ShowDetailsL() |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CAppMngr2WidgetAppInfo::ShowDetailsL() |
|
194 { |
|
195 CAppMngr2WidgetInfoIterator* iterator = CAppMngr2WidgetInfoIterator::NewL( |
|
196 *this, EAppMngr2StatusInstalled ); |
|
197 CleanupStack::PushL( iterator ); |
|
198 SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL(); |
|
199 details->ExecuteLD( *iterator ); |
|
200 CleanupStack::PopAndDestroy( iterator ); |
|
201 } |
|
202 |
|