|
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: CMSFillBrowseContainer class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mediaservant.rsg> |
|
20 #include <StringLoader.h> |
|
21 #include <utf.h> |
|
22 #include <e32math.h> |
|
23 |
|
24 #include "mserv.hlp.hrh" |
|
25 #include "cmfillrule.h" |
|
26 #include "msfillbrowsecontainer.h" |
|
27 #include "msfillbrowseview.h" |
|
28 #include "msappui.h" |
|
29 #include "msengine.h" |
|
30 #include "mediaservantuid.h" |
|
31 |
|
32 #include "msdebug.h" |
|
33 |
|
34 // -------------------------------------------------------------------------- |
|
35 // CMSFillBrowseContainer::CMSFillBrowseContainer() |
|
36 // -------------------------------------------------------------------------- |
|
37 // |
|
38 CMSFillBrowseContainer::CMSFillBrowseContainer( |
|
39 CMSAppUi& aAppUi, |
|
40 CMSFillBrowseView& aView ) |
|
41 { |
|
42 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::\ |
|
43 CMSFillBrowseContainer")); |
|
44 |
|
45 iAppUi = &aAppUi; |
|
46 iView = &aView; |
|
47 iIconCount = 0; //default icon |
|
48 |
|
49 iAppUi->MSEngine()->SetObserver( this ); |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // CMSFillBrowseContainer::~CMSFillBrowseContainer() |
|
54 // -------------------------------------------------------------------------- |
|
55 // |
|
56 CMSFillBrowseContainer::~CMSFillBrowseContainer() |
|
57 { |
|
58 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::\ |
|
59 ~CMSFillBrowseContainer")); |
|
60 |
|
61 iStatusArray.Close(); |
|
62 |
|
63 delete iListBox; // Deletes listbox object. |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CMSFillBrowseContainer::RandomizeListL() |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 void CMSFillBrowseContainer::RandomizeListL() |
|
71 { |
|
72 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::RandomizeListL")); |
|
73 |
|
74 iAppUi->MSEngine()->PreProcessFillListL( iRule->Name() ); |
|
75 HBufC* naviText = StringLoader::LoadLC( R_MS_WAIT_RANDOMIZE ); |
|
76 iView->SetNavigationPaneTextL( *naviText ); |
|
77 CleanupStack::PopAndDestroy( naviText ); |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CMSFillBrowseContainer::HasListRandomRule |
|
82 // -------------------------------------------------------------------------- |
|
83 // |
|
84 TBool CMSFillBrowseContainer::HasListRandomRule() |
|
85 { |
|
86 TBool retval = EFalse; |
|
87 if ( iRule->Method() == ECMRandom ) |
|
88 { |
|
89 retval = ETrue; |
|
90 } |
|
91 return retval; |
|
92 } |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // CMSFillBrowseContainer::ReadyL() |
|
96 // engine observer callback |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 void CMSFillBrowseContainer::ReadyL( TCmService aService, TInt /*aError*/ ) |
|
100 { |
|
101 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::ReadyL")); |
|
102 |
|
103 if ( aService == ECmServicePreProcessingFilllist ) |
|
104 { |
|
105 iView->ClearCurrentNaviPaneText(); |
|
106 // read rules again |
|
107 iAppUi->FillRuleController()->UpdateArrayL(); |
|
108 |
|
109 GetBrowseDataL(); |
|
110 // Add data to listbox |
|
111 UpdateListBoxDataL(); |
|
112 } |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------------- |
|
116 // CMSFillBrowseContainer::CheckIfStatusChanged() |
|
117 // Checks if status values are changed |
|
118 // -------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CMSFillBrowseContainer::CheckIfStatusChanged() |
|
121 { |
|
122 TBool status( EFalse ); |
|
123 |
|
124 TInt itemCount = iItemArray->Count(); |
|
125 |
|
126 for ( TInt i = 0; i < itemCount; i++ ) |
|
127 { |
|
128 TCmListItemStatus status1 = (*iItemArray)[i]->Status(); |
|
129 TCmListItemStatus status2 = iStatusArray[i]; |
|
130 if ( (*iItemArray)[i]->Status() != iStatusArray[i] ) |
|
131 { |
|
132 status = ETrue; |
|
133 i = itemCount; // break loop |
|
134 } |
|
135 } |
|
136 |
|
137 return status; |
|
138 } |
|
139 |
|
140 // -------------------------------------------------------------------------- |
|
141 // CMSFillBrowseContainer::SetFileStatusesL() |
|
142 // Sets file statuses |
|
143 // -------------------------------------------------------------------------- |
|
144 // |
|
145 void CMSFillBrowseContainer::SetFileStatusesL() |
|
146 { |
|
147 if ( CheckIfStatusChanged() ) |
|
148 { |
|
149 iAppUi->MSEngine()->SetFillFileStatusesL( iItemArray ); |
|
150 } |
|
151 } |
|
152 |
|
153 // -------------------------------------------------------------------------- |
|
154 // CMSFillBrowseContainer::GetBrowseDataL() |
|
155 // Gets file information from engine |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 void CMSFillBrowseContainer::GetBrowseDataL() |
|
159 { |
|
160 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::GetBrowseDataL")); |
|
161 |
|
162 CMSParameterAgent* parameterAgent = iAppUi->ParameterAgent(); |
|
163 |
|
164 TInt selected = iAppUi->ParameterAgent()->FillViewFocusIndex(); |
|
165 |
|
166 RPointerArray<CMSFillList>* fillListArray = |
|
167 iAppUi->FillRuleController()->FillListArray(); |
|
168 |
|
169 CMSFillList* fillList = (*fillListArray)[selected]; |
|
170 iRule = fillList->List(); |
|
171 // get media type |
|
172 iMediaType = iRule->MediaType(); |
|
173 // get items covered by rule |
|
174 if( iItemArray ) |
|
175 { |
|
176 iItemArray->ResetAndDestroy(); |
|
177 iItemArray->Close(); |
|
178 delete iItemArray; |
|
179 iItemArray = NULL; |
|
180 } |
|
181 iItemArray = iAppUi->MSEngine()->GetFillListItemsL( iRule->Name() ); |
|
182 // keep original statuses safe |
|
183 for ( TInt i = 0; i < iItemArray->Count(); i++ ) |
|
184 { |
|
185 iStatusArray.AppendL( (*iItemArray)[i]->Status() ); |
|
186 } |
|
187 |
|
188 // Set title pane text |
|
189 HBufC* ruleName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
190 iRule->Name() ); |
|
191 CleanupStack::PushL( ruleName ); |
|
192 iView->SetTitlePaneTextL( *ruleName ); |
|
193 CleanupStack::PopAndDestroy( ruleName ); |
|
194 |
|
195 // set navi pane text |
|
196 CreateAndSetNaviPaneTextL( fillList->ItemCount(), fillList->ListSize() ); |
|
197 } |
|
198 |
|
199 // -------------------------------------------------------------------------- |
|
200 // CMSFillBrowseContainer::CreateAndSetNaviPaneTextL() |
|
201 // -------------------------------------------------------------------------- |
|
202 // |
|
203 void CMSFillBrowseContainer::CreateAndSetNaviPaneTextL( TUint32 aCount, |
|
204 TUint32 aSize ) |
|
205 { |
|
206 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::\ |
|
207 CreateAndSetNaviPaneTextL")); |
|
208 |
|
209 // Set navi pane text |
|
210 CArrayFix<TInt>* infoArray = |
|
211 new ( ELeave ) CArrayFixFlat<TInt>(2); // only 2 numbers needed |
|
212 CleanupStack::PushL( infoArray ); |
|
213 |
|
214 HBufC* naviText = NULL; |
|
215 |
|
216 TReal size( 0 ); |
|
217 Math::Round( size, TReal( aSize ) / KMega, 0 ); |
|
218 |
|
219 |
|
220 switch ( aCount ) |
|
221 { |
|
222 case 0: // 0 items |
|
223 { |
|
224 naviText = StringLoader::LoadLC( |
|
225 R_MS_FILL_LIST_BROWSE_NAVI_0_ITEMS ); |
|
226 break; |
|
227 } |
|
228 case 1: // 1 item |
|
229 { |
|
230 naviText = StringLoader::LoadLC( |
|
231 R_MS_FILL_LIST_BROWSE_NAVI_1_ITEM, size ); |
|
232 break; |
|
233 } |
|
234 default: // many items |
|
235 { |
|
236 infoArray->AppendL( size ); |
|
237 infoArray->AppendL( aCount ); |
|
238 naviText = StringLoader::LoadLC( |
|
239 R_MS_FILL_LIST_BROWSE_NAVI_ITEMS, *infoArray ); |
|
240 // do number conversion |
|
241 TPtr ptr = naviText->Des(); |
|
242 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
243 break; |
|
244 } |
|
245 } |
|
246 |
|
247 iView->SetNavigationPaneTextL( *naviText ); |
|
248 CleanupStack::PopAndDestroy( naviText ); |
|
249 CleanupStack::PopAndDestroy( infoArray ); |
|
250 } |
|
251 |
|
252 |
|
253 // -------------------------------------------------------------------------- |
|
254 // CMSFillBrowseContainer::SetStatusOfFiles() |
|
255 // -------------------------------------------------------------------------- |
|
256 // |
|
257 void CMSFillBrowseContainer::SetStatusOfFiles( TCmListItemStatus aStatus ) |
|
258 { |
|
259 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::SetStatusOfFiles")); |
|
260 |
|
261 const CListBoxView::CSelectionIndexArray* selections = |
|
262 ListBox()->SelectionIndexes(); |
|
263 TInt count = selections->Count(); |
|
264 |
|
265 // mark used |
|
266 if ( count ) |
|
267 { |
|
268 for ( TInt index = 0; index < count; index++) |
|
269 { |
|
270 SetFileStatus( (*selections)[ index ], aStatus ); |
|
271 |
|
272 } |
|
273 } |
|
274 // set only highlighted item status |
|
275 else |
|
276 { |
|
277 SetFileStatus( ListBox()->CurrentItemIndex(), aStatus ); |
|
278 } |
|
279 |
|
280 } |
|
281 |
|
282 // -------------------------------------------------------------------------- |
|
283 // CMSFillBrowseContainer::HandleResourceChange |
|
284 // Handles layout change |
|
285 // -------------------------------------------------------------------------- |
|
286 // |
|
287 void CMSFillBrowseContainer::HandleResourceChange( TInt aType ) |
|
288 { |
|
289 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::\ |
|
290 HandleResourceChange")); |
|
291 |
|
292 |
|
293 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
294 { |
|
295 SetRect( iView->ClientRect() ); |
|
296 } |
|
297 |
|
298 CCoeControl::HandleResourceChange( aType ); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CMSFillBrowseContainer::GetHelpContext |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CMSFillBrowseContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
306 { |
|
307 LOG(_L("[MediaServant]\t CMSFillBrowseContainer::GetHelpContext")); |
|
308 |
|
309 aContext.iMajor = TUid::Uid(KMediaServantUID3); |
|
310 aContext.iContext = KMSERV_HLP_FILL_BROWSE; |
|
311 } |
|
312 |
|
313 // End of File |
|
314 |