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