|
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: Base class implementation for items displayed in AppMngr2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2infobase.h" // CAppMngr2InfoBase |
|
20 #include "appmngr2runtime.h" // CAppMngr2Runtime |
|
21 #include "appmngr2common.hrh" // Default icon indexes |
|
22 #include <appmngr2.rsg> // Resource IDs |
|
23 #include <AknUtils.h> // DisplayTextLanguageSpecificNumberConversion |
|
24 #include <StringLoader.h> // StringLoader |
|
25 #include <barsread.h> // TResourceReader |
|
26 #include <e32math.h> // Math::Round |
|
27 |
|
28 const TUint KKiloByte = KKilo; |
|
29 const TUint KMegaByte = KKilo*KKiloByte; |
|
30 const TUint KGigaByte = KKilo*KMegaByte; |
|
31 const TInt KDecimalPlaces = 0; |
|
32 |
|
33 |
|
34 // ======== LOCAL FUNCTIONS ========= |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // DivideAndReturnRoundedInt() |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 TInt DivideAndReturnRoundedInt( TInt64 aDivident, TUint aDivisor ) |
|
41 { |
|
42 // Ignored possible math errors returned by Math::Round() and Math::Int(). |
|
43 TReal rounded = 0; |
|
44 Math::Round( rounded, I64REAL( aDivident ) / aDivisor, KDecimalPlaces ); |
|
45 if( rounded < 1 ) |
|
46 { |
|
47 rounded = 1; |
|
48 } |
|
49 TInt32 final = 0; |
|
50 Math::Int( final, rounded ); |
|
51 return final; |
|
52 } |
|
53 |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CAppMngr2InfoBase::ConstructL() |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CAppMngr2InfoBase::ConstructL() |
|
62 { |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CAppMngr2InfoBase::~CAppMngr2InfoBase() |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CAppMngr2InfoBase::~CAppMngr2InfoBase() |
|
70 { |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CAppMngr2InfoBase::Runtime() |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C CAppMngr2Runtime& CAppMngr2InfoBase::Runtime() const |
|
78 { |
|
79 return iRuntime; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CAppMngr2InfoBase::SpecificIconL() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C CGulIcon* CAppMngr2InfoBase::SpecificIconL() const |
|
87 { |
|
88 User::Leave( KErrNotSupported ); // should not get here |
|
89 return NULL; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CAppMngr2InfoBase::IndicatorIconIndex() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C TInt CAppMngr2InfoBase::IndicatorIconIndex() const |
|
97 { |
|
98 if( iLocation == EAppMngr2LocationMemoryCard ) |
|
99 { |
|
100 return EAppMngr2IconQgnIndiAmInstMmcAdd; |
|
101 } |
|
102 if( iLocation == EAppMngr2LocationMassStorage ) |
|
103 { |
|
104 return EAppMngr2IconQgnIndiFmgrMsAdd; |
|
105 } |
|
106 return EAppMngr2NoIndicatorIcon; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CAppMngr2InfoBase::SpecificIndicatorIconL() |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C CGulIcon* CAppMngr2InfoBase::SpecificIndicatorIconL() const |
|
114 { |
|
115 User::Leave( KErrNotSupported ); // should not get here |
|
116 return NULL; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CAppMngr2InfoBase::IsShowOnTop() |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C TBool CAppMngr2InfoBase::IsShowOnTop() const |
|
124 { |
|
125 return iShowOnTop; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CAppMngr2InfoBase::GetMenuItemsL() |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C void CAppMngr2InfoBase::GetMenuItemsL( |
|
133 RPointerArray<CEikMenuPaneItem::SData>& /*aMenuCmds*/ ) |
|
134 { |
|
135 // no item specific menu items by default |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CAppMngr2InfoBase::SupportsGenericCmd() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C TBool CAppMngr2InfoBase::SupportsGenericCommand( TInt /*aCmdId*/ ) |
|
144 { |
|
145 return EFalse; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CAppMngr2InfoBase::GetMiddleSoftkeyCommandL() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C void CAppMngr2InfoBase::GetMiddleSoftkeyCommandL( |
|
153 TInt& /*aResourceId*/, TInt& /*aCommandId*/ ) |
|
154 { |
|
155 // no item specific middle softkey command by default |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CAppMngr2InfoBase::SizeStringWithUnitsL() |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C HBufC* CAppMngr2InfoBase::SizeStringWithUnitsL( TInt64 aSizeInBytes ) |
|
163 { |
|
164 HBufC* dispString = NULL; |
|
165 if( aSizeInBytes <= KMegaByte ) |
|
166 { |
|
167 TInt kiloBytes = DivideAndReturnRoundedInt( aSizeInBytes, KKiloByte ); |
|
168 dispString = StringLoader::LoadLC( R_SWINS_UNIT_KILOBYTE, kiloBytes ); |
|
169 } |
|
170 else if( aSizeInBytes <= KGigaByte ) |
|
171 { |
|
172 TInt megaBytes = DivideAndReturnRoundedInt( aSizeInBytes, KMegaByte ); |
|
173 dispString = StringLoader::LoadLC( R_SWINS_UNIT_MEGABYTE, megaBytes ); |
|
174 } |
|
175 else // aSizeInBytes > KGigaByte |
|
176 { |
|
177 TInt gigaBytes = DivideAndReturnRoundedInt( aSizeInBytes, KGigaByte ); |
|
178 dispString = StringLoader::LoadLC( R_SWINS_UNIT_GIGABYTE, gigaBytes ); |
|
179 } |
|
180 |
|
181 TPtr ptr = dispString->Des(); |
|
182 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
183 |
|
184 CleanupStack::Pop( dispString ); |
|
185 return dispString; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CAppMngr2InfoBase::ReadMenuItemDataFromResourceL() |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C void CAppMngr2InfoBase::ReadMenuItemDataFromResourceL( |
|
193 TInt aResourceId, CEikMenuPaneItem::SData& aMenuItemData ) |
|
194 { |
|
195 TResourceReader reader; |
|
196 iRuntime.EikonEnv().CreateResourceReaderLC( reader, aResourceId ); |
|
197 |
|
198 aMenuItemData.iCommandId = reader.ReadInt32(); |
|
199 aMenuItemData.iCascadeId = reader.ReadInt32(); |
|
200 aMenuItemData.iFlags = reader.ReadInt32(); |
|
201 aMenuItemData.iText.Copy( reader.ReadTPtrC() ); |
|
202 aMenuItemData.iExtraText = reader.ReadTPtrC(); |
|
203 // bmpfile, bmpid, bmpmask, and extension ignored |
|
204 |
|
205 CleanupStack::PopAndDestroy(); // resource reader |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CAppMngr2InfoBase::Location() |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C TAppMngr2Location CAppMngr2InfoBase::Location() const |
|
213 { |
|
214 return iLocation; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CAppMngr2InfoBase::LocationDrive() |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C TDriveUnit CAppMngr2InfoBase::LocationDrive() const |
|
222 { |
|
223 return iLocationDrive; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CAppMngr2InfoBase::CAppMngr2InfoBase() |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 CAppMngr2InfoBase::CAppMngr2InfoBase( CAppMngr2Runtime& aRuntime, |
|
231 RFs& aFsSession ) : iFs( aFsSession ), iRuntime( aRuntime ) |
|
232 { |
|
233 } |
|
234 |