|
1 /* |
|
2 * Copyright (c) 2003 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 displaying servers |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CWVSettingsUIServerListDialog.h" |
|
20 #include "CWVSettingsUI.hrh" |
|
21 #include "CWVSettingsUIServersArray.h" |
|
22 #include "CWVSettingsUIServerSelector.h" |
|
23 #include "MWVSettingsObserverng.h" |
|
24 #include "CWVSettingsUIDialogTitlePaneHandler.h" |
|
25 |
|
26 #include <csxhelp/imng.hlp.hrh> |
|
27 |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <aknlists.h> |
|
30 #include <StringLoader.h> // StringLoader |
|
31 #include <aknquerydialog.h> |
|
32 #include <aknradiobuttonsettingpage.h> |
|
33 #include <aknnotewrappers.h> |
|
34 #include <cimpssapsettingsstore.h> |
|
35 #include <cimpssapsettingslist.h> |
|
36 #include <cimpssapsettings.h> |
|
37 #include <CWVSettingsUIng.rsg> |
|
38 #include <AknIconArray.h> |
|
39 #include <eikapp.h> |
|
40 #include <apsettings.mbg> |
|
41 #include <AknsUtils.h> |
|
42 #include <AknsConstants.h> |
|
43 #include <hlplch.h> |
|
44 #include <featmgr.h> |
|
45 #include <cimpspresenceconnectionuing.h> |
|
46 #include <impspresenceconnectionuiconstsng.h> |
|
47 #include <pathinfo.h> |
|
48 #include <cpengnwsessionslotid2.h> |
|
49 #include "CAExternalInterface.h" |
|
50 #include <CAVariationNG.rsg> |
|
51 #include <BARSREAD.H> |
|
52 #include "VariantKeys.h" |
|
53 |
|
54 //FORWARD DECLARATION |
|
55 class CIMPSSAPSettingsStore; |
|
56 |
|
57 // ================= MEMBER FUNCTIONS ======================= |
|
58 |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // |
|
62 CWVSettingsUIServerListDialog::CWVSettingsUIServerListDialog( |
|
63 CIMPSSAPSettingsStore& aSAPSettingsStore, |
|
64 MWVSettingsObserver& aObserver, |
|
65 CWVSettingsUIDialogTitlePaneHandler& aTitlePaneHandler, |
|
66 CWVSettingsUIDialogImp& aDialog, |
|
67 CIMPSPresenceConnectionUi* aConnectionUi ) |
|
68 : iSAPSettingsStore( &aSAPSettingsStore ), |
|
69 iObserver( &aObserver ), |
|
70 iProtectedServers( 4 ), // granularity = 4, because it's not likely that there are more protected servers |
|
71 iTitlePaneHandler( &aTitlePaneHandler ), |
|
72 iDialog( &aDialog ), |
|
73 iConnectionUI( aConnectionUi ), |
|
74 iEditorActive( EFalse ), |
|
75 iAdded( EFalse ) |
|
76 , iIsOpenedTargettDlg( EFalse ) |
|
77 { |
|
78 } |
|
79 |
|
80 // Destructor |
|
81 CWVSettingsUIServerListDialog::~CWVSettingsUIServerListDialog() |
|
82 { |
|
83 if ( iSAPSettingsStore ) |
|
84 { |
|
85 iSAPSettingsStore->RemoveObserver( this ); |
|
86 } |
|
87 delete iTitle; |
|
88 iProtectedServers.Close(); |
|
89 delete iSAP; |
|
90 if ( iDlgLauncher && iDlgLauncher->IsActive() ) |
|
91 { |
|
92 iDlgLauncher->Cancel(); |
|
93 } |
|
94 delete iDlgLauncher; |
|
95 // to cancel all request when dialog shut |
|
96 CCoeEnv* env = CCoeEnv::Static(); |
|
97 if ( env->IsActive() ) |
|
98 { |
|
99 env->Cancel(); |
|
100 } |
|
101 |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CWVSettingsUIServerListDialog::RefreshTitleL |
|
106 // |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CWVSettingsUIServerListDialog::RefreshTitleL() |
|
111 { |
|
112 if ( !iTitle ) |
|
113 { |
|
114 iTitle = iEikonEnv->AllocReadResourceL( RSC_WVSETTINGSVIEW_SERVERLIST_TITLE ); |
|
115 } |
|
116 |
|
117 iTitlePaneHandler->SetTitlePaneTextL ( *iTitle ); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CWVSettingsUIServerListDialog::DisplayServerEditorDialogL |
|
122 // |
|
123 // (other items were commented in a header). |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 TWVSettingsDialogReturnValue CWVSettingsUIServerListDialog::DisplayServerEditorDialogL( |
|
127 CWVSettingsUIDefineNewServerDialog::TEditMode aEditMode ) |
|
128 { |
|
129 TInt exitReason( 0 ); |
|
130 if ( iSAP ) |
|
131 { |
|
132 iCurrent = iSAP->Uid(); |
|
133 } |
|
134 |
|
135 CWVSettingsUIDefineNewServerDialog* defineNewServerDialog = new ( ELeave ) |
|
136 CWVSettingsUIDefineNewServerDialog( |
|
137 exitReason, |
|
138 *iSAPSettingsStore, |
|
139 aEditMode, |
|
140 *iObserver, |
|
141 *iTitlePaneHandler, |
|
142 iDialog, |
|
143 iNewUid, |
|
144 iConnectionUI, |
|
145 iSAP ); |
|
146 |
|
147 // the ownership of iSAP has now been transferred to define new server dialog |
|
148 iSAP = NULL; |
|
149 |
|
150 CleanupStack::PushL( defineNewServerDialog ); |
|
151 defineNewServerDialog->ConstructL( R_WVSETTINGSVIEW_DEFNEWSERVER_MENUBAR ); |
|
152 CleanupStack::Pop( defineNewServerDialog ); |
|
153 |
|
154 iEditorActive = ETrue; |
|
155 TInt returnValue ( defineNewServerDialog->ExecuteLD( R_WVSETTINGSVIEW_DEFNEWSERVER_DLG ) ); |
|
156 iEditorActive = EFalse; |
|
157 |
|
158 // Dialog was canceled. |
|
159 if ( returnValue == EEikBidCancel ) |
|
160 { |
|
161 // Dialog was shut down by a dialog shutter and we need to return |
|
162 // quickly without touching any internal variables. |
|
163 return EWVSettingsViewForceExit; |
|
164 } |
|
165 |
|
166 if ( ( exitReason == EMissingCompulsory ) |
|
167 && aEditMode == CWVSettingsUIDefineNewServerDialog::EEditServer ) |
|
168 { |
|
169 CIMPSSAPSettings* sap = GetSAPL( iListBox->CurrentItemIndex() ); |
|
170 |
|
171 if ( sap ) |
|
172 { |
|
173 CleanupStack::PushL( sap ); |
|
174 // show note that prevents user from deleting protected server |
|
175 if ( sap->Protection() == ESAPBrandProtection ) |
|
176 { |
|
177 // show note |
|
178 ShowBrandProtectionNoteL(); |
|
179 CleanupStack::PopAndDestroy( sap ); |
|
180 } |
|
181 else |
|
182 { |
|
183 // there is no brand protection for this server, it's ok to delete it |
|
184 // delete the server |
|
185 TRAPD( err, iSAPSettingsStore->DeleteSAPL( sap->Uid() ) ); |
|
186 |
|
187 if ( err == KErrNone ) |
|
188 { |
|
189 TInt index( iListBox->CurrentItemIndex() ); |
|
190 |
|
191 // the index cannot go below zero in any case |
|
192 if ( --index < 0 ) |
|
193 { |
|
194 index = 0; |
|
195 } |
|
196 // we must set the current item index to the next |
|
197 // item, unless this is the last one |
|
198 if ( index + 1 < iListBox->BottomItemIndex() ) |
|
199 { |
|
200 // this is not the last item, we need to add one |
|
201 index++; |
|
202 } |
|
203 // Remove data also from internal buffer |
|
204 UpdateModelL(); |
|
205 |
|
206 iListBox->HandleItemRemovalL(); |
|
207 // if the list is empty index is set to 0 above |
|
208 iListBox->SetCurrentItemIndexAndDraw( index ); |
|
209 iListBox->DrawNow(); |
|
210 } |
|
211 CleanupStack::PopAndDestroy( sap ); |
|
212 } |
|
213 } |
|
214 } |
|
215 |
|
216 iListBox->View()->DrawItem( iListBox->CurrentItemIndex() ); |
|
217 |
|
218 if ( returnValue == EWVSettingsViewCmdExit ) |
|
219 { |
|
220 return EWVSettingsViewExitCalled; |
|
221 } |
|
222 else |
|
223 { |
|
224 return EWVSettingsViewOk; |
|
225 } |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CWVSettingsUIServerListDialog::DeleteSelectedServerL |
|
230 // |
|
231 // (other items were commented in a header). |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CWVSettingsUIServerListDialog::DeleteSelectedServerL() |
|
235 { |
|
236 // get the current sap |
|
237 CIMPSSAPSettings* sap = GetSAPL( iListBox->CurrentItemIndex() ); |
|
238 |
|
239 // Get default sap's uid |
|
240 TUint32 defaultSapUid; |
|
241 iSAPSettingsStore->GetDefaultL( defaultSapUid, EIMPSIMAccessGroup ); |
|
242 |
|
243 // Check if we are trying to delete default sap |
|
244 TBool isDefaultSap = sap->Uid() == defaultSapUid; |
|
245 |
|
246 TInt sapCount = iSAPSettingsStore->SAPCountL( EIMPSIMAccessGroup ); |
|
247 |
|
248 if ( sap ) |
|
249 { |
|
250 CleanupStack::PushL( sap ); |
|
251 // show note that prevents user from deleting protected server |
|
252 if ( sap->Protection() == ESAPBrandProtection ) |
|
253 { |
|
254 // show note |
|
255 ShowBrandProtectionNoteL(); |
|
256 CleanupStack::PopAndDestroy( sap ); // sap |
|
257 return; |
|
258 } |
|
259 |
|
260 CPEngNWSessionSlotID2* sessionSlotID = NULL; |
|
261 TRAPD( err, sessionSlotID = iConnectionUI->GetActiveNWSessionSlotIDL( EIMPSConnClientIM ) ); |
|
262 CleanupStack::PushL( sessionSlotID ); |
|
263 |
|
264 if ( !err ) |
|
265 { |
|
266 // check if IM or PEC is connected to this server |
|
267 CIMPSSAPSettings* loggedInSap = CIMPSSAPSettings::NewLC(); |
|
268 TInt returnValue = iConnectionUI->GetLoggedInSapL( *sessionSlotID, *loggedInSap ); |
|
269 CleanupStack::Pop( loggedInSap ); |
|
270 CleanupStack::PopAndDestroy( sessionSlotID ); |
|
271 CleanupStack::PushL( loggedInSap ); |
|
272 |
|
273 TIMPSConnectionOperation connOperation( EIMPSConnOppUnknown ); |
|
274 |
|
275 // if returnValue is anything except KErrNone, nobody is logged in at the moment |
|
276 // but we must check if the login is ongoing at this moment |
|
277 if ( returnValue != KErrNone ) |
|
278 { |
|
279 // we were not logged in |
|
280 // check if the log in is ongoing |
|
281 HBufC* buffer = NULL; |
|
282 connOperation = iConnectionUI->CurrentConnectionOperationL( buffer ); |
|
283 if ( connOperation == EIMPSConnOppClientLogin ) |
|
284 { |
|
285 // login ongoing, set the sap name for later checks |
|
286 CleanupStack::PushL( buffer ); |
|
287 loggedInSap->SetSAPNameL( *buffer ); |
|
288 CleanupStack::PopAndDestroy( buffer ); |
|
289 } |
|
290 } |
|
291 |
|
292 // if there is an active connection or ongoing login operation |
|
293 if ( ( returnValue == KErrNone ) || ( connOperation == EIMPSConnOppClientLogin ) ) |
|
294 { |
|
295 // check if the active connection is to the current sap |
|
296 if ( loggedInSap->SAPName().CompareF ( sap->SAPName() ) == 0 ) |
|
297 { |
|
298 // the active connection or the ongoing login operation was to the current sap |
|
299 if ( connOperation == EIMPSConnOppClientLogin ) |
|
300 { |
|
301 // a login operation is ongoing, we cannot let the user edit the settings |
|
302 HBufC* prompt = StringLoader::LoadLC( |
|
303 R_QTN_CHAT_LOGIN_ONGOING_NOTE, |
|
304 loggedInSap->SAPName(), |
|
305 iCoeEnv ); |
|
306 CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote( ETrue ); |
|
307 dlg->ExecuteLD( *prompt ); |
|
308 CleanupStack::PopAndDestroy( prompt ); |
|
309 CleanupStack::PopAndDestroy( loggedInSap ); |
|
310 CleanupStack::PopAndDestroy( sap ); |
|
311 return; |
|
312 } |
|
313 // this is the server we are logged in to |
|
314 else if ( !ConfirmLogoutL() ) |
|
315 { |
|
316 // user declined logout, we cannot delete this server |
|
317 CleanupStack::PopAndDestroy( 2 ); // loggedInSap, sap |
|
318 return; |
|
319 } |
|
320 } |
|
321 } |
|
322 CleanupStack::PopAndDestroy( loggedInSap ); |
|
323 } |
|
324 // ignore not found error, since then there cannot be active connection to disconnect |
|
325 else if ( err != KErrNotFound ) |
|
326 { |
|
327 User::Leave( err ); |
|
328 } |
|
329 else |
|
330 { |
|
331 CleanupStack::PopAndDestroy( sessionSlotID ); |
|
332 } |
|
333 |
|
334 // Ask confirmation from user about deletion |
|
335 HBufC* prompt = prompt = StringLoader::LoadLC( |
|
336 R_QTN_CHAT_DELETE_COMMUNITY, |
|
337 sap->SAPName() ); |
|
338 |
|
339 // Ask common confirmation |
|
340 TInt confirmationResult = ExecuteConfirmationDialogL( *prompt ); |
|
341 if ( confirmationResult == 0 ) |
|
342 { |
|
343 CleanupStack::PopAndDestroy( 2, sap ); // prompt, sap |
|
344 return; |
|
345 } |
|
346 |
|
347 CleanupStack::PopAndDestroy( prompt ); |
|
348 prompt = NULL; |
|
349 |
|
350 if ( isDefaultSap && sapCount > 1 ) |
|
351 |
|
352 { |
|
353 // If current server is deleted, we need new server to use. |
|
354 // The default SAP cannot be deleted from SAP settings store so |
|
355 // we have to query this before the actual deletion |
|
356 CWVSettingsUIServerSelector::ExecuteSelectionQueryLD( |
|
357 *iSAPSettingsStore, *iDialog, EFalse, ETrue ); |
|
358 } |
|
359 |
|
360 // do the actual deletion |
|
361 iSAPSettingsStore->DeleteSAPL( sap->Uid() ); |
|
362 |
|
363 // set the current index |
|
364 TInt index( iListBox->CurrentItemIndex() ); |
|
365 |
|
366 if ( --index < 0 ) |
|
367 { |
|
368 index = 0; |
|
369 } |
|
370 else if ( index + 1 < iListBox->BottomItemIndex() ) |
|
371 { |
|
372 // this is not the last item, we need to add one |
|
373 index++; |
|
374 } |
|
375 // Remove data also from internal buffer |
|
376 UpdateModelL(); |
|
377 |
|
378 iListBox->HandleItemRemovalL(); |
|
379 iListBox->SetCurrentItemIndexAndDraw( index ); |
|
380 |
|
381 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
382 { |
|
383 // Update CBA |
|
384 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
385 cba->SetCommandSetL( R_WVSETTINGSVIEW_SOFTKEYS_OPTIONS_BACK__EMPTY ); |
|
386 cba->DrawNow(); |
|
387 } |
|
388 |
|
389 DrawNow(); |
|
390 } |
|
391 |
|
392 CleanupStack::PopAndDestroy( sap ); |
|
393 } |
|
394 // } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CWVSettingsUIServerListDialog::ShowBrandProtectionNoteL |
|
398 // |
|
399 // (other items were commented in a header). |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 void CWVSettingsUIServerListDialog::ShowBrandProtectionNoteL() |
|
403 { |
|
404 HBufC* noteText = iEikonEnv->AllocReadResourceLC( R_QTN_WVSETTINGSVIEW_BRAND_SERVER_DELNOTE ); |
|
405 CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue ); |
|
406 dlg->ExecuteLD( *noteText ); |
|
407 CleanupStack::PopAndDestroy( noteText ); // noteText |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CWVSettingsUIServerListDialog::ConfirmLogoutL |
|
412 // |
|
413 // (other items were commented in a header). |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 TBool CWVSettingsUIServerListDialog::ConfirmLogoutL() |
|
417 { |
|
418 // check if pec and chat are logged in |
|
419 TBool pecLogged ( iConnectionUI->LoggedInL( EIMPSConnClientPEC ) ); |
|
420 TBool imLogged ( iConnectionUI->LoggedInL( EIMPSConnClientIM ) ); |
|
421 |
|
422 if ( pecLogged || imLogged ) |
|
423 { |
|
424 // ask confirmation about logging out |
|
425 CAknQueryDialog* dlg = new ( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone ); |
|
426 CleanupStack::PushL( dlg ); |
|
427 // Set prompt |
|
428 HBufC* text = CEikonEnv::Static()->AllocReadResourceLC( |
|
429 R_WVSETTINGSVIEW_ERROR_ID_ACTIVE_CONNECTION ); |
|
430 dlg->SetPromptL( *text ); |
|
431 CleanupStack::PopAndDestroy( text ); |
|
432 CleanupStack::Pop( dlg ); |
|
433 TInt ret( dlg->ExecuteLD( R_ACTIVE_CONNECTION_CONFIRMATION_QUERY ) ); |
|
434 |
|
435 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
436 { |
|
437 iDialog->ChangeToManualL(); |
|
438 // user confirmed logout -> disconnect all open connections |
|
439 CPEngNWSessionSlotID2* sessionSlotID = |
|
440 iConnectionUI->GetActiveNWSessionSlotIDL( EIMPSConnClientIM ); |
|
441 CleanupStack::PushL( sessionSlotID ); |
|
442 User::LeaveIfError( iConnectionUI->LogoutL( *sessionSlotID ) ); |
|
443 CleanupStack::PopAndDestroy( sessionSlotID ); |
|
444 return ETrue; |
|
445 } |
|
446 else |
|
447 { |
|
448 // the user declined the logout, we can just return EFalse |
|
449 return EFalse; |
|
450 } |
|
451 } |
|
452 |
|
453 return EFalse; |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CWVSettingsUIServerListDialog::ExecuteConfirmationDialogL |
|
458 // |
|
459 // (other items were commented in a header). |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 TInt CWVSettingsUIServerListDialog::ExecuteConfirmationDialogL( const TDesC& aPrompt ) |
|
463 { |
|
464 // Show confirmation |
|
465 CAknQueryDialog* dlg = new ( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone ); |
|
466 CleanupStack::PushL( dlg ); |
|
467 dlg->SetPromptL( aPrompt ); |
|
468 CleanupStack::Pop( dlg ); |
|
469 return dlg->ExecuteLD( R_WVSETTINGSVIEW_CONFIRMATION_QUERY ); |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CWVSettingsUIServerListDialog::GetSAPL |
|
474 // |
|
475 // (other items were commented in a header). |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 CIMPSSAPSettings* CWVSettingsUIServerListDialog::GetSAPL( TInt aIndex ) |
|
479 { |
|
480 // the index cannot be less than zero |
|
481 if ( aIndex < 0 ) |
|
482 { |
|
483 User::Leave( KErrNotFound ); |
|
484 } |
|
485 TPtrC name( iServerListAdapter->RawDataMdcaPoint( aIndex ) ); |
|
486 |
|
487 CIMPSSAPSettingsList* sapList = CIMPSSAPSettingsList::NewLC(); |
|
488 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
489 iSAPSettingsStore->PopulateSAPSettingsListL( *sapList, EIMPSIMAccessGroup ); |
|
490 TInt index( 0 ); |
|
491 |
|
492 if ( sapList->FindNameL( name, index ) == 0 ) |
|
493 { |
|
494 TUint32 uid( sapList->UidForIndex( index ) ); |
|
495 const CIMPSSAPSettingsListItem* sapItem = sapList->ListItemForUid( uid ); |
|
496 iSAPSettingsStore->GetSAPL( sapItem->Uid(), sap ); |
|
497 CleanupStack::Pop( sap ); |
|
498 } |
|
499 else |
|
500 { |
|
501 CleanupStack::PopAndDestroy( sap ); |
|
502 sap = NULL; |
|
503 } |
|
504 |
|
505 CleanupStack::PopAndDestroy( sapList ); |
|
506 |
|
507 return sap; |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CWVSettingsUIServerListDialog::UpdateModelL |
|
512 // |
|
513 // (other items were commented in a header). |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 void CWVSettingsUIServerListDialog::UpdateModelL() |
|
517 { |
|
518 |
|
519 CIMPSSAPSettingsList* newList = CIMPSSAPSettingsList::NewLC(); |
|
520 iSAPSettingsStore->PopulateSAPSettingsListL( *newList, EIMPSIMAccessGroup ); |
|
521 TInt index( newList->IndexForUid( iCurrent ) ); |
|
522 iCurrent = 0; |
|
523 if ( iAdded ) |
|
524 { |
|
525 iAdded = EFalse; |
|
526 TInt newIndex = newList->IndexForUid( iNewUid ); |
|
527 if ( newIndex > KErrNotFound ) |
|
528 { |
|
529 index = newIndex; |
|
530 } |
|
531 } |
|
532 |
|
533 // ReplaceModel can only leave if newList is NULL, so we can pop the newList here |
|
534 CleanupStack::Pop( newList ); |
|
535 |
|
536 // Ownership of newList is transferred to iServerListAdapter |
|
537 iServerListAdapter->ReplaceModelL( newList ); |
|
538 |
|
539 // we don't want to go below zero |
|
540 if ( index < 0 ) |
|
541 { |
|
542 index = 0; |
|
543 } |
|
544 |
|
545 // set the correct focus |
|
546 iListBox->SetCurrentItemIndex( index ); |
|
547 |
|
548 if ( newList ) |
|
549 { |
|
550 if ( newList->Count() > 0 ) |
|
551 { |
|
552 // check that the focus stays on the screen |
|
553 if ( iListBox->CurrentItemIndex() > ( newList->Count() - 1 ) ) |
|
554 { |
|
555 iListBox->SetCurrentItemIndex( newList->Count() - 1 ); |
|
556 } |
|
557 } |
|
558 } |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CWVSettingsUIServerListDialog::LoadListboxIconArrayL |
|
563 // |
|
564 // (other items were commented in a header). |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CWVSettingsUIServerListDialog::LoadListboxIconArrayL() |
|
568 { |
|
569 |
|
570 // Create array for listbox graphics |
|
571 CAknIconArray* icons = new ( ELeave ) CAknIconArray( 1 ); // one icon in array |
|
572 CleanupStack::PushL( icons ); |
|
573 |
|
574 CFbsBitmap* bitmap = NULL; |
|
575 CFbsBitmap* mask = NULL; |
|
576 |
|
577 TFileName bitmapfilepath; |
|
578 bitmapfilepath.Append( TParsePtrC( PathInfo::RomRootPath() ).Drive() ); |
|
579 bitmapfilepath.Append( KDC_APP_BITMAP_DIR() ); |
|
580 bitmapfilepath.Append( KBitmapFile() ); |
|
581 |
|
582 AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), |
|
583 KAknsIIDQgnIndiSettProtectedAdd, |
|
584 bitmap, mask, bitmapfilepath, |
|
585 EMbmApsettingsQgn_indi_sett_protected_add, |
|
586 EMbmApsettingsQgn_indi_sett_protected_add_mask ); |
|
587 |
|
588 icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
589 CleanupStack::Pop( 2 ); // mask, bitmap |
|
590 |
|
591 // Transfer ownership to listbox |
|
592 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
593 CleanupStack::Pop( icons ); |
|
594 } |
|
595 |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CWVSettingsUIServerListDialog::ProcessCommandL |
|
599 // |
|
600 // (other items were commented in a header). |
|
601 // ----------------------------------------------------------------------------- |
|
602 // |
|
603 void CWVSettingsUIServerListDialog::ProcessCommandL( TInt aCommand ) |
|
604 { |
|
605 HideMenu(); |
|
606 |
|
607 switch ( aCommand ) |
|
608 { |
|
609 case EAknSoftkeyEdit: // Flowthrough, MSK command |
|
610 case EWVSettingsViewServerlistNew: // Flowthrough |
|
611 case EWVSettingsViewServerlistEdit: |
|
612 { |
|
613 LaunchCorrectDialog( aCommand ); |
|
614 break; |
|
615 } |
|
616 |
|
617 case EWVSettingsViewServerlistDelete: |
|
618 { |
|
619 DeleteSelectedServerL(); |
|
620 break; |
|
621 } |
|
622 // Help key support EWVSettingsViewCmdHelp is assigned EAknCmdHelp in |
|
623 // CWSettingsUI.hrh |
|
624 case EWVSettingsViewCmdHelp: |
|
625 { |
|
626 HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), |
|
627 ( CCoeEnv::Static()->AppUi() )->AppHelpContextL () ); |
|
628 break; |
|
629 } |
|
630 |
|
631 case EWVSettingsViewCmdExit: |
|
632 { |
|
633 TryExitL( aCommand ); |
|
634 break; |
|
635 } |
|
636 default: |
|
637 { |
|
638 CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommand ); |
|
639 break; |
|
640 } |
|
641 } |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CWVSettingsUIServerListDialog::HandleListBoxEventL |
|
646 // |
|
647 // (other items were commented in a header). |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CWVSettingsUIServerListDialog::HandleListBoxEventL( CEikListBox* aListBox, |
|
651 TListBoxEvent aEventType ) |
|
652 { |
|
653 if ( aEventType != EEventEnterKeyPressed && |
|
654 aEventType != EEventItemDoubleClicked ) |
|
655 { |
|
656 return; |
|
657 } |
|
658 |
|
659 if ( aListBox == iListBox ) |
|
660 { |
|
661 ProcessCommandL( EWVSettingsViewServerlistEdit ); |
|
662 } |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CWVSettingsUIServerListDialog::OfferKeyEventL |
|
667 // |
|
668 // (other items were commented in a header). |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 TKeyResponse CWVSettingsUIServerListDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
672 TEventCode aType ) |
|
673 { |
|
674 |
|
675 if ( aType == EEventKey && ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter ) ) |
|
676 { |
|
677 HandleListBoxEventL( iListBox, EEventEnterKeyPressed ); |
|
678 return EKeyWasConsumed; |
|
679 } |
|
680 else if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
|
681 { |
|
682 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
683 { |
|
684 return EKeyWasConsumed; |
|
685 } |
|
686 DeleteSelectedServerL(); |
|
687 return EKeyWasConsumed; |
|
688 } |
|
689 |
|
690 return CEikDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
691 } |
|
692 |
|
693 // ----------------------------------------------------------------------------- |
|
694 // CWVSettingsUIServerListDialog::DynInitMenuPaneL |
|
695 // |
|
696 // (other items were commented in a header). |
|
697 // ----------------------------------------------------------------------------- |
|
698 // |
|
699 void CWVSettingsUIServerListDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
700 { |
|
701 |
|
702 // if we're displaying general menu and help feature is not supported.. |
|
703 if ( aResourceId == R_WVSETTINGSVIEW_GENERAL_MENU && |
|
704 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
705 { |
|
706 // dimm the help menu item |
|
707 aMenuPane->SetItemDimmed( EWVSettingsViewCmdHelp, ETrue ); |
|
708 } |
|
709 else if ( aResourceId == R_WVSETTINGSVIEW_SERVERLIST_MENUPANE ) |
|
710 { |
|
711 // |
|
712 // Based on Variation flag, Enable Locking Server Setting which removes |
|
713 // adding/deleting New Server option in Settings View. |
|
714 TBool lockServerSettings = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_LOCK_SERVER_SETTING ); |
|
715 |
|
716 if ( iServerListAdapter->MdcaCount() == 0 ) |
|
717 { |
|
718 aMenuPane->DeleteMenuItem( EWVSettingsViewServerlistEdit ); |
|
719 aMenuPane->DeleteMenuItem( EWVSettingsViewServerlistDelete ); |
|
720 } |
|
721 else if ( lockServerSettings ) |
|
722 { |
|
723 aMenuPane->DeleteMenuItem( EWVSettingsViewServerlistNew ); |
|
724 aMenuPane->DeleteMenuItem( EWVSettingsViewServerlistDelete ); |
|
725 } |
|
726 } |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CWVSettingsUIServerListDialog::PreLayoutDynInitL |
|
731 // |
|
732 // (other items were commented in a header). |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 void CWVSettingsUIServerListDialog::PreLayoutDynInitL() |
|
736 { |
|
737 RefreshTitleL(); |
|
738 |
|
739 iSAPSettingsStore->AddObserverL( this, EIMPSIMAccessGroup ); |
|
740 |
|
741 CIMPSSAPSettingsList* sapList = CIMPSSAPSettingsList::NewLC(); |
|
742 iSAPSettingsStore->PopulateSAPSettingsListL( *sapList, EIMPSIMAccessGroup ); |
|
743 // Ownership of sapList is transferred to iServerListAdapter |
|
744 CleanupStack::Pop( sapList ); |
|
745 // after this iProtectedServers contain protected servers' indexes |
|
746 |
|
747 iServerListAdapter = CWVSettingsUIServersArray::NewL( *sapList, iProtectedServers ); |
|
748 |
|
749 iListBox = |
|
750 static_cast< CAknSingleStyleListBox* >( Control( EWVSettingsViewControlIdServerList ) ); |
|
751 LoadListboxIconArrayL(); |
|
752 HBufC* emptyText = iEikonEnv->AllocReadResourceLC( R_WVSETTINGSVIEW_SERVERLIST_NOSERV ); |
|
753 |
|
754 iListBox->Model()->SetItemTextArray( iServerListAdapter ); |
|
755 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
756 iListBox->CreateScrollBarFrameL( ETrue ); |
|
757 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
758 CEikScrollBarFrame::EOff, |
|
759 CEikScrollBarFrame::EAuto ); |
|
760 iListBox->HandleItemAdditionL(); |
|
761 iListBox->SetListBoxObserver( this ); |
|
762 iListBox->UpdateScrollBarsL(); |
|
763 iListBox->View()->SetListEmptyTextL( *emptyText ); |
|
764 |
|
765 iDlgLauncher = new ( ELeave ) CAsyncCallBack( |
|
766 TCallBack( LaunchDlgCallback, this ), |
|
767 CActive::EPriorityStandard ); |
|
768 |
|
769 CleanupStack::PopAndDestroy( emptyText ); |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------- |
|
773 // CWVSettingsUIServerListDialog::HandleActiveDbEvent() |
|
774 // (other items were commented in a header). |
|
775 // --------------------------------------------------------- |
|
776 // |
|
777 void CWVSettingsUIServerListDialog::HandleSAPEvent( TSAPEvent aEvent ) |
|
778 { |
|
779 // Waiting for SAP Settings store improvementes in event handling |
|
780 |
|
781 if ( aEvent == ESAPSettingChanged ) |
|
782 { |
|
783 // we have to refresh the view |
|
784 // if editor is active, we should not refresh |
|
785 // when editor is exited the view will be refresed anyway |
|
786 CIMPSSAPSettings* sap = NULL; |
|
787 // we cannot leave here |
|
788 TRAPD( ignore, sap = GetSAPL( iListBox->CurrentItemIndex() ) ); |
|
789 |
|
790 if ( sap ) |
|
791 { |
|
792 iCurrent = sap->Uid(); |
|
793 delete sap; |
|
794 } |
|
795 |
|
796 if ( !iEditorActive ) |
|
797 { |
|
798 // we cannot leave here, the display just wont be up-to-date |
|
799 TRAP( ignore, UpdateModelL() ); |
|
800 } |
|
801 } |
|
802 } |
|
803 |
|
804 // --------------------------------------------------------- |
|
805 // CWVSettingsUIServerListDialog::MappedCommandId() |
|
806 // (other items were commented in a header). |
|
807 // --------------------------------------------------------- |
|
808 // |
|
809 TInt CWVSettingsUIServerListDialog::MappedCommandId( TInt aButtonId ) |
|
810 { |
|
811 // change cancel id so avkon don't remap it to 0 |
|
812 if ( aButtonId == EEikBidCancel ) |
|
813 { |
|
814 return KErrDied; |
|
815 } |
|
816 return aButtonId; |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------- |
|
820 // CWVSettingsUIServerListDialog::OkToExitL() |
|
821 // (other items were commented in a header). |
|
822 // --------------------------------------------------------- |
|
823 // |
|
824 TBool CWVSettingsUIServerListDialog::OkToExitL( TInt aButtonId ) |
|
825 { |
|
826 if ( aButtonId == EAknSoftkeyEmpty ) |
|
827 { |
|
828 return EFalse; |
|
829 } |
|
830 if ( iEditorActive ) |
|
831 { |
|
832 return EFalse; |
|
833 } |
|
834 if ( aButtonId == EAknSoftkeyEdit ) |
|
835 { |
|
836 // MSK command |
|
837 ProcessCommandL( aButtonId ); |
|
838 return EFalse; |
|
839 } |
|
840 |
|
841 return CAknDialog::OkToExitL( aButtonId ); |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------- |
|
845 // CWVSettingsUIServerListDialog::LaunchCorrectDialog() |
|
846 // (other items were commented in a header). |
|
847 // --------------------------------------------------------- |
|
848 // |
|
849 void CWVSettingsUIServerListDialog::LaunchCorrectDialog( TInt aCommand ) |
|
850 { |
|
851 |
|
852 if ( GetTargetDlgFlag() ) |
|
853 { |
|
854 return; |
|
855 } |
|
856 |
|
857 if ( !iDlgLauncher->IsActive() ) |
|
858 { |
|
859 iDlgCommand = aCommand; |
|
860 iDlgLauncher->Call(); |
|
861 } |
|
862 } |
|
863 |
|
864 // --------------------------------------------------------- |
|
865 // CWVSettingsUIServerListDialog::LaunchDlgCallback() |
|
866 // (other items were commented in a header). |
|
867 // --------------------------------------------------------- |
|
868 // |
|
869 TInt CWVSettingsUIServerListDialog::LaunchDlgCallback( TAny* aDlg ) |
|
870 { |
|
871 CWVSettingsUIServerListDialog* dlg = |
|
872 static_cast<CWVSettingsUIServerListDialog*>( aDlg ); |
|
873 |
|
874 |
|
875 dlg->SetTargetDlgFlag( ETrue ); |
|
876 TRAP_IGNORE( dlg->DoLaunchCorrectDialogL() ); |
|
877 dlg->SetTargetDlgFlag( EFalse ); |
|
878 return EFalse; |
|
879 } |
|
880 |
|
881 // --------------------------------------------------------- |
|
882 // CWVSettingsUIServerListDialog::DoLaunchCorrectDialogL() |
|
883 // (other items were commented in a header). |
|
884 // --------------------------------------------------------- |
|
885 // |
|
886 void CWVSettingsUIServerListDialog::DoLaunchCorrectDialogL() |
|
887 { |
|
888 switch ( iDlgCommand ) |
|
889 { |
|
890 case EWVSettingsViewServerlistNew: |
|
891 { |
|
892 TWVSettingsDialogReturnValue returnValue( DisplayServerEditorDialogL( |
|
893 CWVSettingsUIDefineNewServerDialog::ENewServer ) ); |
|
894 // If dialog was shutdown by a dialog shutter. don't touch internal variables. |
|
895 if ( returnValue != EWVSettingsViewForceExit ) |
|
896 { |
|
897 iAdded = ETrue; |
|
898 UpdateModelL(); |
|
899 RefreshTitleL(); |
|
900 iListBox->HandleItemAdditionL(); |
|
901 if ( returnValue == EWVSettingsViewExitCalled ) |
|
902 { |
|
903 TryExitL ( EWVSettingsViewCmdExit ); |
|
904 } |
|
905 } |
|
906 else |
|
907 { |
|
908 TryExitL ( EAknSoftkeyCancel ); |
|
909 } |
|
910 break; |
|
911 } |
|
912 |
|
913 case EAknSoftkeyEdit: // Flowthrough, MSK command |
|
914 case EWVSettingsViewServerlistEdit: |
|
915 { |
|
916 TInt listboxIndex = iListBox->CurrentItemIndex(); |
|
917 // if there are no items in the list, we can just return |
|
918 if ( listboxIndex < 0 ) |
|
919 { |
|
920 return; |
|
921 } |
|
922 delete iSAP; |
|
923 iSAP = NULL; |
|
924 iSAP = GetSAPL( iListBox->CurrentItemIndex() ); |
|
925 |
|
926 // If a matching SAP for current item index can't be found a SAP then |
|
927 // we have a synchronization problem |
|
928 |
|
929 if ( iSAP ) |
|
930 { |
|
931 TWVSettingsDialogReturnValue returnValue = DisplayServerEditorDialogL( |
|
932 CWVSettingsUIDefineNewServerDialog::EEditServer ); |
|
933 // If dialog was shutdown by a dialog shutter. don't touch internal variables. |
|
934 if ( returnValue != EWVSettingsViewForceExit ) |
|
935 { |
|
936 UpdateModelL(); |
|
937 RefreshTitleL(); |
|
938 iListBox->HandleItemAdditionL(); |
|
939 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
940 { |
|
941 // Update CBA |
|
942 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
943 cba->SetCommandSetL( R_WVSETTINGSVIEW_SOFTKEYS_OPTIONS_BACK__EMPTY ); |
|
944 cba->DrawNow(); |
|
945 } |
|
946 if ( returnValue == EWVSettingsViewExitCalled ) |
|
947 { |
|
948 ProcessCommandL( EWVSettingsViewCmdExit ); |
|
949 } |
|
950 } |
|
951 else |
|
952 { |
|
953 TryExitL ( EAknSoftkeyCancel ); |
|
954 } |
|
955 } |
|
956 else |
|
957 { |
|
958 iListBox->HandleItemRemovalL(); |
|
959 } |
|
960 |
|
961 break; |
|
962 } |
|
963 default: |
|
964 { |
|
965 // nothing to do |
|
966 } |
|
967 } |
|
968 } |
|
969 |
|
970 |
|
971 // --------------------------------------------------------- |
|
972 // CWVSettingsUIDialogImp::SetTargetDlgFlag() |
|
973 // (other items were commented in a header). |
|
974 // --------------------------------------------------------- |
|
975 // |
|
976 void CWVSettingsUIServerListDialog::SetTargetDlgFlag( TBool aFlag ) |
|
977 { |
|
978 iIsOpenedTargettDlg = aFlag; |
|
979 } |
|
980 |
|
981 |
|
982 // --------------------------------------------------------- |
|
983 // CWVSettingsUIDialogImp::SetTargetDlgFlag() |
|
984 // (other items were commented in a header). |
|
985 // --------------------------------------------------------- |
|
986 // |
|
987 TBool CWVSettingsUIServerListDialog::GetTargetDlgFlag() |
|
988 { |
|
989 return iIsOpenedTargettDlg; |
|
990 } |
|
991 |
|
992 /** |
|
993 * Help key support - GetHelpContext is called by the framework on |
|
994 * event EAknCmdHelp |
|
995 * -------------------------------------------------------------------------------- |
|
996 * CWVSettingsUIDefineNewServerDialog::GetHelpContext |
|
997 * @param aContext The context dependent on the current view is passed by the framework. |
|
998 */ |
|
999 void CWVSettingsUIServerListDialog::GetHelpContext( |
|
1000 TCoeHelpContext& aContext ) const |
|
1001 { |
|
1002 aContext.iMajor = KUidChatClient; |
|
1003 aContext.iContext = KIMNG_HLP_SERVLISTSETT_IM ; |
|
1004 } |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CWVSettingsUIServerListDialog::IntResourceValueL() |
|
1008 // @param aResourceId The resource ID to be fetched from Cenrep (if present) or else from the variation file |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // |
|
1011 TInt CWVSettingsUIServerListDialog::IntResourceValueL( TInt aResourceId ) |
|
1012 { |
|
1013 |
|
1014 TInt val( 0 ); |
|
1015 TInt err ( KErrNone ); |
|
1016 CRepository* rep = 0; |
|
1017 |
|
1018 TRAP( err, rep = CRepository::NewL( KCRUidIMNG ) ); |
|
1019 |
|
1020 if ( err == KErrNone ) |
|
1021 { |
|
1022 TInt key = aResourceId + KIMCUStartVariationID; |
|
1023 |
|
1024 err = rep->Get( key, val ); |
|
1025 |
|
1026 delete rep; |
|
1027 } |
|
1028 |
|
1029 if ( err != KErrNone ) |
|
1030 { |
|
1031 |
|
1032 TResourceReader reader; |
|
1033 |
|
1034 aResourceId = aResourceId + RSC_CRRSS_CHAT_VARIATION_IMPSCU_START_ID; |
|
1035 |
|
1036 CCoeEnv::Static()->CreateResourceReaderLC( |
|
1037 reader, |
|
1038 aResourceId ); |
|
1039 val = reader.ReadInt32(); |
|
1040 CleanupStack::PopAndDestroy(); // reader |
|
1041 |
|
1042 } |
|
1043 |
|
1044 return val; |
|
1045 |
|
1046 } |
|
1047 // End of File |