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 |
|
126 // No priorities in Uncategorized -> always disabled |
|
127 hidePrioritise = ETrue; |
|
128 |
|
129 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmAdd, hideAdd ); |
|
130 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmPrioritise, hidePrioritise ); |
|
131 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmCopyToOtherDestination, hideCopy ); |
|
132 aMenuPane->SetItemDimmed( ECmManagerUiCmdCmCopyToOtherDestination, hideMove ); |
|
133 } |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CUncatDlg::InitTextsL |
|
138 // called before the dialog is shown |
|
139 // to initialize localized textual data |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CUncatDlg::InitTextsL() |
|
143 { |
|
144 // set pane text if neccessary... |
|
145 // pane text needed if not pop-up... |
|
146 HBufC* primary = |
|
147 iEikonEnv->AllocReadResourceLC( R_CMMANAGERUI_EMPTY_METHOD_VIEW_PRIMARY ); |
|
148 HBufC* secondary = |
|
149 iEikonEnv->AllocReadResourceLC( R_CMMANAGERUI_EMPTY_METHOD_VIEW_SECONDARY ); |
|
150 CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(2); |
|
151 CleanupStack::PushL(items); |
|
152 items->AppendL(primary->Des()); |
|
153 items->AppendL(secondary->Des()); |
|
154 HBufC* emptyText = |
|
155 StringLoader::LoadLC( R_TWO_STRING_FOR_EMPTY_VIEW , *items); |
|
156 iListbox->View()->SetListEmptyTextL( *emptyText ); |
|
157 CleanupStack::PopAndDestroy( emptyText ); |
|
158 CleanupStack::PopAndDestroy( items ); |
|
159 CleanupStack::PopAndDestroy( secondary ); |
|
160 CleanupStack::PopAndDestroy( primary ); |
|
161 |
|
162 iStatusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
163 iTitlePane = |
|
164 ( CAknTitlePane* )iStatusPane->ControlL( |
|
165 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
166 |
|
167 iOldTitleText = iTitlePane->Text()->AllocL(); |
|
168 HBufC* name = StringLoader::LoadLC( R_CMMANAGERUI_DEST_UNCATEGORIZED ); |
|
169 iTitlePane->SetTextL( *name ); |
|
170 CleanupStack::PopAndDestroy( name ); |
|
171 iNaviPane = ( CAknNavigationControlContainer* ) |
|
172 iStatusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
173 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC ); |
|
174 iNaviPane->PushL( *iNaviDecorator ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CUncatDlg::ProcessCommandL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CUncatDlg::ProcessCommandL( TInt aCommandId ) |
|
182 { |
|
183 if ( MenuShowing() ) |
|
184 { |
|
185 HideMenu(); |
|
186 } |
|
187 |
|
188 switch ( aCommandId ) |
|
189 { |
|
190 case ECmManagerUiCmdCmMoveToOtherDestination: |
|
191 { |
|
192 if ( CurrentCML()->GetBoolAttributeL( ECmConnected ) ) |
|
193 { |
|
194 TCmCommonUi::ShowNoteL( R_QTN_SET_NOTE_AP_IN_USE_EDIT, |
|
195 TCmCommonUi::ECmErrorNote ); |
|
196 } |
|
197 else |
|
198 { |
|
199 // The selected item will be at the same position |
|
200 TInt selected = iListbox->CurrentItemIndex(); |
|
201 TInt noi = iListbox->Model()->NumberOfItems(); |
|
202 // If it is the last then the previous will be selected. |
|
203 if( ( selected == noi-1 ) && ( selected > 0 )) |
|
204 { |
|
205 selected--; |
|
206 } |
|
207 |
|
208 TRAPD( err, CCmDlg::ProcessCommandL( |
|
209 ECmManagerUiCmdCmCopyToOtherDestination ) ); |
|
210 if ( err == KErrCancel ) |
|
211 { |
|
212 break; |
|
213 } |
|
214 else |
|
215 { |
|
216 User::LeaveIfError( err ); |
|
217 } |
|
218 |
|
219 if ( iListbox->Model()->NumberOfItems() ) |
|
220 { |
|
221 //first item cannot be deleted |
|
222 iListbox->ScrollToMakeItemVisible( selected); |
|
223 iListbox->SetCurrentItemIndexAndDraw( selected ); |
|
224 } |
|
225 else |
|
226 { |
|
227 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_UNCAT_EMPTY, |
|
228 TCmCommonUi::ECmInfoNote ); |
|
229 iCmManager->WatcherUnRegister(); |
|
230 TryExitL( KDialogUserBack ); |
|
231 } |
|
232 } |
|
233 } |
|
234 break; |
|
235 |
|
236 case EAknSoftkeyClear: |
|
237 case ECmManagerUiCmdCmDelete: |
|
238 { |
|
239 CCmPluginBase* cm = CurrentCML(); |
|
240 |
|
241 if ( cm->GetBoolAttributeL( ECmProtected ) ) |
|
242 { |
|
243 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
244 TCmCommonUi::ECmErrorNote ); |
|
245 |
|
246 break; |
|
247 } |
|
248 |
|
249 if ( cm->GetBoolAttributeL( ECmIsLinked ) )//same check as KErrLocked below |
|
250 { |
|
251 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF, |
|
252 TCmCommonUi::ECmErrorNote ); |
|
253 |
|
254 break; |
|
255 } |
|
256 |
|
257 if ( cm->GetBoolAttributeL( ECmConnected ) )//same check as KErrInUse below |
|
258 { |
|
259 TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_CM_IN_USE_CANNOT_DELETE, |
|
260 TCmCommonUi::ECmErrorNote ); |
|
261 |
|
262 break; |
|
263 } |
|
264 |
|
265 HBufC* cmName = cm->GetStringAttributeL(ECmName); |
|
266 CleanupStack::PushL(cmName); |
|
267 |
|
268 if ( TCmCommonUi::ShowConfirmationQueryL( |
|
269 R_CMMANAGERUI_QUEST_CM_DELETE, *cmName ) ) |
|
270 { |
|
271 TRAPD( err, CurrentCML()->DeleteL( ETrue ) ); |
|
272 |
|
273 switch ( err ) |
|
274 { |
|
275 case KErrInUse: |
|
276 { |
|
277 TCmCommonUi::ShowNoteL |
|
278 ( R_CMMANAGERUI_INFO_CM_IN_USE_CANNOT_DELETE, |
|
279 TCmCommonUi::ECmErrorNote ); |
|
280 } |
|
281 break; |
|
282 |
|
283 case KErrLocked: |
|
284 { |
|
285 TCmCommonUi::ShowNoteL |
|
286 ( R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF, |
|
287 TCmCommonUi::ECmErrorNote ); |
|
288 } |
|
289 break; |
|
290 |
|
291 case KErrNone: |
|
292 { |
|
293 HandleListboxDataChangeL(); |
|
294 iListbox->HandleItemRemovalL(); |
|
295 |
|
296 if ( !iListbox->Model()->NumberOfItems() ) |
|
297 { |
|
298 TCmCommonUi::ShowNoteL( R_QTN_NETW_CONSET_INFO_UNCAT_EMPTY, |
|
299 TCmCommonUi::ECmInfoNote ); |
|
300 iCmManager->WatcherUnRegister(); |
|
301 TryExitL( KDialogUserBack ); |
|
302 } |
|
303 } |
|
304 break; |
|
305 |
|
306 default: |
|
307 { |
|
308 } |
|
309 } |
|
310 |
|
311 } |
|
312 CleanupStack::PopAndDestroy( cmName ); |
|
313 |
|
314 } |
|
315 break; |
|
316 |
|
317 case ECmManagerUiCmdCmAdd: |
|
318 case ECmManagerUiCmdCmCopyToOtherDestination: |
|
319 case ECmManagerUiCmdCmPrioritise: |
|
320 { |
|
321 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
322 TCmCommonUi::ECmErrorNote ); |
|
323 } |
|
324 break; |
|
325 |
|
326 default: |
|
327 { |
|
328 CCmDlg::ProcessCommandL(aCommandId); |
|
329 } |
|
330 } |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // CUncatDlg::CurrentCML |
|
335 // called before the dialog is shown to initialize listbox data |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 CCmPluginBase* CUncatDlg::CurrentCML() |
|
339 { |
|
340 return CMByIndexL( iListbox->CurrentItemIndex() ); |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // CUncatDlg::CMByIndexL |
|
345 // a connection method in the list |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 CCmPluginBase* CUncatDlg::CMByIndexL( TInt aIndex ) |
|
349 { |
|
350 TInt anIndex = iItemIndex[aIndex]; |
|
351 if( !iCmUncatItems[anIndex].iPlugin ) |
|
352 { |
|
353 iCmUncatItems[anIndex].iPlugin = |
|
354 iCmManager->GetConnectionMethodL( |
|
355 iCmUncatItems[anIndex].iCmId ); |
|
356 } |
|
357 return iCmUncatItems[anIndex].iPlugin; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // CUncatDlg::CMCount |
|
362 // number of cms in the list |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 TInt CUncatDlg::CMCount() |
|
366 { |
|
367 return iCmUncatItems.Count(); |
|
368 } |
|
369 |
|
370 // -------------------------------------------------------------------------- |
|
371 // CUncatDlg::ConstructCMArrayL |
|
372 // -------------------------------------------------------------------------- |
|
373 // |
|
374 void CUncatDlg::ConstructCMArrayL( RArray<TUint32>& aCmIds ) |
|
375 { |
|
376 // empty the array - reuse |
|
377 CleanupUncatArray( ETrue ); |
|
378 iCmManager->ConnectionMethodL( aCmIds, EFalse ); |
|
379 CleanupClosePushL( aCmIds ); |
|
380 |
|
381 for( TInt i = 0; i < aCmIds.Count(); ++i ) |
|
382 { |
|
383 TUncatItem item; |
|
384 |
|
385 item.iPlugin = NULL; |
|
386 item.iCmId = aCmIds[i]; |
|
387 |
|
388 User::LeaveIfError( iCmUncatItems.Append( item ) ); |
|
389 } |
|
390 |
|
391 CleanupStack::Pop( &aCmIds ); |
|
392 } |
|
393 |
|
394 // -------------------------------------------------------------------------- |
|
395 // CCmDlg::ClearHiddenCMsFromArrayL |
|
396 // -------------------------------------------------------------------------- |
|
397 // |
|
398 void CUncatDlg::ClearHiddenCMsFromArrayL( RArray<TUint32>& aCmIds ) |
|
399 { |
|
400 TBool hidden( EFalse ); |
|
401 TInt err( KErrNone ); |
|
402 for ( TInt index = 0; index < aCmIds.Count(); index++ ) |
|
403 { |
|
404 TUint recId = aCmIds[index]; |
|
405 TRAP( err, hidden = iCmManager->GetConnectionMethodInfoBoolL( recId, ECmHidden ) ); |
|
406 if ( err || hidden ) |
|
407 { |
|
408 aCmIds.Remove( index ); |
|
409 index--; |
|
410 // Remove the same item from iCmUncatItems array |
|
411 for( TInt i = 0; i < iCmUncatItems.Count(); i++ ) |
|
412 { |
|
413 if( iCmUncatItems[i].iCmId == recId ) |
|
414 { |
|
415 iCmUncatItems.Remove( i ); |
|
416 break; |
|
417 } |
|
418 } |
|
419 } |
|
420 } |
|
421 } |
|
422 |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // CUncatDlg::CleanupUncatArray |
|
426 // -------------------------------------------------------------------------- |
|
427 // |
|
428 void CUncatDlg::CleanupUncatArray( TBool aReuseArray ) |
|
429 { |
|
430 CLOG_WRITE( "CUncatDlg::CleanupUncatArray" ); |
|
431 for ( TInt i = 0; i < iCmUncatItems.Count(); ++i ) |
|
432 { |
|
433 CCmPluginBase* cm = iCmUncatItems[i].iPlugin; |
|
434 delete cm; |
|
435 } |
|
436 |
|
437 if ( aReuseArray ) |
|
438 { |
|
439 iCmUncatItems.Reset(); |
|
440 } |
|
441 else |
|
442 { |
|
443 iCmUncatItems.Close(); |
|
444 } |
|
445 } |
|
446 |
|
447 // -------------------------------------------------------------------------- |
|
448 // CUncatDlg::CommsDatChangesL |
|
449 // -------------------------------------------------------------------------- |
|
450 // |
|
451 void CUncatDlg::CommsDatChangesL() |
|
452 { |
|
453 // Update list box |
|
454 HandleListboxDataChangeL(); |
|
455 } |
|