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: CMSStoreListView class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <mediaservant.rsg> |
|
21 #include <hlplch.h> |
|
22 #include <StringLoader.h> |
|
23 |
|
24 #include "msstorelistcontainer.h" |
|
25 #include "mediaservant.hrh" |
|
26 #include "msconstants.h" |
|
27 #include "msstorelistview.h" |
|
28 #include "msappui.h" |
|
29 #include "msengine.h" |
|
30 #include "msdebug.h" |
|
31 |
|
32 |
|
33 // -------------------------------------------------------------------------- |
|
34 // CMSStoreListView::CMSStoreListView() |
|
35 // -------------------------------------------------------------------------- |
|
36 // |
|
37 CMSStoreListView::CMSStoreListView( CMSAppUi& aAppUi ) : |
|
38 iAppUi( aAppUi ) |
|
39 { |
|
40 LOG(_L("[MediaServant]\t CMSStoreListView::CMSStoreListView")); |
|
41 } |
|
42 |
|
43 // -------------------------------------------------------------------------- |
|
44 // CMSStoreListView::ConstructL() |
|
45 // -------------------------------------------------------------------------- |
|
46 // |
|
47 void CMSStoreListView::ConstructL() |
|
48 { |
|
49 LOG(_L("[MediaServant]\t CMSStoreListView::ConstructL")); |
|
50 |
|
51 BaseConstructL( R_MS_STORE_LIST_VIEW ); |
|
52 } |
|
53 |
|
54 // -------------------------------------------------------------------------- |
|
55 // CMSStoreListView::~CMSStoreListView() |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 CMSStoreListView::~CMSStoreListView() |
|
59 { |
|
60 LOG(_L("[MediaServant]\t CMSStoreListView::~CMSStoreListView")); |
|
61 |
|
62 DoDeactivate(); |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // TUid CMSStoreListView::Id() |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 TUid CMSStoreListView::Id() const |
|
70 { |
|
71 LOG(_L("[MediaServant]\t CMSStoreListView::Id")); |
|
72 |
|
73 return KMSStoreListViewId; |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CMSStoreListView::HandleCommandL(TInt aCommand) |
|
78 // -------------------------------------------------------------------------- |
|
79 // |
|
80 void CMSStoreListView::HandleCommandL( TInt aCommand ) |
|
81 { |
|
82 LOG(_L("[MediaServant]\t CMSStoreListView::HandleCommandL")); |
|
83 |
|
84 switch (aCommand) |
|
85 { |
|
86 case EAknSoftkeyBack: |
|
87 { |
|
88 CancelAsyncOperation( &iAppUi ); |
|
89 |
|
90 // set default icon back |
|
91 iContainer->SetDefaultContextPaneIconL(); |
|
92 // update store rule for mainview redraw |
|
93 iContainer->SetServerSelectionsL(); |
|
94 iContainer->UpdateRulesToServerL(); |
|
95 // back to main view |
|
96 iAppUi.ChangeViewL( KMSStoreListViewId, KMSMainViewId ); |
|
97 break; |
|
98 } |
|
99 |
|
100 case EMSStoreCmdActivate: // fall through |
|
101 case EMSStoreCmdDeActivate: |
|
102 { |
|
103 iContainer->ToggleCurrentItemL(); |
|
104 break; |
|
105 } |
|
106 |
|
107 case EMSStoreCmdEdit: |
|
108 { |
|
109 CancelAsyncOperation( &iAppUi ); |
|
110 // update store rule for mainview redraw |
|
111 iContainer->SetServerSelectionsL(); |
|
112 iContainer->UpdateRulesToServerL(); |
|
113 |
|
114 iAppUi.ChangeViewL( KMSStoreListViewId, KMSStoreSettingsViewId ); |
|
115 break; |
|
116 } |
|
117 |
|
118 case EMSCmdBrowse: |
|
119 { |
|
120 CancelAsyncOperation( &iAppUi ); |
|
121 |
|
122 // update store rule for mainview redraw |
|
123 iContainer->SetServerSelectionsL(); |
|
124 iContainer->UpdateRulesToServerL(); |
|
125 |
|
126 // set browse target |
|
127 iAppUi.ParameterAgent()->SetBrowseTarget( EMSStoredItems ); |
|
128 iAppUi.ChangeViewL( KMSStoreListViewId, KMSBrowseViewId ); |
|
129 break; |
|
130 } |
|
131 |
|
132 case EAknCmdHelp : |
|
133 { |
|
134 TRAPD( error, HlpLauncher::LaunchHelpApplicationL( |
|
135 iEikonEnv->WsSession(), |
|
136 iEikonEnv->EikAppUi()->AppHelpContextL() )); |
|
137 if ( error != KErrNone ) |
|
138 { |
|
139 LOG(_L("[MediaServant]\t CMSStoreListView:: \ |
|
140 HandleCommandL help leaves in \ |
|
141 LaunchHelpApplication")); |
|
142 } |
|
143 break; |
|
144 } |
|
145 |
|
146 default: |
|
147 { |
|
148 CancelAsyncOperation( &iAppUi ); |
|
149 AppUi()->HandleCommandL(aCommand); |
|
150 break; |
|
151 } |
|
152 } |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 // -------------------------------------------------------------------------- |
|
158 // CMSStoreListView::DoActivateL(...) |
|
159 // -------------------------------------------------------------------------- |
|
160 // |
|
161 void CMSStoreListView::DoActivateL( |
|
162 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
163 const TDesC8& /*aCustomMessage*/) |
|
164 { |
|
165 LOG(_L("[MediaServant]\t CMSStoreListView::DoActivateL")); |
|
166 |
|
167 // Set engine observer |
|
168 iAppUi.MSEngine()->SetObserver( this ); |
|
169 // start preprosessing if returned from edit view |
|
170 if ( iAppUi.ParameterAgent()->PreviousViewId() == |
|
171 KMSStoreSettingsViewId ) |
|
172 { |
|
173 iAppUi.MSEngine()->ExecuteStorePreProcessingL(); |
|
174 HBufC* naviText = StringLoader::LoadLC( R_MS_PREPROCESSING_TEXT ); |
|
175 SetNavigationPaneTextL( *naviText ); |
|
176 CleanupStack::PopAndDestroy( naviText ); |
|
177 iPreprocessingState = ETrue; |
|
178 } |
|
179 |
|
180 |
|
181 // Set title pane text to default |
|
182 SetTitlePaneTextL( R_MS_STORE_LIST_VIEW_TITLE ); |
|
183 |
|
184 if ( !iContainer ) |
|
185 { |
|
186 iContainer = new (ELeave) CMSStoreListContainer( iAppUi, *this ); |
|
187 iContainer->ConstructL( ClientRect() ); |
|
188 iContainer->SetMopParent( this ); |
|
189 AppUi()->AddToViewStackL( *this, iContainer ); |
|
190 } |
|
191 } |
|
192 |
|
193 // -------------------------------------------------------------------------- |
|
194 // CMSStoreListView::DoDeactivate() |
|
195 // -------------------------------------------------------------------------- |
|
196 // |
|
197 void CMSStoreListView::DoDeactivate() |
|
198 { |
|
199 LOG(_L("[MediaServant]\t CMSStoreListView::DoDeactivate")); |
|
200 |
|
201 if ( iContainer ) |
|
202 { |
|
203 AppUi()->RemoveFromStack( iContainer ); |
|
204 } |
|
205 |
|
206 ClearCurrentNaviPaneText(); |
|
207 |
|
208 delete iContainer; // Deletes the container class object. |
|
209 iContainer = NULL; |
|
210 } |
|
211 |
|
212 // -------------------------------------------------------------------------- |
|
213 // CMSStoreListView::FocusIndex() |
|
214 // -------------------------------------------------------------------------- |
|
215 // |
|
216 TInt CMSStoreListView::FocusIndex() const |
|
217 { |
|
218 return iContainer->SelectedItemIndex(); |
|
219 } |
|
220 |
|
221 // -------------------------------------------------------------------------- |
|
222 // CMSStoreListView::DynInitMenuPaneL |
|
223 // -------------------------------------------------------------------------- |
|
224 // |
|
225 void CMSStoreListView::DynInitMenuPaneL( TInt aResourceId, |
|
226 CEikMenuPane* aMenuPane) |
|
227 { |
|
228 LOG(_L("[MediaServant]\t CMSStoreListView::DynInitMenuPaneL")); |
|
229 |
|
230 if ( aResourceId == R_MS_STORE_LIST_MENU ) |
|
231 { |
|
232 // selection command |
|
233 if ( iContainer->CurrentListItemSelectionStatus() ) |
|
234 { |
|
235 aMenuPane->SetItemDimmed( EMSStoreCmdActivate, ETrue ); |
|
236 } |
|
237 else |
|
238 { |
|
239 aMenuPane->SetItemDimmed( EMSStoreCmdDeActivate, ETrue ); |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 // -------------------------------------------------------------------------- |
|
245 // CMSStoreListView::ReadyL() |
|
246 // engine observer callback |
|
247 // -------------------------------------------------------------------------- |
|
248 // |
|
249 void CMSStoreListView::ReadyL( TCmService aService, TInt /*aError*/ ) |
|
250 { |
|
251 LOG(_L("[MediaServant]\t CMSStoreListView::ReadyL")); |
|
252 |
|
253 if ( aService == ECmServicePreProcessingStore ) |
|
254 { |
|
255 CreateAndSetNaviTextL(); |
|
256 iPreprocessingState = EFalse; |
|
257 } |
|
258 } |
|
259 |
|
260 |
|
261 // -------------------------------------------------------------------------- |
|
262 // CMSStoreListView::CreateAndSetNaviTextL() |
|
263 // Creates and sets navi pane text |
|
264 // -------------------------------------------------------------------------- |
|
265 // |
|
266 void CMSStoreListView::CreateAndSetNaviTextL() |
|
267 { |
|
268 LOG(_L("[MediaServant]\t CMSStoreListView::CreateAndSetNaviTextL")); |
|
269 |
|
270 HBufC* naviText = NULL; |
|
271 |
|
272 TInt count = iContainer->ListItemCountL(); |
|
273 |
|
274 switch ( count ) |
|
275 { |
|
276 case 0: // 0 items |
|
277 { |
|
278 naviText = StringLoader::LoadLC( |
|
279 R_MS_NO_ITEMS_TO_BE_SYNCED ); |
|
280 break; |
|
281 } |
|
282 case 1: // 1 item |
|
283 { |
|
284 naviText = StringLoader::LoadLC( |
|
285 R_MS_1_ITEM_TO_BE_SYNCED ); |
|
286 break; |
|
287 } |
|
288 default: // many items |
|
289 { |
|
290 naviText = StringLoader::LoadLC( |
|
291 R_MS_N_ITEMS_TO_BE_SYNCED, |
|
292 count ); |
|
293 // do number conversion |
|
294 TPtr ptr = naviText->Des(); |
|
295 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
296 |
|
297 break; |
|
298 } |
|
299 |
|
300 } |
|
301 // update navi pane |
|
302 SetNavigationPaneTextL( *naviText ); |
|
303 |
|
304 CleanupStack::PopAndDestroy( naviText ); |
|
305 } |
|
306 |
|
307 // -------------------------------------------------------------------------- |
|
308 // CMSStoreListView::PreProcessing() |
|
309 // Returns preprocessing state |
|
310 // -------------------------------------------------------------------------- |
|
311 // |
|
312 TBool CMSStoreListView::PreProcessing() |
|
313 { |
|
314 return iPreprocessingState; |
|
315 } |
|
316 |
|
317 // End of File |
|
318 |
|