|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of CUncatDlg. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <eikdef.h> |
|
20 #include <eikenv.h> |
|
21 #include <eikedwin.h> |
|
22 #include <cmmanager.rsg> |
|
23 #include <aknnavide.h> |
|
24 #include <akntitle.h> |
|
25 #include <eikmenup.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <StringLoader.h> |
|
28 #include <AknIconArray.h> |
|
29 |
|
30 #include "cmmanager.hrh" |
|
31 #include "uncatdlg.h" |
|
32 #include "cmlistitem.h" |
|
33 #include "cmlistitemlist.h" |
|
34 #include <cmpluginbaseeng.h> |
|
35 #include <cmpluginbase.h> |
|
36 #include "cmdestinationimpl.h" |
|
37 #include <cmcommonui.h> |
|
38 #include <cmcommonconstants.h> |
|
39 #include <cmpbasesettingsdlg.h> |
|
40 #include "cmlistboxmodel.h" |
|
41 #include "selectdestinationdlg.h" |
|
42 #include "cmlogger.h" |
|
43 |
|
44 using namespace CMManager; |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CUncatDlg::ConstructAndRunLD |
|
48 // Constructs the dialog and runs it. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 TInt CUncatDlg::ConstructAndRunLD( TUint32 aHighlight, |
|
52 TUint32& aSelected ) |
|
53 { |
|
54 CleanupStack::PushL( this ); |
|
55 iHighlight = aHighlight; |
|
56 iSelected = &aSelected; |
|
57 ConstructL( R_CM_MENUBAR ); |
|
58 PrepareLC(R_CM_DIALOG); |
|
59 CleanupStack::Pop( this ); // it will be PushL-d by ExecuteLD... |
|
60 iModel = new( ELeave ) CCmListboxModel(); |
|
61 //destructed in base class destructor |
|
62 iInfoPopupNoteController = CAknInfoPopupNoteController::NewL(); |
|
63 |
|
64 // Trace changes in CommsDat |
|
65 iCmManager->WatcherRegisterL( this ); |
|
66 |
|
67 return RunLD(); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CUncatDlg::NewL() |
|
72 // Two-phase dconstructor, second phase is ConstructAndRunLD |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CUncatDlg* CUncatDlg::NewL(CCmManagerImpl* aCmManager ) |
|
76 { |
|
77 CUncatDlg* self = new (ELeave) CUncatDlg( aCmManager ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CUncatDlg::CUncatDlg() |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CUncatDlg::CUncatDlg( CCmManagerImpl* aCmManager ) |
|
86 : CCmDlg( aCmManager, NULL, NULL ) |
|
87 , iCmUncatItems(KCmArraySmallGranularity) |
|
88 { |
|
89 CLOG_CREATE; |
|
90 CLOG_ATTACH( this, iCmManager ); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CUncatDlg::~CUncatDlg |
|
95 // Destructor |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CUncatDlg::~CUncatDlg() |
|
99 { |
|
100 CLOG_WRITE( "CUncatDlg::~CUncatDlg" ); |
|
101 CleanupUncatArray(); |
|
102 CLOG_CLOSE; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CUncatDlg::DynInitMenuPaneL |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CUncatDlg::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
110 { |
|
111 TBool hideAdd ( EFalse ); |
|
112 TBool hideMove ( EFalse ); |
|
113 TBool hideCopy( EFalse ); |
|
114 TBool hidePrioritise( EFalse ); |
|
115 |
|
116 CCmDlg::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
117 if ( aResourceId == R_CM_MENU ) |
|
118 { |
|
119 // There are no destinatons to move to OR |
|
120 // the highlighted connection method is in use |
|
121 if ( !iCmManager->DestinationCountL() ) |
|
122 { |
|
123 hideMove = ETrue; |
|
124 } |
|
125 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmAdd, hideAdd ); |
|
126 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmPrioritise, hidePrioritise ); |
|
127 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmCopyToOtherDestination, hideCopy ); |
|
128 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmCopyToOtherDestination, hideMove ); |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CUncatDlg::InitTextsL |
|
134 // called before the dialog is shown |
|
135 // to initialize localized textual data |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CUncatDlg::InitTextsL() |
|
139 { |
|
140 // set pane text if neccessary... |
|
141 // pane text needed if not pop-up... |
|
142 HBufC* primary = |
|
143 iEikonEnv->AllocReadResourceLC( R_CMMANAGERUI_EMPTY_METHOD_VIEW_PRIMARY ); |
|
144 HBufC* secondary = |
|
145 iEikonEnv->AllocReadResourceLC( R_CMMANAGERUI_EMPTY_METHOD_VIEW_SECONDARY ); |
|
146 CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(2); |
|
147 CleanupStack::PushL(items); |
|
148 items->AppendL(primary->Des()); |
|
149 items->AppendL(secondary->Des()); |
|
150 HBufC* emptyText = |
|
151 StringLoader::LoadLC( R_TWO_STRING_FOR_EMPTY_VIEW , *items); |
|
152 iListbox->View()->SetListEmptyTextL( *emptyText ); |
|
153 CleanupStack::PopAndDestroy( emptyText ); |
|
154 CleanupStack::PopAndDestroy( items ); |
|
155 CleanupStack::PopAndDestroy( secondary ); |
|
156 CleanupStack::PopAndDestroy( primary ); |
|
157 |
|
158 iStatusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
159 iTitlePane = |
|
160 ( CAknTitlePane* )iStatusPane->ControlL( |
|
161 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
162 |
|
163 iOldTitleText = iTitlePane->Text()->AllocL(); |
|
164 HBufC* name = StringLoader::LoadLC( R_CMMANAGERUI_DEST_UNCATEGORIZED ); |
|
165 iTitlePane->SetTextL( *name ); |
|
166 CleanupStack::PopAndDestroy( name ); |
|
167 iNaviPane = ( CAknNavigationControlContainer* ) |
|
168 iStatusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
169 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC ); |
|
170 iNaviPane->PushL( *iNaviDecorator ); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CUncatDlg::ProcessCommandL |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CUncatDlg::ProcessCommandL( TInt aCommandId ) |
|
178 { |
|
179 if ( MenuShowing() ) |
|
180 { |
|
181 HideMenu(); |
|
182 } |
|
183 |
|
184 switch ( aCommandId ) |
|
185 { |
|
186 case ECmManagerUiCmdCmMoveToOtherDestination: |
|
187 { |
|
188 if ( CurrentCML()->GetBoolAttributeL( ECmConnected ) ) |
|
189 { |
|
190 TCmCommonUi::ShowNoteL( R_QTN_SET_NOTE_AP_IN_USE_EDIT, |
|
191 TCmCommonUi::ECmErrorNote ); |
|
192 } |
|
193 else |
|
194 { |
|
195 // The selected item will be at the same position |
|
196 TInt selected = iListbox->CurrentItemIndex(); |
|
197 TInt noi = iListbox->Model()->NumberOfItems(); |
|
198 // If it is the last then the previous will be selected. |
|
199 if( selected == noi-1 ) |
|
200 { |
|
201 selected--; |
|
202 } |
|
203 |
|
204 TRAPD( err, CCmDlg::ProcessCommandL( |
|
205 ECmManagerUiCmdCmCopyToOtherDestination ) ); |
|
206 if ( err == KErrCancel ) |
|
207 { |
|
208 break; |
|
209 } |
|
210 else |
|
211 { |
|
212 User::LeaveIfError( err ); |
|
213 } |
|
214 |
|
215 if ( iListbox->Model()->NumberOfItems() ) |
|
216 { |
|
217 //first item cannot be deleted |
|
218 iListbox->ScrollToMakeItemVisible( selected); |
|
219 iListbox->SetCurrentItemIndexAndDraw( selected ); |
|
220 } |
|
221 else |
|
222 { |
|
223 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_UNCAT_EMPTY, |
|
224 TCmCommonUi::ECmInfoNote ); |
|
225 TryExitL( KDialogUserBack ); |
|
226 } |
|
227 } |
|
228 } |
|
229 break; |
|
230 |
|
231 case EAknSoftkeyClear: |
|
232 case ECmManagerUiCmdCmDelete: |
|
233 { |
|
234 CCmPluginBase* cm = CurrentCML(); |
|
235 |
|
236 if ( cm->GetBoolAttributeL( ECmProtected ) ) |
|
237 { |
|
238 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
239 TCmCommonUi::ECmErrorNote ); |
|
240 |
|
241 break; |
|
242 } |
|
243 |
|
244 if ( cm->GetBoolAttributeL( ECmIsLinked ) )//same check as KErrLocked below |
|
245 { |
|
246 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF, |
|
247 TCmCommonUi::ECmErrorNote ); |
|
248 |
|
249 break; |
|
250 } |
|
251 |
|
252 if ( cm->GetBoolAttributeL( ECmConnected ) )//same check as KErrInUse below |
|
253 { |
|
254 TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_CM_IN_USE_CANNOT_DELETE, |
|
255 TCmCommonUi::ECmErrorNote ); |
|
256 |
|
257 break; |
|
258 } |
|
259 |
|
260 HBufC* cmName = cm->GetStringAttributeL(ECmName); |
|
261 CleanupStack::PushL(cmName); |
|
262 |
|
263 if ( TCmCommonUi::ShowConfirmationQueryL( |
|
264 R_CMMANAGERUI_QUEST_CM_DELETE, *cmName ) ) |
|
265 { |
|
266 TRAPD( err, CurrentCML()->DeleteL( ETrue ) ); |
|
267 |
|
268 switch ( err ) |
|
269 { |
|
270 case KErrInUse: |
|
271 { |
|
272 TCmCommonUi::ShowNoteL |
|
273 ( R_CMMANAGERUI_INFO_CM_IN_USE_CANNOT_DELETE, |
|
274 TCmCommonUi::ECmErrorNote ); |
|
275 } |
|
276 break; |
|
277 |
|
278 case KErrLocked: |
|
279 { |
|
280 TCmCommonUi::ShowNoteL |
|
281 ( R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF, |
|
282 TCmCommonUi::ECmErrorNote ); |
|
283 } |
|
284 break; |
|
285 |
|
286 case KErrNone: |
|
287 { |
|
288 HandleListboxDataChangeL(); |
|
289 |
|
290 if ( !iListbox->Model()->NumberOfItems() ) |
|
291 { |
|
292 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_UNCAT_EMPTY, |
|
293 TCmCommonUi::ECmInfoNote ); |
|
294 TryExitL( KDialogUserBack ); |
|
295 } |
|
296 } |
|
297 break; |
|
298 |
|
299 default: |
|
300 { |
|
301 } |
|
302 } |
|
303 |
|
304 } |
|
305 CleanupStack::PopAndDestroy( cmName ); |
|
306 |
|
307 } |
|
308 break; |
|
309 |
|
310 case ECmManagerUiCmdCmAdd: |
|
311 case ECmManagerUiCmdCmCopyToOtherDestination: |
|
312 case ECmManagerUiCmdCmPrioritise: |
|
313 { |
|
314 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
315 TCmCommonUi::ECmErrorNote ); |
|
316 } |
|
317 break; |
|
318 |
|
319 default: |
|
320 { |
|
321 CCmDlg::ProcessCommandL(aCommandId); |
|
322 } |
|
323 } |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // CUncatDlg::CurrentCML |
|
328 // called before the dialog is shown to initialize listbox data |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 CCmPluginBase* CUncatDlg::CurrentCML() |
|
332 { |
|
333 return CMByIndexL( iListbox->CurrentItemIndex() ); |
|
334 } |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // CUncatDlg::CMByIndexL |
|
338 // a connection method in the list |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 CCmPluginBase* CUncatDlg::CMByIndexL( TInt aIndex ) |
|
342 { |
|
343 TInt anIndex = iItemIndex[aIndex]; |
|
344 if( !iCmUncatItems[anIndex].iPlugin ) |
|
345 { |
|
346 iCmUncatItems[anIndex].iPlugin = |
|
347 iCmManager->GetConnectionMethodL( |
|
348 iCmUncatItems[anIndex].iCmId ); |
|
349 } |
|
350 return iCmUncatItems[anIndex].iPlugin; |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CUncatDlg::CMCount |
|
355 // number of cms in the list |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 TInt CUncatDlg::CMCount() |
|
359 { |
|
360 return iCmUncatItems.Count(); |
|
361 } |
|
362 |
|
363 // -------------------------------------------------------------------------- |
|
364 // CUncatDlg::ConstructCMArrayL |
|
365 // -------------------------------------------------------------------------- |
|
366 // |
|
367 void CUncatDlg::ConstructCMArrayL( RArray<TUint32>& aCmIds ) |
|
368 { |
|
369 // empty the array - reuse |
|
370 CleanupUncatArray( ETrue ); |
|
371 iCmManager->ConnectionMethodL( aCmIds, EFalse ); |
|
372 CleanupClosePushL( aCmIds ); |
|
373 |
|
374 for( TInt i = 0; i < aCmIds.Count(); ++i ) |
|
375 { |
|
376 TUncatItem item; |
|
377 |
|
378 item.iPlugin = NULL; |
|
379 item.iCmId = aCmIds[i]; |
|
380 |
|
381 User::LeaveIfError( iCmUncatItems.Append( item ) ); |
|
382 } |
|
383 |
|
384 CleanupStack::Pop( &aCmIds ); |
|
385 } |
|
386 |
|
387 // -------------------------------------------------------------------------- |
|
388 // CUncatDlg::CleanupUncatArray |
|
389 // -------------------------------------------------------------------------- |
|
390 // |
|
391 void CUncatDlg::CleanupUncatArray( TBool aReuseArray ) |
|
392 { |
|
393 CLOG_WRITE( "CUncatDlg::CleanupUncatArray" ); |
|
394 for ( TInt i = 0; i < iCmUncatItems.Count(); ++i ) |
|
395 { |
|
396 CCmPluginBase* cm = iCmUncatItems[i].iPlugin; |
|
397 delete cm; |
|
398 } |
|
399 |
|
400 if ( aReuseArray ) |
|
401 { |
|
402 iCmUncatItems.Reset(); |
|
403 } |
|
404 else |
|
405 { |
|
406 iCmUncatItems.Close(); |
|
407 } |
|
408 } |
|
409 |
|
410 // -------------------------------------------------------------------------- |
|
411 // CUncatDlg::CommsDatChangesL |
|
412 // -------------------------------------------------------------------------- |
|
413 // |
|
414 void CUncatDlg::CommsDatChangesL() |
|
415 { |
|
416 // Update list box |
|
417 HandleListboxDataChangeL(); |
|
418 } |