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