|
1 /* |
|
2 * Copyright (c) 2006-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: Dialog for setting the gateway. It's used temporarily. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <eikdef.h> |
|
20 #include <eikenv.h> |
|
21 #include <eikedwin.h> |
|
22 #include <gulicon.h> |
|
23 #include <cmmanager.rsg> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <cmmanager.mbg> |
|
26 #include <badesca.h> // CDesCArray |
|
27 #include <aknnavide.h> |
|
28 #include <akntitle.h> |
|
29 #include <eikmenup.h> |
|
30 #include <StringLoader.h> |
|
31 #include <AknIconArray.h> |
|
32 #include <aknnavilabel.h> |
|
33 #include <textresolver.h> |
|
34 |
|
35 #include <hlplch.h> |
|
36 #include <csxhelp/cp.hlp.hrh> |
|
37 |
|
38 #include <cmcommonconstants.h> |
|
39 #include <cmdestination.h> |
|
40 #include <cmcommonui.h> |
|
41 #include <cmpluginbaseeng.h> |
|
42 #include <cmpluginbase.h> |
|
43 |
|
44 #include "cmmanager.hrh" |
|
45 #include "destlistitem.h" |
|
46 #include "destlistitemlist.h" |
|
47 #include "destdlg.h" |
|
48 #include "cmwizard.h" |
|
49 #include "uncatdlg.h" |
|
50 #include "cmdlg.h" |
|
51 #include "cmdesticondialog.h" |
|
52 #include "cmlistboxmodel.h" |
|
53 #include "cmlistitem.h" |
|
54 #include <mcmdexec.h> |
|
55 #include "ccmdexec.h" |
|
56 #include "cmlogger.h" |
|
57 |
|
58 using namespace CMManager; |
|
59 using namespace CommsDat; |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CDestDlg::ConstructAndRunLD |
|
63 // Constructs the dialog and runs it. |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 TInt CDestDlg::ConstructAndRunLD( CCmManagerImpl* aCmManagerImpl, |
|
67 TUint32 aHighlight, |
|
68 TUint32& aSelected, |
|
69 TBool& aExiting ) |
|
70 { |
|
71 iHighlight = aHighlight; |
|
72 iSelected = &aSelected; |
|
73 iCmManagerImpl = aCmManagerImpl; |
|
74 iExiting = &aExiting; |
|
75 *iExiting = EFalse; |
|
76 |
|
77 iCmdExec = new (ELeave) CCmdExec(*this); |
|
78 |
|
79 ConstructL( R_DEST_MENUBAR ); |
|
80 PrepareLC( R_DEST_DIALOG ); |
|
81 iModel = new( ELeave )CDestListboxModel(); |
|
82 iConnSettingsImpl = CCmConnSettingsUiImpl::NewL( iCmManagerImpl ); |
|
83 |
|
84 // CommsDat notifier should be started with this first UI view for |
|
85 // it will create active object |
|
86 iCmManagerImpl->StartCommsDatNotifierL(); |
|
87 iCmManagerImpl->WatcherRegisterL( this ); |
|
88 |
|
89 return RunLD(); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CDestDlg::CDestDlg() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CDestDlg::CDestDlg() |
|
97 : iModelPassed( EFalse ) |
|
98 , iExitReason( KDialogUserExit ) |
|
99 , iEscapeArrived( EFalse ) |
|
100 { |
|
101 CLOG_CREATE; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CDestDlg::~CApSelectorDialog |
|
106 // Destructor |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CDestDlg::~CDestDlg() |
|
110 { |
|
111 // iModel is deleted by the ListBox because LB owns the model... |
|
112 // of course only after we passed ownership... |
|
113 if ( !iModelPassed ) |
|
114 { |
|
115 delete iModel; |
|
116 } |
|
117 if ( iNaviDecorator ) |
|
118 { |
|
119 delete iNaviDecorator; |
|
120 } |
|
121 if ( iTitlePane ) |
|
122 { |
|
123 // set old text back, if we have it and if we are going back to |
|
124 // Connectivity Settings view |
|
125 if ( iOldTitleText ) |
|
126 { |
|
127 if ( iExitReason == KDialogUserBack ) |
|
128 { |
|
129 TRAP_IGNORE( iTitlePane->SetTextL( *iOldTitleText ) ); |
|
130 } |
|
131 delete iOldTitleText; |
|
132 } |
|
133 } |
|
134 if ( iConnSettingsImpl ) |
|
135 { |
|
136 delete iConnSettingsImpl; |
|
137 } |
|
138 |
|
139 if( iCmWizard ) |
|
140 { |
|
141 delete iCmWizard; |
|
142 } |
|
143 |
|
144 delete iCmdExec; |
|
145 |
|
146 CLOG_CLOSE; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CDestDlg::PreLayoutDynInitL(); |
|
151 // called by framework before dialog is shown |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void CDestDlg::PreLayoutDynInitL() |
|
155 { |
|
156 iListbox = |
|
157 STATIC_CAST( CDestListbox*, Control( KDestListboxId ) ); |
|
158 iListbox->CreateScrollBarFrameL( ETrue ); |
|
159 iListbox->ScrollBarFrame()->SetScrollBarVisibilityL |
|
160 ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
161 iListbox->SetListBoxObserver( this ); |
|
162 |
|
163 iListbox->Model()->SetItemTextArray( iModel ); |
|
164 iModelPassed = ETrue; |
|
165 InitTextsL(); |
|
166 HandleListboxDataChangeL(); |
|
167 iListbox->HandleItemAdditionL(); |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CDestDlg::DynInitMenuPaneL |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 void CDestDlg::DynInitMenuPaneL( TInt aResourceId, |
|
175 CEikMenuPane* aMenuPane ) |
|
176 { |
|
177 switch ( aResourceId ) |
|
178 { |
|
179 case R_DEST_MENU: |
|
180 { |
|
181 // Check if it is the 'New connection' list item |
|
182 // rather than a real destination |
|
183 TUint32 listItemUid = iListbox->CurrentItemUid(); |
|
184 if ( listItemUid == KDestItemNewConnection ) |
|
185 { |
|
186 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestEdit, ETrue ); |
|
187 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestRename, ETrue ); |
|
188 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestDelete, ETrue ); |
|
189 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestChangeIcon, ETrue ); |
|
190 } |
|
191 if ( !iCmManagerImpl->IsDefConnSupported() ) |
|
192 { |
|
193 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestDefaultConnection, ETrue ); |
|
194 } |
|
195 if (!iCmManagerImpl->IsHelpOn()) |
|
196 { |
|
197 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
198 } |
|
199 break; |
|
200 } |
|
201 default: |
|
202 break; |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CDestDlg::OfferKeyEventL |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 TKeyResponse CDestDlg::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
211 TEventCode aType ) |
|
212 { |
|
213 LOGGER_ENTERFN( "CDestDlg::OfferKeyEventL" ); |
|
214 CLOG_WRITE_1("Key iCode: %d", aKeyEvent.iCode ); |
|
215 |
|
216 TKeyResponse retVal ( EKeyWasNotConsumed ); |
|
217 |
|
218 TBool down( EFalse ); |
|
219 |
|
220 switch ( aKeyEvent.iCode ) |
|
221 { |
|
222 case EKeyEscape: |
|
223 { |
|
224 // Handling application close needs special care |
|
225 // because of iCmWizard |
|
226 if ( iCmWizard ) |
|
227 { |
|
228 // if wizard alives then escape should do after wizard has ended. |
|
229 CLOG_WRITE( "CDestDlg::OfferKeyEventL: Wizard in long process" ); |
|
230 iEscapeArrived = ETrue; |
|
231 retVal = EKeyWasConsumed; |
|
232 } |
|
233 else |
|
234 { |
|
235 CLOG_WRITE( "CDestDlg::OfferKeyEventL:Escape" ); |
|
236 retVal = CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
237 } |
|
238 break; |
|
239 } |
|
240 case EKeyBackspace: |
|
241 { |
|
242 ProcessCommandL( ECmManagerUiCmdDestDelete ); |
|
243 retVal = EKeyWasConsumed; |
|
244 break; |
|
245 } |
|
246 case EKeyDownArrow: |
|
247 { |
|
248 down = ETrue; |
|
249 // intended flow-through |
|
250 } |
|
251 case EKeyUpArrow: |
|
252 { |
|
253 // When moving from the 'New connection' (first) item, MSK should be 'Open' |
|
254 if ( iListbox->CurrentItemUid() == KDestItemNewConnection ) |
|
255 { |
|
256 SetMskL( R_QTN_MSK_OPEN ); |
|
257 } |
|
258 |
|
259 // When moving to the 'New connection' (first item) |
|
260 else if ( ( iListbox->CurrentItemIndex() == 1 && !down ) || |
|
261 ( iListbox->CurrentItemIndex() + 1 == |
|
262 iModel->MdcaCount() && down ) ) |
|
263 { |
|
264 SetMskL( R_QTN_MSK_SELECT ); |
|
265 } |
|
266 // flow through to 'default' intended |
|
267 } |
|
268 default: |
|
269 { |
|
270 retVal = iListbox->OfferKeyEventL(aKeyEvent, aType); |
|
271 break; |
|
272 } |
|
273 } |
|
274 return retVal; |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CDestDlg::ShowDefaultSetNoteL |
|
279 // ---------------------------------------------------------------------------- |
|
280 // |
|
281 void CDestDlg::ShowDefaultSetNoteL( TCmDefConnValue aSelection ) |
|
282 { |
|
283 switch ( aSelection.iType ) |
|
284 { |
|
285 case ECmDefConnDestination: |
|
286 case ECmDefConnConnectionMethod: |
|
287 { |
|
288 HBufC* connName = iConnSettingsImpl->CreateDefaultConnectionNameL( aSelection ); |
|
289 CleanupStack::PushL(connName); |
|
290 TCmCommonUi::ShowNoteL( R_CMMANAGERUI_DEFAULT_CONNECTION_SET_TO, |
|
291 *connName, |
|
292 TCmCommonUi::ECmOkNote ); |
|
293 CleanupStack::PopAndDestroy( connName ); |
|
294 } |
|
295 } |
|
296 } |
|
297 |
|
298 |
|
299 // ---------------------------------------------------------------------------- |
|
300 // CDestDlg::SetDefaultNaviL |
|
301 // ---------------------------------------------------------------------------- |
|
302 // |
|
303 void CDestDlg::SetDefaultNaviL( TCmDefConnValue aSelection ) |
|
304 { |
|
305 HBufC* title = NULL; |
|
306 |
|
307 switch ( aSelection.iType ) |
|
308 { |
|
309 case ECmDefConnDestination: |
|
310 case ECmDefConnConnectionMethod: |
|
311 { |
|
312 HBufC* connName = iConnSettingsImpl->CreateDefaultConnectionNameL( aSelection ); |
|
313 CleanupStack::PushL(connName); |
|
314 title = StringLoader::LoadL( R_CMMANAGERUI_NAVI_DEFAULT, *connName ); |
|
315 CleanupStack::PopAndDestroy( connName ); |
|
316 CleanupStack::PushL( title ); |
|
317 break; |
|
318 } |
|
319 } |
|
320 |
|
321 if ( iNaviDecorator ) |
|
322 { |
|
323 if ( iNaviDecorator->ControlType() == |
|
324 CAknNavigationDecorator::ENaviLabel ) |
|
325 { |
|
326 CAknNaviLabel* naviLabel = |
|
327 (CAknNaviLabel*)iNaviDecorator->DecoratedControl(); |
|
328 if ( title ) |
|
329 { |
|
330 naviLabel->SetTextL(*title); |
|
331 } |
|
332 else |
|
333 { |
|
334 naviLabel->SetTextL( KNullDesC ); |
|
335 } |
|
336 |
|
337 iNaviPane->PushL( *iNaviDecorator ); |
|
338 } |
|
339 } |
|
340 |
|
341 if ( title ) |
|
342 { |
|
343 CleanupStack::PopAndDestroy( title ); |
|
344 } |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // CDestDlg::ProcessCommandL |
|
349 // ---------------------------------------------------------------------------- |
|
350 // |
|
351 void CDestDlg::ProcessCommandL( TInt aCommandId ) |
|
352 { |
|
353 LOGGER_ENTERFN( "CDestDlg::ProcessCommandL" ); |
|
354 CLOG_WRITE_1("Command: %d", aCommandId ); |
|
355 |
|
356 if ( MenuShowing() ) |
|
357 { |
|
358 HideMenu(); |
|
359 } |
|
360 |
|
361 switch ( aCommandId ) |
|
362 { |
|
363 case EAknSoftkeyOptions: |
|
364 { |
|
365 DisplayMenuL(); |
|
366 break; |
|
367 } |
|
368 case ECmManagerUiCmdDestUserExit: |
|
369 { |
|
370 CLOG_WRITE( "CDestDlg::ProcessCommandL command: exit"); |
|
371 iExitReason = KDialogUserExit; |
|
372 iCmManagerImpl->WatcherUnRegister(); |
|
373 TryExitL( iExitReason ); |
|
374 break; |
|
375 } |
|
376 case EAknSoftkeyBack: |
|
377 { |
|
378 iExitReason = KDialogUserBack; |
|
379 iCmManagerImpl->WatcherUnRegister(); |
|
380 TryExitL( iExitReason ); |
|
381 break; |
|
382 } |
|
383 case ECmManagerUiCmdDestEdit: |
|
384 { |
|
385 OnCommandDestinationEditL(); |
|
386 break; |
|
387 } |
|
388 case ECmManagerUiCmdDestDefaultConnection: |
|
389 { |
|
390 TCmDCSettingSelection selection; |
|
391 TCmDefConnValue defConnValue; |
|
392 iCmManagerImpl->ReadDefConnL( defConnValue ); |
|
393 switch (defConnValue.iType) |
|
394 { |
|
395 case ECmDefConnConnectionMethod: |
|
396 { |
|
397 selection.iResult = EDCConnectionMethod; |
|
398 selection.iId = defConnValue.iId; |
|
399 break; |
|
400 } |
|
401 case ECmDefConnDestination: |
|
402 { |
|
403 selection.iResult = EDCDestination; |
|
404 selection.iId = defConnValue.iId; |
|
405 break; |
|
406 } |
|
407 default: |
|
408 { |
|
409 break; |
|
410 } |
|
411 } |
|
412 if ( iConnSettingsImpl->RunDefaultConnecitonRBPageL( selection ) ) |
|
413 { |
|
414 defConnValue = selection.ConvertToDefConn(); |
|
415 |
|
416 iCmManagerImpl->WriteDefConnL( defConnValue ); |
|
417 HandleListboxDataChangeL(); |
|
418 } |
|
419 break; |
|
420 } |
|
421 |
|
422 case ECmManagerUiCmdDestChangeIcon: |
|
423 { |
|
424 // Check if this is UnCat |
|
425 if ( iListbox->CurrentItemUid() == KDestItemUncategorized ) |
|
426 { |
|
427 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
428 TCmCommonUi::ECmErrorNote ); |
|
429 break; |
|
430 } |
|
431 |
|
432 // Check that destination is not protected |
|
433 CCmDestinationImpl* dest = |
|
434 iCmManagerImpl->DestinationL( iListbox->CurrentItemUid() ); |
|
435 CleanupStack::PushL( dest ); |
|
436 if ( dest->ProtectionLevel() ) |
|
437 { |
|
438 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
439 TCmCommonUi::ECmErrorNote ); |
|
440 |
|
441 CleanupStack::PopAndDestroy( dest ); |
|
442 break; |
|
443 } |
|
444 |
|
445 TInt iconSelected = 0; |
|
446 CCmDestinationIconDialog* popup = |
|
447 new (ELeave) CCmDestinationIconDialog( iconSelected ); |
|
448 if ( popup->ExecuteLD() ) |
|
449 { |
|
450 dest->SetIconL( iconSelected ); // subclass implements |
|
451 dest->UpdateL(); |
|
452 CleanupStack::PopAndDestroy( dest ); |
|
453 |
|
454 HandleListboxDataChangeL(); |
|
455 break; |
|
456 } |
|
457 |
|
458 CleanupStack::PopAndDestroy( dest ); |
|
459 |
|
460 break; |
|
461 |
|
462 } |
|
463 |
|
464 |
|
465 case ECmManagerUiCmdDestAdd: |
|
466 { |
|
467 AddDestinationL(); |
|
468 break; |
|
469 } |
|
470 |
|
471 case EAknSoftkeyClear: |
|
472 case ECmManagerUiCmdDestDelete: |
|
473 { |
|
474 OnCommandDestinationDeleteL(); |
|
475 break; |
|
476 |
|
477 } |
|
478 |
|
479 case ECmManagerUiCmdDestRename: |
|
480 { |
|
481 OnCommandDestinationRenameL(); |
|
482 break; |
|
483 } |
|
484 |
|
485 case EAknCmdHelp: |
|
486 { |
|
487 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
488 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
489 } |
|
490 break; |
|
491 |
|
492 default: |
|
493 { |
|
494 break; |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CDestDlg::InitTextsL |
|
501 // called before the dialog is shown |
|
502 // to initialize localized textual data |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 void CDestDlg::InitTextsL() |
|
506 { |
|
507 // set pane text if neccessary... |
|
508 // pane text needed if not pop-up... |
|
509 if ( iEikonEnv ) |
|
510 { |
|
511 iStatusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
512 iTitlePane = |
|
513 ( CAknTitlePane* )iStatusPane->ControlL( |
|
514 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
515 |
|
516 iOldTitleText = iTitlePane->Text()->AllocL(); |
|
517 iTitlePane->SetTextL( |
|
518 *(StringLoader::LoadLC( R_CMMANAGERUI_NAVI )) ); |
|
519 |
|
520 CleanupStack::PopAndDestroy(); // resource R_CMMANAGERUI_NAVI |
|
521 iNaviPane = ( CAknNavigationControlContainer* ) |
|
522 iStatusPane->ControlL( |
|
523 TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
524 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC ); |
|
525 iNaviPane->PushL( *iNaviDecorator ); |
|
526 if ( iCmManagerImpl->IsDefConnSupported() ) |
|
527 { |
|
528 TCmDefConnValue selection; |
|
529 selection.iType = ECmDefConnAlwaysAsk; |
|
530 iCmManagerImpl->ReadDefConnL( selection ); |
|
531 SetDefaultNaviL( selection ); |
|
532 } |
|
533 } |
|
534 } |
|
535 |
|
536 // --------------------------------------------------------------------------- |
|
537 // CDestDlg::SetNoOfDestsL |
|
538 // --------------------------------------------------------------------------- |
|
539 // |
|
540 void CDestDlg::SetNoOfDestsL( TInt aCount ) |
|
541 { |
|
542 HBufC* title = NULL; |
|
543 |
|
544 if ( aCount == 1 ) |
|
545 { |
|
546 title = StringLoader::LoadLC( R_QTN_NETW_CONSET_NAVI_ONE_DESTINATION ); |
|
547 } |
|
548 else |
|
549 { |
|
550 title = StringLoader::LoadLC( R_QTN_NETW_CONSET_NAVI_NOF_DESTINATIONS, |
|
551 aCount ); |
|
552 } |
|
553 if (iNaviDecorator) |
|
554 { |
|
555 if ( iNaviDecorator->ControlType() == |
|
556 CAknNavigationDecorator::ENaviLabel ) |
|
557 { |
|
558 CAknNaviLabel* naviLabel = |
|
559 (CAknNaviLabel*)iNaviDecorator->DecoratedControl(); |
|
560 naviLabel->SetTextL(*title); |
|
561 iNaviPane->PushL( *iNaviDecorator ); |
|
562 } |
|
563 } |
|
564 |
|
565 CleanupStack::PopAndDestroy( title ); |
|
566 } |
|
567 |
|
568 // --------------------------------------------------------------------------- |
|
569 // CDestDlg::CreateCustomControlL |
|
570 // --------------------------------------------------------------------------- |
|
571 // |
|
572 SEikControlInfo CDestDlg::CreateCustomControlL |
|
573 ( TInt aControlType ) |
|
574 { |
|
575 SEikControlInfo controlInfo; |
|
576 controlInfo.iTrailerTextId = 0; |
|
577 controlInfo.iFlags = 0; |
|
578 if ( aControlType == KDestListboxType ) |
|
579 { |
|
580 controlInfo.iControl = new ( ELeave ) CDestListbox; |
|
581 } |
|
582 else |
|
583 { |
|
584 controlInfo.iControl = NULL; |
|
585 } |
|
586 return controlInfo; |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // CDestDlg::OkToExitL |
|
591 // Good to know : EAknSoftkeyCancel is never called, because |
|
592 // EEikDialogFlagNotifyEsc flag is not set in the resource. |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 TBool CDestDlg::OkToExitL( TInt aButtonId ) |
|
596 { |
|
597 CLOG_WRITE_1( "CDestDlg::OkToExitL buttonId: %d", aButtonId ); |
|
598 |
|
599 // Translate the button presses into commands for the appui & current |
|
600 // view to handle |
|
601 TBool retval( EFalse ); |
|
602 switch ( aButtonId ) |
|
603 { |
|
604 case EAknSoftkeyOk: |
|
605 case EAknSoftkeySelect: |
|
606 case ECmManagerUiCmdCmAdd: |
|
607 { |
|
608 if ( !iProcessing ) |
|
609 { |
|
610 iProcessing = ETrue; |
|
611 ProcessCommandL( ECmManagerUiCmdDestEdit ); |
|
612 iProcessing = EFalse; |
|
613 } |
|
614 break; |
|
615 } |
|
616 case EAknSoftkeyBack: |
|
617 { |
|
618 if (!iProcessing) |
|
619 { |
|
620 *iExiting = EFalse; |
|
621 iExitReason = KDialogUserBack; |
|
622 retval = ETrue; |
|
623 } |
|
624 break; |
|
625 } |
|
626 case EAknSoftkeyOptions: |
|
627 { |
|
628 if ( !iProcessing ) |
|
629 { |
|
630 DisplayMenuL(); |
|
631 } |
|
632 break; |
|
633 } |
|
634 default: |
|
635 { |
|
636 |
|
637 CLOG_WRITE_1( "CDestDlg::OkToExitL: High level stop %d", aButtonId ); |
|
638 |
|
639 *iExiting = ETrue; |
|
640 retval = ETrue; |
|
641 break; |
|
642 } |
|
643 } |
|
644 return retval; |
|
645 } |
|
646 |
|
647 // --------------------------------------------------------------------------- |
|
648 // CDestDlg::HandleListBoxEventL |
|
649 // --------------------------------------------------------------------------- |
|
650 void CDestDlg::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
651 TListBoxEvent aEventType ) |
|
652 { |
|
653 LOGGER_ENTERFN( "CDestDlg::HandleListBoxEventL" ); |
|
654 |
|
655 switch ( aEventType ) |
|
656 { |
|
657 case EEventEnterKeyPressed: |
|
658 case EEventItemSingleClicked: |
|
659 { |
|
660 if ( !iProcessing ) |
|
661 { |
|
662 iCmdExec->Execute(); |
|
663 } |
|
664 break; |
|
665 } |
|
666 case EEventEditingStarted: |
|
667 { |
|
668 break; |
|
669 } |
|
670 case EEventEditingStopped: |
|
671 { |
|
672 break; |
|
673 } |
|
674 default: |
|
675 { |
|
676 break; |
|
677 }; |
|
678 }; |
|
679 } |
|
680 |
|
681 // ---------------------------------------------------------------------------- |
|
682 // CDestDlg::HandleListboxDataChangeL |
|
683 // called before the dialog is shown to initialize listbox data |
|
684 // ---------------------------------------------------------------------------- |
|
685 // |
|
686 void CDestDlg::HandleListboxDataChangeL() |
|
687 { |
|
688 LOGGER_ENTERFN( "CDestDlg::HandleListboxDataChangeL" ); |
|
689 |
|
690 iCmManagerImpl->OpenTransactionLC(); |
|
691 |
|
692 iModel->ResetAndDestroy(); |
|
693 RArray<TUint32> destIdArray = RArray<TUint32>( KCmArrayBigGranularity ); |
|
694 |
|
695 CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KGranularity ); |
|
696 CleanupStack::PushL( icons ); |
|
697 |
|
698 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
699 |
|
700 iCmManagerImpl->AllDestinationsL(destIdArray); |
|
701 |
|
702 // Append the destinations to the list |
|
703 CleanupClosePushL( destIdArray ); // 1 |
|
704 |
|
705 TCmDefConnValue defConnSel; |
|
706 defConnSel.iType = ECmDefConnAlwaysAsk;//default value |
|
707 if ( iCmManagerImpl->IsDefConnSupported() ) |
|
708 { |
|
709 //refresh default connection in navi pane |
|
710 iCmManagerImpl->ReadDefConnL(defConnSel); |
|
711 SetDefaultNaviL( defConnSel ); |
|
712 } |
|
713 else |
|
714 { |
|
715 SetNoOfDestsL( destIdArray.Count() ); |
|
716 } |
|
717 ///!!!TEMP, no icon for add connection yet |
|
718 TParse mbmFile; |
|
719 User::LeaveIfError( mbmFile.Set( KManagerIconFilename, |
|
720 &KDC_APP_BITMAP_DIR, |
|
721 NULL ) ); |
|
722 |
|
723 CGulIcon* icon = AknsUtils::CreateGulIconL( //second, KDestReservedIconIndexProtected |
|
724 skinInstance, |
|
725 KAknsIIDQgnPropSetConnDestAdd, |
|
726 mbmFile.FullName(), |
|
727 EMbmCmmanagerQgn_prop_set_conn_dest_add, |
|
728 EMbmCmmanagerQgn_prop_set_conn_dest_add_mask ); |
|
729 CleanupStack::PushL( icon ); |
|
730 icons->AppendL( icon ); |
|
731 CleanupStack::Pop( icon ); |
|
732 |
|
733 icon = AknsUtils::CreateGulIconL( //second, KDestReservedIconIndexProtected |
|
734 skinInstance, |
|
735 KAknsIIDQgnIndiSettProtectedAdd, |
|
736 mbmFile.FullName(), |
|
737 EMbmCmmanagerQgn_indi_sett_protected_add, |
|
738 EMbmCmmanagerQgn_indi_sett_protected_add_mask ); |
|
739 |
|
740 |
|
741 // Previous must me changed to following if any problems with theme colours |
|
742 /* AknsUtils::CreateColorIconLC( skinInstance, |
|
743 KAknsIIDQgnIndiSettProtectedAdd, |
|
744 KAknsIIDQsnIconColors, |
|
745 EAknsCIQsnIconColorsCG13, |
|
746 bitmap, |
|
747 mask, |
|
748 mbmFile.FullName(), |
|
749 EMbmCmmanagerQgn_indi_sett_protected_add, |
|
750 EMbmCmmanagerQgn_indi_sett_protected_add_mask, |
|
751 AKN_LAF_COLOR( 215 ) ); |
|
752 |
|
753 icon = CGulIcon::NewL( bitmap, mask ); // Ownership transferred |
|
754 CleanupStack::Pop( 2 ); // bitmap, mask*/ |
|
755 |
|
756 CleanupStack::PushL( icon ); |
|
757 icons->AppendL( icon ); |
|
758 CleanupStack::Pop( icon ); |
|
759 |
|
760 //third, uncategorized KDestReservedIconIndexUncategorized |
|
761 icons->AppendL( iCmManagerImpl->UncategorizedIconL() ); |
|
762 |
|
763 //0..3 are reserved indexes! |
|
764 CFbsBitmap* bitmap = NULL; |
|
765 CFbsBitmap* mask = NULL; |
|
766 |
|
767 AknsUtils::CreateColorIconLC( skinInstance, |
|
768 KAknsIIDQgnIndiDefaultConnAdd, |
|
769 KAknsIIDQsnIconColors, |
|
770 EAknsCIQsnIconColorsCG13, |
|
771 bitmap, |
|
772 mask, |
|
773 mbmFile.FullName(), |
|
774 EMbmCmmanagerQgn_indi_default_conn_add, |
|
775 EMbmCmmanagerQgn_indi_default_conn_add_mask, |
|
776 AKN_LAF_COLOR( 215 ) ); |
|
777 |
|
778 icon = CGulIcon::NewL( bitmap, mask ); // Ownership transferred |
|
779 CleanupStack::Pop( 2 ); // bitmap, mask |
|
780 |
|
781 CleanupStack::PushL( icon ); |
|
782 icons->AppendL( icon ); |
|
783 CleanupStack::Pop( icon ); |
|
784 |
|
785 // Add the New Connection Item |
|
786 HBufC* newConnection = StringLoader::LoadLC( |
|
787 R_CMMANAGERUI_NEW_CONNECTION ); // 2 |
|
788 |
|
789 CDestListItem* newConnItem = |
|
790 CDestListItem::NewLC( |
|
791 KDestItemNewConnection, |
|
792 newConnection, |
|
793 0, |
|
794 KDestReservedIconIndexNewConn, EProtLevel0, EFalse ); // 3 |
|
795 iModel->AppendL( newConnItem ); // ownership relinquished |
|
796 CleanupStack::Pop( newConnItem ); |
|
797 CleanupStack::Pop( newConnection ); |
|
798 |
|
799 TTime destTime; |
|
800 |
|
801 //refresh default connection icon in list - no effect if feature flag is off (defConnSel |
|
802 // is ECmDefConnAlwaysAsk) |
|
803 TInt defUid = KErrNotFound; |
|
804 if ( defConnSel.iType == ECmDefConnDestination ) |
|
805 { |
|
806 defUid = defConnSel.iId; |
|
807 } |
|
808 |
|
809 |
|
810 for (TInt i = 0; i < destIdArray.Count(); i++) |
|
811 { |
|
812 // Get the destinations from their IDs |
|
813 CCmDestinationImpl* dest = NULL; |
|
814 |
|
815 |
|
816 TRAPD( err, dest = iCmManagerImpl->DestinationL( destIdArray[i] ) ); |
|
817 if( err ) |
|
818 { |
|
819 continue; |
|
820 } |
|
821 CleanupStack::PushL( dest ); |
|
822 |
|
823 // Check whether the MMS SNAP is in question. |
|
824 // It should not be shown on the UI in the destinations list |
|
825 TInt snapMetadata = 0; |
|
826 TRAPD(metaErr, snapMetadata = dest->MetadataL( CMManager::ESnapMetadataPurpose )); |
|
827 if ( metaErr == KErrNone && snapMetadata == CMManager::ESnapPurposeMMS ) |
|
828 { |
|
829 // This is the MMS SNAP, skip this item |
|
830 if( dest ) |
|
831 { |
|
832 CleanupStack::PopAndDestroy( dest ); |
|
833 dest = NULL; |
|
834 } |
|
835 continue; |
|
836 } |
|
837 |
|
838 // Also hidden destinations are shown (TSW id ERUN-79KFAK) |
|
839 icons->AppendL( dest->IconL() ); |
|
840 HBufC* name = dest->NameLC(); // 3 |
|
841 TBool def = EFalse; |
|
842 if ( defUid == dest->Id() ) //this is the default destination, indicate it! |
|
843 { |
|
844 def = ETrue; |
|
845 } |
|
846 |
|
847 // The connection methods bound to this destination may have to be checked with |
|
848 // validity. Some connection methods might be invalid. |
|
849 TInt numOfCms = dest->ConnectionMethodCount(); |
|
850 if (numOfCms > 0) |
|
851 { |
|
852 RArray<TUint32> cmIds; |
|
853 dest->ConnectMethodIdArrayL( cmIds ); |
|
854 CleanupClosePushL( cmIds ); |
|
855 |
|
856 for ( TInt j = 0; j < cmIds.Count(); j++ ) |
|
857 { |
|
858 TUint recId = cmIds[j]; |
|
859 |
|
860 TRAP( err, TUint32 bearerType = iCmManagerImpl->BearerTypeFromCmIdL( recId ) ); |
|
861 if( err == KErrNotSupported ) |
|
862 { |
|
863 CLOG_WRITE_1( "CDestDlg::HandleListboxDataChangeL, IAP(%d) unsupported", recId ); |
|
864 numOfCms = numOfCms -1; |
|
865 } |
|
866 } |
|
867 |
|
868 CleanupStack::PopAndDestroy( &cmIds ); |
|
869 } |
|
870 |
|
871 CDestListItem* item = CDestListItem::NewLC( |
|
872 dest->Id(), |
|
873 name, |
|
874 numOfCms, |
|
875 icons->Count()-1, dest->ProtectionLevel(), def ); // 4 |
|
876 iModel->AppendL( item ); // ownership passed |
|
877 CleanupStack::Pop( item ); |
|
878 CleanupStack::Pop( name ); |
|
879 if( dest ) |
|
880 { |
|
881 CleanupStack::PopAndDestroy( dest ); |
|
882 dest = NULL; |
|
883 } |
|
884 } |
|
885 |
|
886 // Add the Uncategorised Item |
|
887 RArray<TUint32> uncatArray(KCmArraySmallGranularity); |
|
888 CleanupClosePushL(uncatArray); |
|
889 |
|
890 iCmManagerImpl->ConnectionMethodL( uncatArray, ETrue ); |
|
891 TUint32 numberOfCMs = NumberOfCMsL( uncatArray ); |
|
892 if ( numberOfCMs ) |
|
893 { |
|
894 icon = AknsUtils::CreateGulIconL( |
|
895 skinInstance, |
|
896 KAknsIIDQgnPropSetConnDestUncategorized, |
|
897 mbmFile.FullName(), |
|
898 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized, |
|
899 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized_mask ); |
|
900 CleanupStack::PushL( icon ); |
|
901 icons->AppendL( icon ); |
|
902 CleanupStack::Pop( icon ); |
|
903 |
|
904 HBufC* uncat = StringLoader::LoadLC( |
|
905 R_CMMANAGERUI_DEST_UNCATEGORIZED ); // 2 |
|
906 |
|
907 // Check the hidden connection methods |
|
908 for ( TInt k = 0; k < uncatArray.Count(); k++ ) |
|
909 { |
|
910 TUint recId = uncatArray[k]; |
|
911 if ( iCmManagerImpl->GetConnectionMethodInfoBoolL( recId, ECmHidden ) ) |
|
912 { |
|
913 numberOfCMs = numberOfCMs -1; |
|
914 } |
|
915 } |
|
916 |
|
917 CDestListItem* uncatItem = |
|
918 CDestListItem::NewLC( |
|
919 KDestItemUncategorized, |
|
920 uncat, |
|
921 numberOfCMs, |
|
922 icons->Count()-1, EProtLevel0, EFalse ); // 3 |
|
923 iModel->AppendL( uncatItem ); // ownership relinquished |
|
924 CleanupStack::Pop( uncatItem ); |
|
925 CleanupStack::Pop( uncat ); |
|
926 } |
|
927 |
|
928 CleanupStack::PopAndDestroy( 2, &destIdArray ); // destIdArray |
|
929 |
|
930 CArrayPtr<CGulIcon>* oldIcons = |
|
931 iListbox->ItemDrawer()->ColumnData()->IconArray(); |
|
932 if( oldIcons ) |
|
933 { |
|
934 oldIcons->ResetAndDestroy(); |
|
935 delete oldIcons; |
|
936 } |
|
937 |
|
938 iListbox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
939 iListbox->HandleItemAdditionL(); |
|
940 iListbox->UpdateScrollBarsL(); |
|
941 |
|
942 if ( !iListbox->CurrentItemUid() && !numberOfCMs ) |
|
943 { |
|
944 // selection is out of range (e.g. Uncategorized deleted) |
|
945 iListbox->SetCurrentItemIndexAndDraw( 0 ); |
|
946 } |
|
947 |
|
948 CleanupStack::Pop( icons ); |
|
949 |
|
950 iCmManagerImpl->RollbackTransaction(); |
|
951 } |
|
952 |
|
953 // ---------------------------------------------------------------------------- |
|
954 // CDestDlg::NumberOfCMsL |
|
955 // ---------------------------------------------------------------------------- |
|
956 // |
|
957 TUint32 CDestDlg::NumberOfCMsL(RArray<TUint32> cmArray) |
|
958 { |
|
959 LOGGER_ENTERFN( "CDestDlg::NumberOfCMsL" ); |
|
960 |
|
961 TUint32 cmCount = cmArray.Count(); |
|
962 TUint32 retValue = cmArray.Count(); |
|
963 CCDIAPRecord* iapRecord = NULL; |
|
964 for ( TInt i = 0; i < cmCount; i++ ) |
|
965 { |
|
966 if ( cmArray[i] <= 255 )// not embedded destination |
|
967 { |
|
968 iapRecord = static_cast<CCDIAPRecord *> |
|
969 (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
970 CleanupStack::PushL( iapRecord ); |
|
971 |
|
972 iapRecord->SetRecordId( cmArray[i] ); |
|
973 iapRecord->LoadL( iCmManagerImpl->Session() ); |
|
974 |
|
975 TRAPD( err, iCmManagerImpl->BearerTypeFromIapRecordL( iapRecord ) ); |
|
976 |
|
977 if( err == KErrNotSupported ) |
|
978 // This is unsupported connection method -> don't display |
|
979 { |
|
980 retValue--; |
|
981 } |
|
982 else |
|
983 { |
|
984 User::LeaveIfError( err ); |
|
985 } |
|
986 CleanupStack::PopAndDestroy( iapRecord ); |
|
987 } |
|
988 } |
|
989 return retValue; |
|
990 } |
|
991 |
|
992 // ---------------------------------------------------------------------------- |
|
993 // CDestDlg::AddDestinationL |
|
994 // ---------------------------------------------------------------------------- |
|
995 // |
|
996 void CDestDlg::AddDestinationL() |
|
997 { |
|
998 LOGGER_ENTERFN( "CDestDlg::AddDestinationL" ); |
|
999 |
|
1000 TBuf<KDestinationNameMaxLength> destName; |
|
1001 |
|
1002 TBool okToAdd = EFalse; |
|
1003 TBool nameAccepted = ETrue; |
|
1004 do |
|
1005 { |
|
1006 okToAdd = TCmCommonUi::ShowConfirmationQueryWithInputL( |
|
1007 R_CMMANAGERUI_PRMPT_DESTINATION_NAME, |
|
1008 destName ); |
|
1009 if ( okToAdd ) |
|
1010 { |
|
1011 CCmDestinationImpl* dest = NULL; |
|
1012 |
|
1013 TRAPD(err, dest = iCmManagerImpl->CreateDestinationL( destName ) ); |
|
1014 if ( err == KErrAlreadyExists ) |
|
1015 { |
|
1016 nameAccepted = EFalse; |
|
1017 TCmCommonUi::ShowNoteL |
|
1018 ( R_CMMANAGERUI_INFO_DEST_ALREADY_IN_USE, |
|
1019 destName, |
|
1020 TCmCommonUi::ECmErrorNote ); |
|
1021 } |
|
1022 else if ( err == KErrDiskFull ) |
|
1023 { |
|
1024 CTextResolver* iTextResolver = CTextResolver::NewLC(*iCoeEnv); |
|
1025 okToAdd = EFalse; |
|
1026 TPtrC buf; |
|
1027 buf.Set(iTextResolver->ResolveErrorString(err)); |
|
1028 TCmCommonUi::ShowNoteL( buf, TCmCommonUi::ECmErrorNote ); |
|
1029 CleanupStack::PopAndDestroy( iTextResolver ); |
|
1030 } |
|
1031 else if ( err == KErrNone ) |
|
1032 { |
|
1033 CleanupStack::PushL( dest ); |
|
1034 nameAccepted = ETrue; |
|
1035 TInt index = 0; |
|
1036 TInt iconSelected = 0; |
|
1037 CCmDestinationIconDialog* popup = |
|
1038 new (ELeave) CCmDestinationIconDialog( iconSelected ); |
|
1039 |
|
1040 // Show the icon dialogs |
|
1041 if ( popup->ExecuteLD() ) |
|
1042 { |
|
1043 index = iconSelected; |
|
1044 |
|
1045 dest->SetIconL( index ); // subclass implements |
|
1046 //dest->UpdateL(); |
|
1047 TRAPD( err, dest->UpdateL() ); |
|
1048 if( err ) |
|
1049 { |
|
1050 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1051 TCmCommonUi::ECmErrorNote ); |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 TRAP( err, HandleListboxDataChangeL() ); |
|
1056 if ( err ) |
|
1057 { |
|
1058 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1059 TCmCommonUi::ECmErrorNote ); |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 CDestListboxModel* lbmodel = |
|
1064 STATIC_CAST( CDestListboxModel*, |
|
1065 iListbox->Model()->ItemTextArray() ); |
|
1066 CDestListItem* lbitem = |
|
1067 lbmodel->At( lbmodel->MdcaCount() - 1 ); |
|
1068 |
|
1069 //returns null if item is not present |
|
1070 if ( lbitem->Uid() == KDestItemUncategorized ) |
|
1071 { |
|
1072 //last item is uncategorized |
|
1073 iListbox->ScrollToMakeItemVisible( |
|
1074 lbmodel->MdcaCount() - 2 ); |
|
1075 //last item is uncategorized |
|
1076 iListbox->SetCurrentItemIndexAndDraw( |
|
1077 lbmodel->MdcaCount() - 2 ); |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 iListbox->ScrollToMakeItemVisible( |
|
1082 lbmodel->MdcaCount() - 1 ); |
|
1083 iListbox->SetCurrentItemIndexAndDraw( |
|
1084 lbmodel->MdcaCount() - 1 ); |
|
1085 } |
|
1086 |
|
1087 iListbox->HandleItemAdditionL(); |
|
1088 |
|
1089 // Sets the mittle soft key text to "Open" |
|
1090 SetMskL( R_QTN_MSK_OPEN ); |
|
1091 |
|
1092 } |
|
1093 if(dest) |
|
1094 { |
|
1095 CleanupStack::PopAndDestroy( dest ); |
|
1096 dest = NULL; |
|
1097 } |
|
1098 } |
|
1099 } |
|
1100 } while ( !nameAccepted && okToAdd ); |
|
1101 } |
|
1102 |
|
1103 // ---------------------------------------------------------------------------- |
|
1104 // CDestDlg::OnCommandDestinationEdit |
|
1105 // ---------------------------------------------------------------------------- |
|
1106 // |
|
1107 void CDestDlg::OnCommandDestinationEditL() |
|
1108 { |
|
1109 LOGGER_ENTERFN( "CDestDlg::OnCommandDestinationEditL" ); |
|
1110 |
|
1111 // Check if memory full |
|
1112 TBool ret ( EFalse ); |
|
1113 ret = iCmManagerImpl->IsMemoryLow(); |
|
1114 if( ret ) |
|
1115 { |
|
1116 CLOG_WRITE( "CDestDlg::OnCommandDestinationEditL: Memory Full, return!" ); |
|
1117 return; |
|
1118 } |
|
1119 |
|
1120 if ( iListbox->CurrentItemUid() == KDestItemNewConnection ) |
|
1121 { |
|
1122 // If there's at least one uprotected destination available |
|
1123 if ( iCmManagerImpl->DestinationCountL() ) |
|
1124 { |
|
1125 if ( iCmManagerImpl->HasUnprotectedDestinationsL() ) |
|
1126 { |
|
1127 // Opens a Connection method creation wizard |
|
1128 CLOG_WRITE( "CDestDlg::OnCommandDestinationEditL iCmWizard constructing" ); |
|
1129 iCmWizard = new (ELeave) CCmWizard( *iCmManagerImpl ); |
|
1130 TInt ret( KErrNone ); |
|
1131 TRAPD( err, ret = iCmWizard->CreateConnectionMethodL() ); |
|
1132 if ( err == KErrDiskFull ) |
|
1133 { |
|
1134 CTextResolver* iTextResolver = CTextResolver::NewLC(*iCoeEnv); |
|
1135 ret = KErrCancel; |
|
1136 TPtrC buf; |
|
1137 buf.Set(iTextResolver->ResolveErrorString(err)); |
|
1138 TCmCommonUi::ShowNoteL( buf, TCmCommonUi::ECmErrorNote ); |
|
1139 CleanupStack::PopAndDestroy( iTextResolver ); |
|
1140 } |
|
1141 else if ( err ) |
|
1142 { |
|
1143 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1144 TCmCommonUi::ECmErrorNote ); |
|
1145 ret = KErrCancel; |
|
1146 } |
|
1147 delete iCmWizard; |
|
1148 iCmWizard = NULL; |
|
1149 CLOG_WRITE_1( "CDestDlg::iCmWizard ret %d", ret ); |
|
1150 |
|
1151 // If application wanted to be closed before then RunAppShutter() |
|
1152 // should be called here |
|
1153 if( iEscapeArrived ) |
|
1154 { |
|
1155 CLOG_WRITE_1( "CDestDlg::iEscapeArrived %d", iEscapeArrived ); |
|
1156 ( ( CAknAppUi* )iEikonEnv->EikAppUi() )->RunAppShutter(); |
|
1157 } |
|
1158 else |
|
1159 { |
|
1160 if( ret != KErrCancel ) |
|
1161 { |
|
1162 TRAP( err, HandleListboxDataChangeL() ); |
|
1163 if ( err ) |
|
1164 { |
|
1165 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1166 TCmCommonUi::ECmErrorNote ); |
|
1167 return; |
|
1168 } |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 // Show a warning here |
|
1176 TCmCommonUi::ShowNoteL( R_CMWIZARD_NO_UNPROTECTED_DESTINATION, |
|
1177 TCmCommonUi::ECmWarningNote ); |
|
1178 } |
|
1179 } |
|
1180 else |
|
1181 { |
|
1182 // ... otherwise show a warning. |
|
1183 TCmCommonUi::ShowNoteL( R_CMWIZARD_NO_DESTINATION, |
|
1184 TCmCommonUi::ECmWarningNote ); |
|
1185 } |
|
1186 } |
|
1187 else |
|
1188 { |
|
1189 if ( iListbox->CurrentItemUid() == KDestItemUncategorized ) |
|
1190 { |
|
1191 CUncatDlg* uncatDlg = CUncatDlg::NewL( iCmManagerImpl ); |
|
1192 |
|
1193 TUint32 selected = 0; |
|
1194 if ( uncatDlg->ConstructAndRunLD( 0, selected ) == |
|
1195 KDialogUserExit) |
|
1196 { |
|
1197 TryExitL(ETrue); |
|
1198 } |
|
1199 else |
|
1200 { |
|
1201 HandleListboxDataChangeL(); |
|
1202 } |
|
1203 } |
|
1204 else |
|
1205 { |
|
1206 CCmDlg* cmDlg = CCmDlg::NewL( iCmManagerImpl , |
|
1207 iListbox->CurrentItemUid(), this ); |
|
1208 |
|
1209 TUint32 selected = 0; |
|
1210 if ( cmDlg->ConstructAndRunLD( 0, selected ) == |
|
1211 KDialogUserExit ) |
|
1212 { |
|
1213 TryExitL(ETrue); |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 HandleListboxDataChangeL(); |
|
1218 } |
|
1219 } |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 // ---------------------------------------------------------------------------- |
|
1224 // CDestDlg::OnCommandDestinationDelete |
|
1225 // ---------------------------------------------------------------------------- |
|
1226 // |
|
1227 void CDestDlg::OnCommandDestinationDeleteL() |
|
1228 { |
|
1229 LOGGER_ENTERFN( "CDestDlg::OnCommandDestinationDeleteL" ); |
|
1230 |
|
1231 TCmDefConnValue oldConn; |
|
1232 if (iCmManagerImpl->IsDefConnSupported()) |
|
1233 { |
|
1234 iCmManagerImpl->ReadDefConnL( oldConn ); |
|
1235 } |
|
1236 TUint32 listItemUid = iListbox->CurrentItemUid(); |
|
1237 |
|
1238 if ( listItemUid == KDestItemNewConnection ) |
|
1239 { |
|
1240 // ignore this command - it's not a destination |
|
1241 return; |
|
1242 } |
|
1243 |
|
1244 if ( listItemUid == KDestItemUncategorized ) |
|
1245 { |
|
1246 // Cannot delete Uncategoried Destination |
|
1247 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1248 TCmCommonUi::ECmErrorNote ); |
|
1249 |
|
1250 return; |
|
1251 } |
|
1252 |
|
1253 TBool carryOn( ETrue ); |
|
1254 // Cannot delete if the destination is embedded somewhere |
|
1255 CCmDestinationImpl* dest = |
|
1256 iCmManagerImpl->DestinationL( iListbox->CurrentItemUid() ); |
|
1257 CleanupStack::PushL( dest ); |
|
1258 // We need this trap only because this function is called from a trap |
|
1259 TRAPD( err, dest->CheckIfEmbeddedL( dest->Id() ) ); |
|
1260 if ( err == KErrNotSupported ) |
|
1261 { |
|
1262 CleanupStack::PopAndDestroy( dest ); |
|
1263 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1264 TCmCommonUi::ECmErrorNote ); |
|
1265 return; |
|
1266 } |
|
1267 else if ( err ) |
|
1268 { |
|
1269 CleanupStack::PopAndDestroy( dest ); |
|
1270 User::Leave(err); |
|
1271 } |
|
1272 |
|
1273 // Show an error message to the user |
|
1274 if ( dest->ProtectionLevel() ) |
|
1275 { |
|
1276 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1277 TCmCommonUi::ECmErrorNote ); |
|
1278 carryOn = EFalse; |
|
1279 } |
|
1280 |
|
1281 if( carryOn ) |
|
1282 { |
|
1283 if( dest->IsConnectedL() ) |
|
1284 { |
|
1285 TCmCommonUi::ShowNoteL( |
|
1286 R_CMMANAGERUI_INFO_DEST_IN_USE_CANNOT_DELETE, |
|
1287 TCmCommonUi::ECmErrorNote ); |
|
1288 carryOn = EFalse; |
|
1289 } |
|
1290 } |
|
1291 |
|
1292 // check if it is linked by anybody |
|
1293 |
|
1294 if ( carryOn ) |
|
1295 { |
|
1296 // for each IAP in CM manager |
|
1297 // 1. check if it is virtual |
|
1298 // if not => goto 1. |
|
1299 // if yes: |
|
1300 // 2. check if it links to the destination to be deleted |
|
1301 // if yes => carryOn = EFalse, ERROR |
|
1302 // if not: |
|
1303 // 3. check if it links to any of the CMs in this destination |
|
1304 // if not => goto 1. |
|
1305 // if yes: |
|
1306 // 4. check if it is also in this destination |
|
1307 // if not => carryOn = EFalse, ERROR |
|
1308 // if yes => goto 1. |
|
1309 // As we need different notes in different cases: |
|
1310 TUint32 noteresId = R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED; |
|
1311 CommsDat::CMDBRecordSet<CommsDat::CCDIAPRecord>* iaps = |
|
1312 iCmManagerImpl->AllIapsL(); |
|
1313 |
|
1314 CleanupStack::PushL( iaps ); |
|
1315 |
|
1316 // for each IAP in CM manager |
|
1317 for ( TInt i = 0; carryOn && i < iaps->iRecords.Count(); ++i ) |
|
1318 { |
|
1319 CommsDat::CCDIAPRecord* rec = (*iaps)[i]; |
|
1320 TUint32 bearerType = 0; |
|
1321 |
|
1322 TRAP_IGNORE( bearerType = |
|
1323 iCmManagerImpl->BearerTypeFromIapRecordL( rec ) ); |
|
1324 if ( !bearerType ) |
|
1325 { |
|
1326 continue; |
|
1327 } |
|
1328 |
|
1329 // check if it is virtual |
|
1330 if ( iCmManagerImpl->GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1331 { |
|
1332 // check if it links to the destination to be deleted |
|
1333 CCmPluginBase* plugin = NULL; |
|
1334 TRAP_IGNORE( plugin = iCmManagerImpl->GetConnectionMethodL( |
|
1335 rec->RecordId() ) ); |
|
1336 |
|
1337 if ( !plugin ) |
|
1338 { |
|
1339 continue; |
|
1340 } |
|
1341 |
|
1342 CleanupStack::PushL( plugin ); |
|
1343 |
|
1344 if ( plugin->IsLinkedToSnap( dest->Id() ) ) |
|
1345 { |
|
1346 // the CM links to this destination, deletion not allowed |
|
1347 carryOn = EFalse; |
|
1348 noteresId = R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED; |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 |
|
1353 // check if the CM links to any of the CMs in this destination |
|
1354 for ( TInt j = 0; j < dest->ConnectionMethodCount(); ++j ) |
|
1355 { |
|
1356 CCmPluginBase* destPlugin = NULL; |
|
1357 |
|
1358 TRAP_IGNORE( destPlugin = dest->GetConnectionMethodL( j ) ); |
|
1359 if ( !destPlugin ) |
|
1360 { |
|
1361 continue; |
|
1362 } |
|
1363 |
|
1364 if ( destPlugin->GetIntAttributeL( ECmId ) == |
|
1365 rec->RecordId() ) |
|
1366 { |
|
1367 // the CM shouldn't be compared to itself |
|
1368 continue; |
|
1369 } |
|
1370 |
|
1371 if ( plugin->IsLinkedToIap( |
|
1372 destPlugin->GetIntAttributeL( ECmId ) ) ) |
|
1373 { |
|
1374 // the CM links to at least one CM in this destination |
|
1375 carryOn = EFalse; |
|
1376 noteresId = R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF; |
|
1377 break; |
|
1378 } |
|
1379 } |
|
1380 |
|
1381 } |
|
1382 |
|
1383 CleanupStack::PopAndDestroy( plugin ); |
|
1384 } |
|
1385 |
|
1386 |
|
1387 } |
|
1388 |
|
1389 CleanupStack::PopAndDestroy( iaps ); |
|
1390 |
|
1391 if ( !carryOn ) |
|
1392 { |
|
1393 TCmCommonUi::ShowNoteL( |
|
1394 noteresId, |
|
1395 TCmCommonUi::ECmErrorNote ); |
|
1396 } |
|
1397 } |
|
1398 |
|
1399 |
|
1400 // check if it has protected method |
|
1401 if( carryOn ) |
|
1402 { |
|
1403 if( IsThereProtectedMethodL( dest ) ) |
|
1404 { |
|
1405 TCmCommonUi::ShowNoteL( |
|
1406 R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_DEST_PROT_CM, |
|
1407 TCmCommonUi::ECmErrorNote ); |
|
1408 carryOn = EFalse; |
|
1409 } |
|
1410 } |
|
1411 |
|
1412 if( carryOn ) |
|
1413 { |
|
1414 HBufC* destName = dest->NameLC(); // 2 |
|
1415 if ( TCmCommonUi::ShowConfirmationQueryL( |
|
1416 R_CMMANAGERUI_QUEST_DEST_DELETE, *destName ) ) |
|
1417 { |
|
1418 CleanupStack::PopAndDestroy( destName ); |
|
1419 TRAPD( err, dest->DeleteLD() ); |
|
1420 switch ( err ) |
|
1421 { |
|
1422 case KErrInUse: |
|
1423 { |
|
1424 TCmCommonUi::ShowNoteL( |
|
1425 R_CMMANAGERUI_INFO_DEST_IN_USE_CANNOT_DELETE, |
|
1426 TCmCommonUi::ECmErrorNote ); |
|
1427 } |
|
1428 break; |
|
1429 |
|
1430 case KErrLocked: |
|
1431 { |
|
1432 TCmCommonUi::ShowNoteL |
|
1433 ( R_QTN_NETW_CONSET_INFO_CANNOT_DELETE_VIRTUAL_REF, |
|
1434 TCmCommonUi::ECmErrorNote ); |
|
1435 } |
|
1436 break; |
|
1437 |
|
1438 case KErrNone: |
|
1439 { |
|
1440 if (iCmManagerImpl->IsDefConnSupported()) |
|
1441 { |
|
1442 ShowDefaultConnectionNoteL(oldConn); |
|
1443 } |
|
1444 CleanupStack::Pop( dest ); |
|
1445 dest = NULL; |
|
1446 |
|
1447 TInt selected = iListbox->CurrentItemIndex(); |
|
1448 |
|
1449 HandleListboxDataChangeL(); |
|
1450 |
|
1451 if ( iListbox->Model()->NumberOfItems() ) |
|
1452 { |
|
1453 if( selected == iListbox->Model()->NumberOfItems() ) |
|
1454 { |
|
1455 --selected; |
|
1456 } |
|
1457 |
|
1458 //first item cannot be deleted |
|
1459 iListbox->ScrollToMakeItemVisible( selected); |
|
1460 iListbox->SetCurrentItemIndexAndDraw( selected ); |
|
1461 } |
|
1462 } |
|
1463 break; |
|
1464 |
|
1465 default: |
|
1466 { |
|
1467 } |
|
1468 } |
|
1469 } |
|
1470 else |
|
1471 { |
|
1472 CleanupStack::PopAndDestroy( destName ); |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 if( dest ) |
|
1477 { |
|
1478 CleanupStack::PopAndDestroy( dest ); |
|
1479 } |
|
1480 |
|
1481 } |
|
1482 |
|
1483 |
|
1484 // ---------------------------------------------------------------------------- |
|
1485 // CDestDlg::OnCommandDestinationRenameL |
|
1486 // ---------------------------------------------------------------------------- |
|
1487 // |
|
1488 void CDestDlg::OnCommandDestinationRenameL() |
|
1489 { |
|
1490 LOGGER_ENTERFN( "CDestDlg::OnCommandDestinationRenameL" ); |
|
1491 |
|
1492 // Check if this is UnCat |
|
1493 if ( iListbox->CurrentItemUid() == KDestItemUncategorized ) |
|
1494 { |
|
1495 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1496 TCmCommonUi::ECmErrorNote ); |
|
1497 return; |
|
1498 } |
|
1499 |
|
1500 // Get currently selected destination. |
|
1501 CCmDestinationImpl* dest = |
|
1502 iCmManagerImpl->DestinationL( iListbox->CurrentItemUid() ); |
|
1503 CleanupStack::PushL( dest ); |
|
1504 |
|
1505 // Show an error message to the user |
|
1506 if ( dest->ProtectionLevel() ) |
|
1507 { |
|
1508 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
1509 TCmCommonUi::ECmErrorNote ); |
|
1510 |
|
1511 CleanupStack::PopAndDestroy( dest ); |
|
1512 return; |
|
1513 } |
|
1514 |
|
1515 // Allocate max length for the buffer, since we don't know how long |
|
1516 // the new name will be. Copy the actual name of the destination |
|
1517 // into the buffer. |
|
1518 TBuf< KDestinationNameMaxLength > destName; |
|
1519 destName.Copy( *( dest->NameLC() ) ); |
|
1520 |
|
1521 TBool okToRename = EFalse; |
|
1522 TBool nameAccepted = ETrue; |
|
1523 do |
|
1524 { |
|
1525 okToRename = TCmCommonUi::ShowConfirmationQueryWithInputL( |
|
1526 R_CMMANAGERUI_PRMPT_DESTINATION_NAME, |
|
1527 destName ); |
|
1528 if ( okToRename ) |
|
1529 { |
|
1530 TRAPD(err, dest->SetNameL( destName )); |
|
1531 if ( err == KErrAlreadyExists ) |
|
1532 { |
|
1533 nameAccepted = EFalse; |
|
1534 TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_DEST_ALREADY_IN_USE, |
|
1535 destName, |
|
1536 TCmCommonUi::ECmErrorNote ); |
|
1537 } |
|
1538 else if ( err == KErrNone ) |
|
1539 { |
|
1540 nameAccepted = ETrue; |
|
1541 dest->UpdateL(); |
|
1542 HandleListboxDataChangeL(); |
|
1543 } |
|
1544 } |
|
1545 } while ( !nameAccepted && okToRename ); |
|
1546 |
|
1547 // dest->NameLC() |
|
1548 CleanupStack::PopAndDestroy( ); |
|
1549 CleanupStack::PopAndDestroy( dest ); |
|
1550 } |
|
1551 |
|
1552 // ---------------------------------------------------------------------------- |
|
1553 // CDestDlg::IsThereProtectedMethodL |
|
1554 // ---------------------------------------------------------------------------- |
|
1555 // |
|
1556 TBool CDestDlg::IsThereProtectedMethodL( CCmDestinationImpl* aDest ) |
|
1557 { |
|
1558 LOGGER_ENTERFN( "CDestDlg::IsThereProtectedMethodL" ); |
|
1559 |
|
1560 TInt count( aDest->ConnectionMethodCount() ); |
|
1561 |
|
1562 for( TInt i = 0; i < count; ++i ) |
|
1563 { |
|
1564 CCmPluginBase* cm = aDest->GetConnectionMethodL( i ); |
|
1565 |
|
1566 if( cm->GetBoolAttributeL( ECmProtected ) ) |
|
1567 { |
|
1568 return ETrue; |
|
1569 } |
|
1570 } |
|
1571 |
|
1572 return EFalse; |
|
1573 } |
|
1574 |
|
1575 |
|
1576 // ---------------------------------------------------------------------------- |
|
1577 // CDestDlg::SetMskL |
|
1578 // ---------------------------------------------------------------------------- |
|
1579 // |
|
1580 void CDestDlg::SetMskL( TInt aResourceId ) |
|
1581 { |
|
1582 HBufC* text = StringLoader::LoadLC( aResourceId ); |
|
1583 ButtonGroupContainer().SetCommandL( EAknSoftkeySelect, *text ); |
|
1584 ButtonGroupContainer().DrawDeferred(); |
|
1585 CleanupStack::PopAndDestroy( text ); |
|
1586 |
|
1587 } |
|
1588 |
|
1589 // -------------------------------------------------------------------------- |
|
1590 // CDestDlg::GetHelpContext |
|
1591 // -------------------------------------------------------------------------- |
|
1592 // |
|
1593 void CDestDlg::GetHelpContext( TCoeHelpContext& aContext ) const |
|
1594 { |
|
1595 aContext.iMajor = KHelpUidPlugin; |
|
1596 aContext.iContext = KSET_HLP_CONN_DEST_VIEW; |
|
1597 } |
|
1598 |
|
1599 // -------------------------------------------------------------------------- |
|
1600 // CDestDlg::Execute |
|
1601 // -------------------------------------------------------------------------- |
|
1602 // |
|
1603 void CDestDlg::Execute() |
|
1604 { |
|
1605 LOGGER_ENTERFN( "CDestDlg::Execute" ); |
|
1606 iProcessing = ETrue; |
|
1607 |
|
1608 TRAPD( err, ProcessCommandL(ECmManagerUiCmdDestEdit) ); |
|
1609 if ( err ) |
|
1610 { |
|
1611 HandleLeaveError( err ); |
|
1612 } |
|
1613 |
|
1614 iProcessing = EFalse; |
|
1615 } |
|
1616 |
|
1617 // -------------------------------------------------------------------------- |
|
1618 // CDestDlg::HandleResourceChange |
|
1619 // -------------------------------------------------------------------------- |
|
1620 // |
|
1621 |
|
1622 void CDestDlg::HandleResourceChange( TInt aType ) |
|
1623 { |
|
1624 CCoeControl::HandleResourceChange( aType ); |
|
1625 |
|
1626 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
1627 { |
|
1628 DrawNow(); |
|
1629 } |
|
1630 |
|
1631 CAknDialog::HandleResourceChange(aType); |
|
1632 } |
|
1633 |
|
1634 // -------------------------------------------------------------------------- |
|
1635 // CDestDlg::HandleLeaveError |
|
1636 // -------------------------------------------------------------------------- |
|
1637 // |
|
1638 void CDestDlg::HandleLeaveError( TInt aError ) |
|
1639 { |
|
1640 LOGGER_ENTERFN( "CDestDlg::HandleLeaveError" ); |
|
1641 |
|
1642 switch( aError ) |
|
1643 { |
|
1644 case KLeaveWithoutAlert: |
|
1645 case KErrNoMemory: |
|
1646 EnforcedResetCDestDlg(); |
|
1647 break; |
|
1648 default: |
|
1649 // More leave errors may be handled if necessary |
|
1650 // Now other leave errors are ignored here |
|
1651 break; |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 // -------------------------------------------------------------------------- |
|
1656 // CDestDlg::EnforcedResetCDestDlg |
|
1657 // -------------------------------------------------------------------------- |
|
1658 // |
|
1659 void CDestDlg::EnforcedResetCDestDlg() |
|
1660 { |
|
1661 LOGGER_ENTERFN( "CDestDlg::EnforcedResetCDestDlg" ); |
|
1662 |
|
1663 if( iCmWizard != NULL ) |
|
1664 { |
|
1665 delete iCmWizard; |
|
1666 iCmWizard = NULL; |
|
1667 } |
|
1668 |
|
1669 if( iProcessing ) |
|
1670 { |
|
1671 iProcessing = EFalse; |
|
1672 } |
|
1673 } |
|
1674 |
|
1675 // -------------------------------------------------------------------------- |
|
1676 // CDestDlg::ShowDefaultConnectionNoteL |
|
1677 // -------------------------------------------------------------------------- |
|
1678 // |
|
1679 void CDestDlg::ShowDefaultConnectionNoteL(TCmDefConnValue aOldDefConn) |
|
1680 { |
|
1681 LOGGER_ENTERFN( "CDestDlg::ShowDefaultConnectionNoteL" ); |
|
1682 TCmDefConnValue newConn; |
|
1683 |
|
1684 iCmManagerImpl->ReadDefConnL( newConn ); |
|
1685 |
|
1686 if ( newConn != aOldDefConn ) |
|
1687 { |
|
1688 ShowDefaultSetNoteL( newConn ); |
|
1689 } |
|
1690 } |
|
1691 |
|
1692 // -------------------------------------------------------------------------- |
|
1693 // CDestDlg::CommsDatChanges |
|
1694 // -------------------------------------------------------------------------- |
|
1695 // |
|
1696 void CDestDlg::CommsDatChangesL() |
|
1697 { |
|
1698 // Update list box |
|
1699 HandleListboxDataChangeL(); |
|
1700 } |