64
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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: This file implements classes CPIMSettingItemListDlg, CFsEmailSettingsList.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// SYSTEM INCLUDES
|
|
20 |
#include "emailtrace.h"
|
|
21 |
#include <barsread.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <aknlists.h>
|
|
24 |
#include <eikenv.h>
|
|
25 |
#include <AknIconArray.h>
|
|
26 |
#include <eikclbd.h>
|
|
27 |
#include <aknViewAppUi.h>
|
|
28 |
#include <eikappui.h>
|
|
29 |
#include <aknlistquerydialog.h>
|
|
30 |
#include <e32cmn.h>
|
|
31 |
#include <FreestyleEmailUi.rsg>
|
|
32 |
|
|
33 |
#include "cfsmailclient.h"
|
|
34 |
#include "cfsmailbox.h"
|
|
35 |
#include <AknGlobalConfirmationQuery.h> // confirmation
|
|
36 |
#include <freestyleemailui.mbg> // icons
|
|
37 |
#include "esmailsettingspluginuids.hrh"
|
|
38 |
#include "esmailsettingsplugin.h"
|
|
39 |
|
|
40 |
#include <aknnotewrappers.h> // for note
|
|
41 |
#include <AknDialog.h> // for settings dialog
|
|
42 |
#include <aknsettingitemlist.h> // for settings dialog
|
|
43 |
|
|
44 |
// 9.11.2009: Temporary flagging SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
45 |
// Can be removed when header structure change is complete
|
|
46 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
47 |
#include <eikctrlstatus.h> // EEikControlHasEars
|
|
48 |
#else
|
|
49 |
#include <uikon/eikctrlstatus.h> // EEikControlHasEars
|
|
50 |
#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
51 |
|
|
52 |
// LOCAL INCLUDES
|
|
53 |
#include "FreestyleEmailUiConstants.h"
|
|
54 |
#include "FreestyleEmailUiSettingsListView.h"
|
|
55 |
#include "FreestyleEmailUiSettingsList.h"
|
|
56 |
#include "FreestyleEmailUiSettings.hrh"
|
|
57 |
#include "FreestyleEmailUiConstants.h"
|
|
58 |
#include "FreestyleEmailUiAppui.h"
|
|
59 |
#include "FreestyleEmailUiLauncherGridVisualiser.h"
|
|
60 |
#include "FreestyleEmailUiShortcutBinding.h"
|
|
61 |
#include "FreestyleEmailUiUtilities.h"
|
|
62 |
#include "FSEmail.pan"
|
|
63 |
|
|
64 |
// CONSTANTS
|
|
65 |
|
|
66 |
|
|
67 |
//** PIM selection dialog **
|
|
68 |
|
|
69 |
//----------------------------------------------------------------------------
|
|
70 |
// CPIMSettingsItem extends
|
|
71 |
//----------------------------------------------------------------------------
|
|
72 |
class CPIMSettingsItem : public CAknEnumeratedTextPopupSettingItem
|
|
73 |
{
|
|
74 |
public:
|
|
75 |
void SetDefaultPIM( TInt aNewValue );
|
|
76 |
};
|
|
77 |
|
|
78 |
void CPIMSettingsItem::SetDefaultPIM( TInt aNewValue )
|
|
79 |
{
|
|
80 |
FUNC_LOG;
|
|
81 |
SetInternalValue( aNewValue );
|
|
82 |
SetSelectedIndex( aNewValue );
|
|
83 |
}
|
|
84 |
|
|
85 |
//----------------------------------------------------------------------------
|
|
86 |
// CSettingItemList class declaration
|
|
87 |
//----------------------------------------------------------------------------
|
|
88 |
class CSettingItemList : public CAknSettingItemList
|
|
89 |
{
|
|
90 |
public:
|
|
91 |
CSettingItemList();
|
|
92 |
|
|
93 |
virtual CAknSettingItem* CreateSettingItemL(TInt aIdentifier);
|
|
94 |
|
|
95 |
TInt iItemId;
|
|
96 |
CSettingItemList* iSettingsList;
|
|
97 |
};
|
|
98 |
|
|
99 |
//----------------------------------------------------------------------------
|
|
100 |
// constructor CSettingItemList
|
|
101 |
//----------------------------------------------------------------------------
|
|
102 |
CSettingItemList::CSettingItemList()
|
|
103 |
{
|
|
104 |
FUNC_LOG;
|
|
105 |
}
|
|
106 |
//----------------------------------------------------------------------------
|
|
107 |
// CreateSettingItemL
|
|
108 |
//----------------------------------------------------------------------------
|
|
109 |
CAknSettingItem* CSettingItemList::CreateSettingItemL( TInt aIdentifier )
|
|
110 |
{
|
|
111 |
FUNC_LOG;
|
|
112 |
CAknSettingItem* settingitem = NULL;
|
|
113 |
|
|
114 |
switch (aIdentifier)
|
|
115 |
{
|
|
116 |
case 0:
|
|
117 |
{
|
|
118 |
settingitem = new (ELeave) CAknEnumeratedTextPopupSettingItem( aIdentifier, iItemId );
|
|
119 |
}
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
|
|
123 |
return settingitem;
|
|
124 |
}
|
|
125 |
|
|
126 |
//----------------------------------------------------------------------------
|
|
127 |
// CPIMSettingItemListDlg Class declaration
|
|
128 |
//----------------------------------------------------------------------------
|
|
129 |
class CPIMSettingItemListDlg : public CAknDialog
|
|
130 |
{
|
|
131 |
public:
|
|
132 |
CPIMSettingItemListDlg( CFSMailClient& aMailClient );
|
|
133 |
~CPIMSettingItemListDlg();
|
|
134 |
virtual SEikControlInfo CreateCustomControlL(TInt aControlType);
|
|
135 |
virtual CPIMSettingItemListDlg::TFormControlTypes ConvertCustomControlTypeToBaseControlType(TInt aControlType) const;
|
|
136 |
|
|
137 |
virtual void PostLayoutDynInitL();
|
|
138 |
void AddPIMSettingItemsL( TInt aIndex );
|
|
139 |
|
|
140 |
virtual TBool OkToExitL( TInt aButtonId );
|
|
141 |
|
|
142 |
protected:
|
|
143 |
CSettingItemList* iSettingsList;
|
|
144 |
CFSMailClient& iMailClient;
|
|
145 |
RArray<TUid> iPluginUids;
|
|
146 |
};
|
|
147 |
|
|
148 |
//----------------------------------------------------------------------------
|
|
149 |
// CPIMSettingItemListDlg
|
|
150 |
//----------------------------------------------------------------------------
|
|
151 |
CPIMSettingItemListDlg::CPIMSettingItemListDlg( CFSMailClient& aMailClient)
|
|
152 |
: iMailClient(aMailClient)
|
|
153 |
{
|
|
154 |
FUNC_LOG;
|
|
155 |
}
|
|
156 |
|
|
157 |
//----------------------------------------------------------------------------
|
|
158 |
// CPIMSettingItemListDlg::~CPIMSettingItemListDlg
|
|
159 |
//----------------------------------------------------------------------------
|
|
160 |
CPIMSettingItemListDlg::~CPIMSettingItemListDlg( )
|
|
161 |
{
|
|
162 |
FUNC_LOG;
|
|
163 |
iPluginUids.Close();
|
|
164 |
}
|
|
165 |
|
|
166 |
//----------------------------------------------------------------------------
|
|
167 |
// CreateCustomControlL
|
|
168 |
//----------------------------------------------------------------------------
|
|
169 |
SEikControlInfo CPIMSettingItemListDlg::CreateCustomControlL(TInt /*aControlType*/)
|
|
170 |
{
|
|
171 |
FUNC_LOG;
|
|
172 |
iSettingsList = new (ELeave) CSettingItemList;
|
|
173 |
|
|
174 |
SEikControlInfo controlInfo;
|
|
175 |
controlInfo.iFlags = EEikControlHasEars;
|
|
176 |
controlInfo.iTrailerTextId = 0;
|
|
177 |
controlInfo.iControl = iSettingsList;
|
|
178 |
STATIC_CAST(CSettingItemList*, controlInfo.iControl)->SetContainerWindowL(*this);
|
|
179 |
|
|
180 |
return controlInfo;
|
|
181 |
}
|
|
182 |
|
|
183 |
//----------------------------------------------------------------------------
|
|
184 |
// ConvertCustomControlTypeToBaseControlType
|
|
185 |
//----------------------------------------------------------------------------
|
|
186 |
CPIMSettingItemListDlg::TFormControlTypes CPIMSettingItemListDlg::ConvertCustomControlTypeToBaseControlType(TInt /*aControlType*/) const
|
|
187 |
{
|
|
188 |
FUNC_LOG;
|
|
189 |
return EPopfieldDerived;
|
|
190 |
}
|
|
191 |
|
|
192 |
//----------------------------------------------------------------------------
|
|
193 |
// PostLayoutDynInitL
|
|
194 |
// This safely loads the dialog with the data
|
|
195 |
//----------------------------------------------------------------------------
|
|
196 |
void CPIMSettingItemListDlg::PostLayoutDynInitL()
|
|
197 |
{
|
|
198 |
FUNC_LOG;
|
|
199 |
// there are only one item in list
|
|
200 |
AddPIMSettingItemsL( 0 );
|
|
201 |
}
|
|
202 |
|
|
203 |
//----------------------------------------------------------------------------
|
|
204 |
// AddPIMSettingItemsL
|
|
205 |
//
|
|
206 |
//----------------------------------------------------------------------------
|
|
207 |
void CPIMSettingItemListDlg::AddPIMSettingItemsL( TInt aIndex )
|
|
208 |
{
|
|
209 |
FUNC_LOG;
|
|
210 |
CPIMSettingsItem* item = static_cast<CPIMSettingsItem*>(
|
|
211 |
(*iSettingsList->SettingItemArray())[aIndex] );
|
|
212 |
CArrayPtr<CAknEnumeratedText>* texts = item->EnumeratedTextArray();
|
|
213 |
texts->ResetAndDestroy();
|
|
214 |
|
|
215 |
// Read mailboxes ****************************
|
|
216 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
217 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
218 |
TFSMailMsgId plugin;
|
|
219 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
220 |
|
|
221 |
TUid PIMpluginId;
|
|
222 |
TInt mailBoxesCount = mailBoxes.Count();
|
|
223 |
for ( TInt i = 0; i < mailBoxesCount; ++i )
|
|
224 |
{
|
|
225 |
// get mailbox name and insert it to listBox
|
|
226 |
CFSMailBox* mailBox = mailBoxes[i];
|
|
227 |
|
|
228 |
// Insert mailbox to dialog list if can handle PIM sync
|
|
229 |
if ( mailBox->GetSettingsUid() != TUid::Null() )
|
|
230 |
{
|
|
231 |
TUid pluginUid = mailBox->GetSettingsUid();
|
|
232 |
CESMailSettingsPlugin* settingsPlugin =
|
|
233 |
CESMailSettingsPlugin::NewL( pluginUid );
|
|
234 |
CleanupStack::PushL(settingsPlugin);
|
|
235 |
HBufC* itemTxt =
|
|
236 |
settingsPlugin->LocalizedProtocolName().AllocLC();
|
|
237 |
TBool canHandlePIMSync = settingsPlugin->CanHandlePIMSync();
|
|
238 |
|
|
239 |
if ( canHandlePIMSync && PIMpluginId != pluginUid )
|
|
240 |
{
|
|
241 |
PIMpluginId = pluginUid;
|
|
242 |
iPluginUids.Append( pluginUid );
|
|
243 |
// takes ownership of itemTxt
|
|
244 |
texts->AppendL(
|
|
245 |
new ( ELeave ) CAknEnumeratedText( i, itemTxt ) );
|
|
246 |
// set as default item if selected for PIM sync
|
|
247 |
if ( settingsPlugin->IsSelectedForPIMSync() )
|
|
248 |
{
|
|
249 |
item->SetDefaultPIM( i );
|
|
250 |
}
|
|
251 |
CleanupStack::Pop( itemTxt );
|
|
252 |
}
|
|
253 |
else
|
|
254 |
{
|
|
255 |
CleanupStack::PopAndDestroy( itemTxt );
|
|
256 |
}
|
|
257 |
CleanupStack::PopAndDestroy();//settingsPlugin
|
|
258 |
}
|
|
259 |
}
|
|
260 |
item->UpdateListBoxTextL();
|
|
261 |
|
|
262 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
263 |
}
|
|
264 |
|
|
265 |
//----------------------------------------------------------------------------
|
|
266 |
// OkToExitL
|
|
267 |
//
|
|
268 |
//----------------------------------------------------------------------------
|
|
269 |
TBool CPIMSettingItemListDlg::OkToExitL( TInt aButtonId )
|
|
270 |
{
|
|
271 |
FUNC_LOG;
|
|
272 |
if ( aButtonId == EFSEmailUiPIMDialogBack )
|
|
273 |
return ETrue;
|
|
274 |
|
|
275 |
if ( aButtonId == EFSEmailUiPIMDialogChange )
|
|
276 |
{
|
|
277 |
const TInt current = iSettingsList->ListBox()->CurrentItemIndex();
|
|
278 |
iSettingsList->EditItemL( current, ETrue );
|
|
279 |
iSettingsList->StoreSettingsL();
|
|
280 |
|
|
281 |
for ( TInt i=0; i < iPluginUids.Count(); ++i )
|
|
282 |
{
|
|
283 |
CESMailSettingsPlugin* settingsPlugin = CESMailSettingsPlugin::NewL( iPluginUids[i] );
|
|
284 |
if ( iSettingsList->iItemId == i )
|
|
285 |
{
|
|
286 |
settingsPlugin->SelectForPIMSync( ETrue );
|
|
287 |
}
|
|
288 |
else
|
|
289 |
{
|
|
290 |
settingsPlugin->SelectForPIMSync( EFalse );
|
|
291 |
}
|
|
292 |
delete settingsPlugin;
|
|
293 |
settingsPlugin = NULL;
|
|
294 |
}
|
|
295 |
iPluginUids.Close();
|
|
296 |
}
|
|
297 |
|
|
298 |
return EFalse;
|
|
299 |
}
|
|
300 |
|
|
301 |
|
|
302 |
//**** CFsEmailSettingsList ****
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// c++ Constructor
|
|
306 |
//
|
|
307 |
// First phase of Symbian two-phase construction. Should not
|
|
308 |
// contain any code that could leave.
|
|
309 |
// ---------------------------------------------------------------------------
|
|
310 |
//
|
|
311 |
CFsEmailSettingsList::CFsEmailSettingsList(CFreestyleEmailUiAppUi& aAppUi, CFSMailClient& aMailClient, CFsEmailSettingsListView& aView )
|
|
312 |
:iAppUi(aAppUi), iMailClient(aMailClient), iView( aView )
|
|
313 |
{
|
|
314 |
FUNC_LOG;
|
|
315 |
|
|
316 |
iListBox = NULL;
|
|
317 |
iCurrentSubView = EFsEmailSettingsMainListView;
|
|
318 |
iPIMListActivation = EFalse;
|
|
319 |
iPIMServiceSettingsSelection = EFalse;
|
|
320 |
iPIMSyncMailboxIndex = -1;
|
|
321 |
iPIMSyncCount = 0;
|
|
322 |
iSelectedSubListIndex = 0;
|
|
323 |
}
|
|
324 |
|
|
325 |
// ---------------------------------------------------------------------------
|
|
326 |
// c++ destructor
|
|
327 |
//
|
|
328 |
// Destroy child controls
|
|
329 |
// ---------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
CFsEmailSettingsList::~CFsEmailSettingsList()
|
|
332 |
{
|
|
333 |
FUNC_LOG;
|
|
334 |
|
|
335 |
if ( iListBox )
|
|
336 |
{
|
|
337 |
delete iListBox;
|
|
338 |
iListBox = NULL;
|
|
339 |
}
|
|
340 |
|
|
341 |
if ( iLongTapDetector )
|
|
342 |
{
|
|
343 |
delete iLongTapDetector;
|
|
344 |
iLongTapDetector = NULL;
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
// Construct the control (first phase).
|
|
350 |
//
|
|
351 |
// @param aRect bounding rectangle
|
|
352 |
// @param aParent owning parent, or NULL
|
|
353 |
// @param aAppUi pointer to AppUi
|
|
354 |
// @param aMailClient reference to freestyle mail client
|
|
355 |
// ---------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
CFsEmailSettingsList* CFsEmailSettingsList::NewL(
|
|
358 |
const TRect& aRect,
|
|
359 |
const CCoeControl* aParent,
|
|
360 |
CFreestyleEmailUiAppUi& aAppUi,
|
|
361 |
CFSMailClient& aMailClient,
|
|
362 |
CFsEmailSettingsListView& aView )
|
|
363 |
{
|
|
364 |
FUNC_LOG;
|
|
365 |
|
|
366 |
CFsEmailSettingsList* self = CFsEmailSettingsList::NewLC(
|
|
367 |
aRect,
|
|
368 |
aParent,
|
|
369 |
aAppUi,
|
|
370 |
aMailClient,
|
|
371 |
aView );
|
|
372 |
CleanupStack::Pop( self );
|
|
373 |
|
|
374 |
return self;
|
|
375 |
}
|
|
376 |
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
// Construct the control (first phase).
|
|
379 |
//
|
|
380 |
// @param aRect bounding rectangle
|
|
381 |
// @param aParent owning parent, or NULL
|
|
382 |
// @param aAppUi pointer to AppUi
|
|
383 |
// @param aMailClient reference to freestyle mail client
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
CFsEmailSettingsList* CFsEmailSettingsList::NewLC(
|
|
387 |
const TRect& aRect,
|
|
388 |
const CCoeControl* aParent,
|
|
389 |
CFreestyleEmailUiAppUi& aAppUi,
|
|
390 |
CFSMailClient& aMailClient,
|
|
391 |
CFsEmailSettingsListView& aView )
|
|
392 |
{
|
|
393 |
FUNC_LOG;
|
|
394 |
|
|
395 |
CFsEmailSettingsList* self = new ( ELeave ) CFsEmailSettingsList(aAppUi, aMailClient, aView );
|
|
396 |
CleanupStack::PushL( self );
|
|
397 |
self->ConstructL( aRect, aParent);
|
|
398 |
|
|
399 |
return self;
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------------------------
|
|
403 |
// Construct the control (first phase).
|
|
404 |
//
|
|
405 |
// @param aRect bounding rectangle
|
|
406 |
// @param aParent owning parent, or NULL
|
|
407 |
// @param aAppUi pointer to AppUi
|
|
408 |
// @param aMailClient reference to freestyle mail client
|
|
409 |
// ---------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
void CFsEmailSettingsList::ConstructL(
|
|
412 |
const TRect& aRect,
|
|
413 |
const CCoeControl* aParent )
|
|
414 |
{
|
|
415 |
FUNC_LOG;
|
|
416 |
|
|
417 |
if ( aParent == NULL )
|
|
418 |
{
|
|
419 |
CreateWindowL();
|
|
420 |
}
|
|
421 |
else
|
|
422 |
{
|
|
423 |
SetContainerWindowL( *aParent );
|
|
424 |
}
|
|
425 |
|
|
426 |
iFocusControl = NULL;
|
|
427 |
InitializeControlsL();
|
|
428 |
SetRect( aRect );
|
|
429 |
ActivateL();
|
|
430 |
}
|
|
431 |
|
|
432 |
// ---------------------------------------------------------------------------
|
|
433 |
// Return the number of controls in the container (override)
|
|
434 |
// @return count
|
|
435 |
// ---------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
TInt CFsEmailSettingsList::CountComponentControls() const
|
|
438 |
{
|
|
439 |
FUNC_LOG;
|
|
440 |
return ( int ) ELastControl;
|
|
441 |
}
|
|
442 |
|
|
443 |
// ---------------------------------------------------------------------------
|
|
444 |
// Get the control with the given index
|
|
445 |
// @param aIndex Control index [0...n) (limited by #CountComponentControls)
|
|
446 |
// @return Pointer to control
|
|
447 |
// ---------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
CCoeControl* CFsEmailSettingsList::ComponentControl( TInt aIndex ) const
|
|
450 |
{
|
|
451 |
FUNC_LOG;
|
|
452 |
|
|
453 |
switch ( aIndex )
|
|
454 |
{
|
|
455 |
case EListBox:
|
|
456 |
return iListBox;
|
|
457 |
}
|
|
458 |
|
|
459 |
return NULL;
|
|
460 |
}
|
|
461 |
|
|
462 |
// ---------------------------------------------------------------------------
|
|
463 |
// SizeChanged
|
|
464 |
// ---------------------------------------------------------------------------
|
|
465 |
//
|
|
466 |
void CFsEmailSettingsList::SizeChanged()
|
|
467 |
{
|
|
468 |
FUNC_LOG;
|
|
469 |
|
|
470 |
CCoeControl::SizeChanged();
|
|
471 |
LayoutControls();
|
|
472 |
|
|
473 |
}
|
|
474 |
|
|
475 |
|
|
476 |
// ---------------------------------------------------------------------------
|
|
477 |
// Layout components as specified in the UI Designer
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
//
|
|
480 |
void CFsEmailSettingsList::LayoutControls()
|
|
481 |
{
|
|
482 |
FUNC_LOG;
|
|
483 |
|
|
484 |
iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() );
|
|
485 |
|
|
486 |
}
|
|
487 |
|
|
488 |
// ---------------------------------------------------------------------------
|
|
489 |
// Handle events from listbox.
|
|
490 |
// ---------------------------------------------------------------------------
|
|
491 |
//
|
|
492 |
void CFsEmailSettingsList::HandleListBoxEventL( CEikListBox *aListBox, TListBoxEvent aEventType )
|
|
493 |
{
|
|
494 |
FUNC_LOG;
|
|
495 |
|
|
496 |
if ( aListBox )
|
|
497 |
{
|
|
498 |
if ( aEventType == EEventItemSingleClicked ||
|
|
499 |
aEventType == EEventEnterKeyPressed )
|
|
500 |
{
|
|
501 |
HandleUserSelectionsL();
|
|
502 |
// Fix for EJSA-82HB3F, improves fix for EELN-7Y78DM
|
|
503 |
// Update title pane, needed for touch support
|
|
504 |
HBufC* text = CreateTitlePaneTextLC();
|
|
505 |
iAppUi.SetTitlePaneTextL( *text );
|
|
506 |
CleanupStack::PopAndDestroy( text );
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
}
|
|
511 |
|
|
512 |
// ---------------------------------------------------------------------------
|
|
513 |
// HandleUserSelectionsL
|
|
514 |
//
|
|
515 |
// check where we are in navigation and decide where to go
|
|
516 |
// based on selection commands
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
void CFsEmailSettingsList::HandleUserSelectionsL()
|
|
520 |
{
|
|
521 |
FUNC_LOG;
|
|
522 |
|
|
523 |
iView.HideStylusPopUpMenu();
|
|
524 |
|
|
525 |
TInt index = iListBox->CurrentItemIndex();
|
|
526 |
TInt count = Count();
|
|
527 |
|
|
528 |
// If we are at the main level
|
|
529 |
if ( iCurrentSubView == EFsEmailSettingsMainListView )
|
|
530 |
{
|
|
531 |
// Open global settings
|
|
532 |
if ( index == 0 )
|
|
533 |
{
|
|
534 |
// activate global settings list
|
|
535 |
SetSelectedMainListIndex( index );
|
|
536 |
iAppUi.EnterFsEmailViewL( GlobalSettingsViewId );
|
|
537 |
}
|
|
538 |
// Open selected mailbox settings
|
|
539 |
else if ( index > 0 && index <= iMailboxCount )
|
|
540 |
{
|
|
541 |
// set mailbox info
|
|
542 |
CFSMailBox* mailbox = GetMailboxByIndexLC( index-1 );
|
|
543 |
iSelectedAccountInfo = mailbox->GetId();
|
|
544 |
iSelectedPluginSettings = mailbox->GetSettingsUid();
|
|
545 |
CleanupStack::PopAndDestroy( mailbox );
|
|
546 |
// don't active pimlist subview, set flag to false
|
|
547 |
iPIMListActivation = EFalse;
|
|
548 |
if ( iSelectedPluginSettings == TUid::Null() )
|
|
549 |
{
|
|
550 |
#ifdef _DEBUG
|
|
551 |
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
|
|
552 |
informationNote->ExecuteLD(_L("No plugin Uid found"));
|
|
553 |
#endif // _DEBUG
|
|
554 |
}
|
|
555 |
else
|
|
556 |
{
|
|
557 |
SetSelectedMainListIndex( index );
|
|
558 |
CreatePluginSubviewListL( iSelectedPluginSettings );
|
|
559 |
}
|
|
560 |
}
|
|
561 |
// Create PIM settings as a second level items
|
|
562 |
else if ( index > iMailboxCount )
|
|
563 |
{
|
|
564 |
CFSMailBox* mailbox = GetMailboxByIndexLC( iPIMSyncMailboxIndex );
|
|
565 |
iSelectedAccountInfo = mailbox->GetId();
|
|
566 |
iSelectedPluginSettings = mailbox->GetSettingsUid();
|
|
567 |
CleanupStack::PopAndDestroy( mailbox );
|
|
568 |
iPIMListActivation = ETrue;
|
|
569 |
SetSelectedMainListIndex( index );
|
|
570 |
CreatePluginPIMListL( iSelectedPluginSettings );
|
|
571 |
}
|
|
572 |
else // index < 0; this should never happen
|
|
573 |
{
|
|
574 |
__ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) );
|
|
575 |
}
|
|
576 |
}
|
|
577 |
|
|
578 |
// In second level list, activate selected plugin settings view or
|
|
579 |
// open PIM service dialog if first item selected in PIM list
|
|
580 |
else
|
|
581 |
{
|
|
582 |
if ( iPIMServiceSettingsSelection && index == 0 )
|
|
583 |
{
|
|
584 |
// open PIM service settings selection dialog
|
|
585 |
OpenPIMServiceDialogL();
|
|
586 |
}
|
|
587 |
else
|
|
588 |
{
|
|
589 |
ActivateMailSettingsPluginSubViewL( index );
|
|
590 |
}
|
|
591 |
}
|
|
592 |
|
|
593 |
}
|
|
594 |
|
|
595 |
// ---------------------------------------------------------------------------
|
|
596 |
// Handle key events.
|
|
597 |
// ---------------------------------------------------------------------------
|
|
598 |
//
|
|
599 |
TKeyResponse CFsEmailSettingsList::OfferKeyEventL(
|
|
600 |
const TKeyEvent& aKeyEvent,
|
|
601 |
TEventCode aType )
|
|
602 |
{
|
|
603 |
FUNC_LOG;
|
|
604 |
|
|
605 |
// Handle shortcuts
|
|
606 |
if ( aType == EEventKey )
|
|
607 |
{
|
|
608 |
TInt commandId = iAppUi.ShortcutBinding().CommandForShortcutKey( aKeyEvent, CFSEmailUiShortcutBinding::EContextSettings );
|
|
609 |
if ( commandId >= 0 )
|
|
610 |
{
|
|
611 |
iAppUi.View( SettingsViewId )->HandleCommandL( commandId );
|
|
612 |
}
|
|
613 |
}
|
|
614 |
|
|
615 |
if ( aKeyEvent.iCode == EKeyLeftArrow
|
|
616 |
|| aKeyEvent.iCode == EKeyRightArrow )
|
|
617 |
{
|
|
618 |
// Listbox takes all events even if it doesn't use them
|
|
619 |
return EKeyWasNotConsumed;
|
|
620 |
}
|
|
621 |
|
|
622 |
if ( iFocusControl != NULL
|
|
623 |
&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
|
|
624 |
{
|
|
625 |
return EKeyWasConsumed;
|
|
626 |
}
|
|
627 |
|
|
628 |
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
|
|
629 |
}
|
|
630 |
|
|
631 |
|
|
632 |
// ---------------------------------------------------------------------------
|
|
633 |
// Initialize each control upon creation.
|
|
634 |
// ---------------------------------------------------------------------------
|
|
635 |
//
|
|
636 |
void CFsEmailSettingsList::InitializeControlsL()
|
|
637 |
{
|
|
638 |
FUNC_LOG;
|
|
639 |
|
|
640 |
// Create list box control
|
|
641 |
iListBox = new ( ELeave ) CSettingsListType;
|
|
642 |
iListBox->SetContainerWindowL( *this );
|
|
643 |
{
|
|
644 |
TResourceReader reader;
|
|
645 |
iEikonEnv->CreateResourceReaderLC( reader, R_FS_EMAIL_SETTINGS_LIST_LIST_BOX );
|
|
646 |
iListBox->ConstructFromResourceL( reader );
|
|
647 |
CleanupStack::PopAndDestroy(); // reader internal state
|
|
648 |
}
|
|
649 |
// the listbox owns the items in the list and will free them
|
|
650 |
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
|
|
651 |
|
|
652 |
// setup the icon array so graphics-style boxes work
|
|
653 |
SetupListBoxIconsL();
|
|
654 |
|
|
655 |
// Create scrollbar
|
|
656 |
iListBox->CreateScrollBarFrameL();
|
|
657 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
658 |
CEikScrollBarFrame::EOff,
|
|
659 |
CEikScrollBarFrame::EAuto );
|
|
660 |
|
|
661 |
iListBox->SetFocus( ETrue );
|
|
662 |
iFocusControl = iListBox;
|
|
663 |
|
|
664 |
// event listener this class
|
|
665 |
iListBox->SetListBoxObserver( this );
|
|
666 |
|
|
667 |
// Construct the long tap detector.
|
|
668 |
iLongTapDetector = CAknLongTapDetector::NewL( this );
|
|
669 |
}
|
|
670 |
|
|
671 |
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
// Handle global resource changes, such as scalable UI or skin events (override)
|
|
674 |
// ---------------------------------------------------------------------------
|
|
675 |
//
|
|
676 |
void CFsEmailSettingsList::HandleResourceChange( TInt aType )
|
|
677 |
{
|
|
678 |
FUNC_LOG;
|
|
679 |
|
|
680 |
CCoeControl::HandleResourceChange( aType );
|
|
681 |
SetRect( iAvkonViewAppUi->View( SettingsViewId )->ClientRect() );
|
|
682 |
}
|
|
683 |
|
|
684 |
|
|
685 |
// -----------------------------------------------------------------------------
|
|
686 |
// CFsEmailSettingsList::HandlePointerEventL()
|
|
687 |
// From CCoeControl.
|
|
688 |
// -----------------------------------------------------------------------------
|
|
689 |
//
|
|
690 |
void CFsEmailSettingsList::HandlePointerEventL(
|
|
691 |
const TPointerEvent& aPointerEvent )
|
|
692 |
{
|
|
693 |
// Pass the event to the long tap detector.
|
|
694 |
iLongTapDetector->PointerEventL( aPointerEvent );
|
|
695 |
|
|
696 |
if ( !iLongTapEventConsumed )
|
|
697 |
{
|
|
698 |
// Call HandlePointerEventL() of the base class.
|
|
699 |
CCoeControl::HandlePointerEventL( aPointerEvent );
|
|
700 |
}
|
|
701 |
else
|
|
702 |
{
|
|
703 |
iLongTapEventConsumed = EFalse;
|
|
704 |
}
|
|
705 |
}
|
|
706 |
|
|
707 |
|
|
708 |
// ---------------------------------------------------------------------------
|
|
709 |
// Draw container contents.
|
|
710 |
// ---------------------------------------------------------------------------
|
|
711 |
//
|
|
712 |
void CFsEmailSettingsList::Draw( const TRect& aRect ) const
|
|
713 |
{
|
|
714 |
FUNC_LOG;
|
|
715 |
|
|
716 |
CWindowGc& gc = SystemGc();
|
|
717 |
gc.Clear( aRect );
|
|
718 |
|
|
719 |
}
|
|
720 |
|
|
721 |
|
|
722 |
// ---------------------------------------------------------------------------
|
|
723 |
// Count
|
|
724 |
//
|
|
725 |
// Retuns number of item in list
|
|
726 |
// ---------------------------------------------------------------------------
|
|
727 |
//
|
|
728 |
TInt CFsEmailSettingsList::Count()
|
|
729 |
{
|
|
730 |
FUNC_LOG;
|
|
731 |
|
|
732 |
CDesCArray* itemArray = static_cast<CDesCArray*>( iListBox->Model()->ItemTextArray() );
|
|
733 |
TInt count( itemArray->Count() );
|
|
734 |
|
|
735 |
return count;
|
|
736 |
}
|
|
737 |
|
|
738 |
// ---------------------------------------------------------------------------
|
|
739 |
// Get the listbox pointer.
|
|
740 |
// ---------------------------------------------------------------------------
|
|
741 |
//
|
|
742 |
CSettingsListType* CFsEmailSettingsList::ListBox()
|
|
743 |
{
|
|
744 |
FUNC_LOG;
|
|
745 |
return iListBox;
|
|
746 |
}
|
|
747 |
|
|
748 |
// ---------------------------------------------------------------------------
|
|
749 |
// Get the listbox pointer.
|
|
750 |
// ---------------------------------------------------------------------------
|
|
751 |
//
|
|
752 |
TBool CFsEmailSettingsList::PIMSyncItemVisible()
|
|
753 |
{
|
|
754 |
FUNC_LOG;
|
|
755 |
return ( iPIMSyncMailboxIndex == -1 ) ? EFalse : ETrue;
|
|
756 |
}
|
|
757 |
|
|
758 |
|
|
759 |
// -----------------------------------------------------------------------------
|
|
760 |
// CFsEmailSettingsList::HandleLongTapEventL()
|
|
761 |
// From MAknLongTapDetectorCallBack.
|
|
762 |
// -----------------------------------------------------------------------------
|
|
763 |
//
|
|
764 |
void CFsEmailSettingsList::HandleLongTapEventL(
|
|
765 |
const TPoint& aPenEventLocation,
|
|
766 |
const TPoint& aPenEventScreenLocation )
|
|
767 |
{
|
|
768 |
// Get the item index based on the position of the tap event.
|
|
769 |
TInt itemIndex( 0 );
|
|
770 |
TBool itemSelected =
|
|
771 |
iListBox->View()->XYPosToItemIndex( aPenEventLocation,
|
|
772 |
itemIndex );
|
|
773 |
|
|
774 |
if ( itemSelected && itemIndex >= 0 )
|
|
775 |
{
|
|
776 |
// Update the item index based on the position of the tap event.
|
|
777 |
iListBox->SetCurrentItemIndex( itemIndex );
|
|
778 |
|
|
779 |
if ( SelectedItemIsMailbox() )
|
|
780 |
{
|
|
781 |
iView.DisplayStylusPopUpMenu( aPenEventScreenLocation );
|
|
782 |
}
|
|
783 |
|
|
784 |
iLongTapEventConsumed = ETrue;
|
|
785 |
}
|
|
786 |
}
|
|
787 |
|
|
788 |
|
|
789 |
// ---------------------------------------------------------------------------
|
|
790 |
// Create a list box item for plain text
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
//
|
|
793 |
HBufC* CFsEmailSettingsList::CreateListBoxItemLC(
|
|
794 |
const TDesC& aMainText )
|
|
795 |
{
|
|
796 |
FUNC_LOG;
|
|
797 |
|
|
798 |
_LIT ( KStringHeader, "\t%S" );
|
|
799 |
HBufC* temp = HBufC::NewLC( aMainText.Length() + KStringHeader().Length() );
|
|
800 |
TPtr tempPtr = temp->Des();
|
|
801 |
tempPtr.Format( KStringHeader(), &aMainText );
|
|
802 |
|
|
803 |
return temp;
|
|
804 |
}
|
|
805 |
|
|
806 |
// ---------------------------------------------------------------------------
|
|
807 |
// Create a list box item for text and icon
|
|
808 |
// ---------------------------------------------------------------------------
|
|
809 |
//
|
|
810 |
HBufC* CFsEmailSettingsList::CreateListBoxItemLC(
|
|
811 |
const TDesC& aMainText,
|
|
812 |
TInt aIconNum )
|
|
813 |
{
|
|
814 |
FUNC_LOG;
|
|
815 |
|
|
816 |
_LIT ( KStringHeader, "\t%S\t%d" );
|
|
817 |
HBufC* temp = HBufC::NewLC( aMainText.Length() + KStringHeader().Length() );
|
|
818 |
TPtr tempPtr = temp->Des();
|
|
819 |
tempPtr.Format( KStringHeader(), &aMainText, aIconNum );
|
|
820 |
|
|
821 |
return temp;
|
|
822 |
}
|
|
823 |
|
|
824 |
// ---------------------------------------------------------------------------
|
|
825 |
// Insert given item in a list
|
|
826 |
// ---------------------------------------------------------------------------
|
|
827 |
//
|
|
828 |
void CFsEmailSettingsList::AppendItemL( TDesC& aListItem )
|
|
829 |
{
|
|
830 |
FUNC_LOG;
|
|
831 |
|
|
832 |
CDesCArray* itemArray = static_cast<CDesCArray*>(
|
|
833 |
iListBox->Model()->ItemTextArray() );
|
|
834 |
itemArray->AppendL( aListItem );
|
|
835 |
}
|
|
836 |
|
|
837 |
// ---------------------------------------------------------------------------
|
|
838 |
// Set up the list's icon array.
|
|
839 |
// ---------------------------------------------------------------------------
|
|
840 |
//
|
|
841 |
void CFsEmailSettingsList::SetupListBoxIconsL()
|
|
842 |
{
|
|
843 |
FUNC_LOG;
|
|
844 |
|
|
845 |
CArrayPtr<CGulIcon>* icons = new (ELeave) CArrayPtrFlat<CGulIcon>( 3 );
|
|
846 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
|
|
847 |
}
|
|
848 |
|
|
849 |
// ---------------------------------------------------------------------------
|
|
850 |
// ProtocolBrandingIconL
|
|
851 |
//
|
|
852 |
// Sets mailbox protocol branding icon to list box by given id
|
|
853 |
// ---------------------------------------------------------------------------
|
|
854 |
//
|
|
855 |
void CFsEmailSettingsList::ProtocolBrandingIconL( TFSMailMsgId aMailBoxId )
|
|
856 |
{
|
|
857 |
FUNC_LOG;
|
|
858 |
|
|
859 |
MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL();
|
|
860 |
CGulIcon* mailBoxIcon(0);
|
|
861 |
TRAPD( err, mailBoxIcon = brandManager.GetGraphicL( EFSMailboxIcon, aMailBoxId ) );
|
|
862 |
|
|
863 |
if ( err != KErrNone || !mailBoxIcon )
|
|
864 |
{
|
|
865 |
CFbsBitmap* bitmap(0);
|
|
866 |
CFbsBitmap* mask(0);
|
|
867 |
|
|
868 |
TFileName iconFileName;
|
|
869 |
TFsEmailUiUtility::GetFullIconFileNameL( iconFileName );
|
|
870 |
|
|
871 |
// <cmail> icons changed
|
|
872 |
AknIconUtils::CreateIconL( bitmap , mask , iconFileName,
|
|
873 |
EMbmFreestyleemailuiQgn_indi_cmail_drop_email_account,
|
|
874 |
EMbmFreestyleemailuiQgn_indi_cmail_drop_email_account_mask );
|
|
875 |
// </cmail>
|
|
876 |
CleanupStack::PushL( bitmap );
|
|
877 |
CleanupStack::PushL( mask );
|
|
878 |
|
|
879 |
// create default mailbox icon from bitmaps
|
|
880 |
mailBoxIcon = CGulIcon::NewL( bitmap, mask );
|
|
881 |
CleanupStack::Pop( mask );
|
|
882 |
CleanupStack::Pop( bitmap );
|
|
883 |
}
|
|
884 |
|
|
885 |
CArrayPtr<CGulIcon>* icons = iListBox->ItemDrawer()->ColumnData()->IconArray();
|
|
886 |
CleanupStack::PushL( mailBoxIcon );
|
|
887 |
icons->AppendL( mailBoxIcon );
|
|
888 |
CleanupStack::Pop( mailBoxIcon );
|
|
889 |
}
|
|
890 |
|
|
891 |
|
|
892 |
// ---------------------------------------------------------------------------
|
|
893 |
// ClearListL
|
|
894 |
//
|
|
895 |
// Removes all items from list
|
|
896 |
// ---------------------------------------------------------------------------
|
|
897 |
//
|
|
898 |
void CFsEmailSettingsList::ClearListL()
|
|
899 |
{
|
|
900 |
FUNC_LOG;
|
|
901 |
|
|
902 |
CDesCArray* itemArray = static_cast<CDesCArray*>(
|
|
903 |
iListBox->Model()->ItemTextArray() );
|
|
904 |
itemArray->Reset();
|
|
905 |
iListBox->ItemDrawer()->ColumnData()->IconArray()->ResetAndDestroy();
|
|
906 |
iListBox->HandleItemRemovalL();
|
|
907 |
}
|
|
908 |
|
|
909 |
// ---------------------------------------------------------------------------
|
|
910 |
// GetMailboxByIndexLC
|
|
911 |
//
|
|
912 |
// @return CFSMailBox pointer, ownership is transferred
|
|
913 |
// ---------------------------------------------------------------------------
|
|
914 |
//
|
|
915 |
CFSMailBox* CFsEmailSettingsList::GetMailboxByIndexLC( const TInt& aIndex ) const
|
|
916 |
{
|
|
917 |
FUNC_LOG;
|
|
918 |
|
|
919 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
920 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
921 |
mailBoxes.Reset();
|
|
922 |
TFSMailMsgId plugin;
|
|
923 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
924 |
CFSMailBox* mailbox = NULL;
|
|
925 |
if ( aIndex > -1 && aIndex < mailBoxes.Count() )
|
|
926 |
{
|
|
927 |
mailbox = iMailClient.GetMailBoxByUidL( mailBoxes[aIndex]->GetId() );
|
|
928 |
}
|
|
929 |
User::LeaveIfNull( mailbox );
|
|
930 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
931 |
CleanupStack::PushL( mailbox );
|
|
932 |
return mailbox;
|
|
933 |
}
|
|
934 |
|
|
935 |
// ---------------------------------------------------------------------------
|
|
936 |
// GetMailBoxByIdL
|
|
937 |
//
|
|
938 |
// @return CFSMailBox pointer, ownership is transferred
|
|
939 |
// ---------------------------------------------------------------------------
|
|
940 |
//
|
|
941 |
CFSMailBox* CFsEmailSettingsList::GetMailBoxByIdL( const TUint& aMailboxId ) const
|
|
942 |
{
|
|
943 |
FUNC_LOG;
|
|
944 |
|
|
945 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
946 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
947 |
mailBoxes.Reset();
|
|
948 |
TFSMailMsgId plugin;
|
|
949 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
950 |
CFSMailBox* mailbox = NULL;
|
|
951 |
for ( TInt i = 0; i < mailBoxes.Count(); ++i )
|
|
952 |
{
|
|
953 |
if ( mailBoxes[i]->GetId().Id() == aMailboxId )
|
|
954 |
{
|
|
955 |
TRAP_IGNORE( mailbox = iMailClient.GetMailBoxByUidL( mailBoxes[i]->GetId() ) );
|
|
956 |
break;
|
|
957 |
}
|
|
958 |
}
|
|
959 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
960 |
return mailbox;
|
|
961 |
}
|
|
962 |
|
|
963 |
// ---------------------------------------------------------------------------
|
|
964 |
// GetMailboxCountL
|
|
965 |
//
|
|
966 |
// @return TInt amount of mailboxes
|
|
967 |
// ---------------------------------------------------------------------------
|
|
968 |
//
|
|
969 |
TInt CFsEmailSettingsList::GetMailboxCountL() const
|
|
970 |
{
|
|
971 |
FUNC_LOG;
|
|
972 |
|
|
973 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
974 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
975 |
mailBoxes.Reset();
|
|
976 |
TFSMailMsgId plugin;
|
|
977 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
978 |
TInt count = mailBoxes.Count();
|
|
979 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
980 |
|
|
981 |
return count;
|
|
982 |
}
|
|
983 |
|
|
984 |
// ---------------------------------------------------------------------------
|
|
985 |
// CreateAccountListL
|
|
986 |
// Creates mailbox list for settings
|
|
987 |
// @return void
|
|
988 |
// ---------------------------------------------------------------------------
|
|
989 |
//
|
|
990 |
void CFsEmailSettingsList::CreateAccountListL()
|
|
991 |
{
|
|
992 |
FUNC_LOG;
|
|
993 |
|
|
994 |
LoadAccountsToListL();
|
|
995 |
|
|
996 |
// we are on first level of the list box
|
|
997 |
iCurrentSubView = EFsEmailSettingsMainListView;
|
|
998 |
|
|
999 |
}
|
|
1000 |
|
|
1001 |
// ---------------------------------------------------------------------------
|
|
1002 |
// Get2ndLevelListIndicator
|
|
1003 |
// Indicates the state of list. Are the "second level" of items displayed
|
|
1004 |
// @return TBool
|
|
1005 |
// ---------------------------------------------------------------------------
|
|
1006 |
//
|
|
1007 |
TBool CFsEmailSettingsList::Get2ndLevelListIndicator()
|
|
1008 |
{
|
|
1009 |
FUNC_LOG;
|
|
1010 |
return ( iCurrentSubView != EFsEmailSettingsMainListView );
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
// ---------------------------------------------------------------------------
|
|
1014 |
// SetPluginSettingsUid
|
|
1015 |
// @return void
|
|
1016 |
// ---------------------------------------------------------------------------
|
|
1017 |
//
|
|
1018 |
void CFsEmailSettingsList::SetPluginSettingsUid( const TUid& aPluginId )
|
|
1019 |
{
|
|
1020 |
FUNC_LOG;
|
|
1021 |
iSelectedPluginSettings = aPluginId;
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
// ---------------------------------------------------------------------------
|
|
1025 |
// GetSettingsPluginL
|
|
1026 |
// Creates needed settings plugin instance and register it to view stack
|
|
1027 |
// Ownership is not transferred
|
|
1028 |
// @return CESMailSettingsPlugin*
|
|
1029 |
// ---------------------------------------------------------------------------
|
|
1030 |
//
|
|
1031 |
CESMailSettingsPlugin* CFsEmailSettingsList::GetSettingsPluginL( TUid aUid )
|
|
1032 |
{
|
|
1033 |
FUNC_LOG;
|
|
1034 |
CESMailSettingsPlugin* settingsPlugin =
|
|
1035 |
static_cast<CESMailSettingsPlugin*>( iAppUi.View( aUid ) );
|
|
1036 |
|
|
1037 |
if ( settingsPlugin == NULL )
|
|
1038 |
{
|
|
1039 |
TInt err( KErrNone );
|
|
1040 |
|
|
1041 |
TRAP( err, settingsPlugin = CESMailSettingsPlugin::NewL( aUid ););
|
|
1042 |
if ( err == KErrNoMemory )
|
|
1043 |
{
|
|
1044 |
User::Leave( err );
|
|
1045 |
}
|
|
1046 |
else if ( err == KErrNone )
|
|
1047 |
{
|
|
1048 |
CleanupStack::PushL(settingsPlugin);
|
|
1049 |
iAppUi.AddViewL( settingsPlugin );
|
|
1050 |
CleanupStack::Pop(settingsPlugin);
|
|
1051 |
}
|
|
1052 |
else
|
|
1053 |
{
|
|
1054 |
}
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
return settingsPlugin;
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
|
|
1061 |
// ---------------------------------------------------------------------------
|
|
1062 |
// SetSelectedSubListIndex
|
|
1063 |
// @return void
|
|
1064 |
// ---------------------------------------------------------------------------
|
|
1065 |
//
|
|
1066 |
void CFsEmailSettingsList::SetSelectedSubListIndex( TInt aIndex )
|
|
1067 |
{
|
|
1068 |
FUNC_LOG;
|
|
1069 |
if ( aIndex >= 0 )
|
|
1070 |
{
|
|
1071 |
iSelectedSubListIndex = aIndex;
|
|
1072 |
}
|
|
1073 |
else
|
|
1074 |
{
|
|
1075 |
iSelectedSubListIndex = 0;
|
|
1076 |
}
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
// ---------------------------------------------------------------------------
|
|
1080 |
// SetSelectedMainListIndex
|
|
1081 |
// Saves mailbox list index to parent when settings plugin view is activated
|
|
1082 |
// because this container is destroyed during the view switch
|
|
1083 |
// @return void
|
|
1084 |
// ---------------------------------------------------------------------------
|
|
1085 |
//
|
|
1086 |
void CFsEmailSettingsList::SetSelectedMainListIndex( TInt aIndex )
|
|
1087 |
{
|
|
1088 |
FUNC_LOG;
|
|
1089 |
CFsEmailSettingsListView* parent =
|
|
1090 |
static_cast<CFsEmailSettingsListView*>( iAppUi.View( SettingsViewId ) );
|
|
1091 |
|
|
1092 |
if ( aIndex >= 0 )
|
|
1093 |
{
|
|
1094 |
parent->SetSelectedMainListIndex( aIndex );
|
|
1095 |
}
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
// ---------------------------------------------------------------------------
|
|
1099 |
// GetSelectedMainListIndex
|
|
1100 |
// Returns latest mailbox list item index which is saved in parent view
|
|
1101 |
// @return void
|
|
1102 |
// ---------------------------------------------------------------------------
|
|
1103 |
//
|
|
1104 |
TInt CFsEmailSettingsList::GetSelectedMainListIndex() const
|
|
1105 |
{
|
|
1106 |
FUNC_LOG;
|
|
1107 |
CFsEmailSettingsListView* parent =
|
|
1108 |
static_cast<CFsEmailSettingsListView*>( iAppUi.View( SettingsViewId ) );
|
|
1109 |
|
|
1110 |
TInt index = parent->GetSelectedMainListIndex();
|
|
1111 |
|
|
1112 |
if ( index < 0 )
|
|
1113 |
{
|
|
1114 |
index = 0;
|
|
1115 |
}
|
|
1116 |
|
|
1117 |
return index;
|
|
1118 |
}
|
|
1119 |
|
|
1120 |
// ---------------------------------------------------------------------------
|
|
1121 |
// LoadAccountsToListL
|
|
1122 |
// Loads global settings and account names to list dynamically
|
|
1123 |
// from fs mail client
|
|
1124 |
// @return void
|
|
1125 |
// ---------------------------------------------------------------------------
|
|
1126 |
//
|
|
1127 |
void CFsEmailSettingsList::LoadAccountsToListL()
|
|
1128 |
{
|
|
1129 |
FUNC_LOG;
|
|
1130 |
|
|
1131 |
// Remove current items
|
|
1132 |
ClearListL();
|
|
1133 |
// Insert Global settings as a first item
|
|
1134 |
HBufC* localizedText = StringLoader::LoadLC(
|
|
1135 |
R_FS_EMAIL_SETTINGS_LIST_GLOBAL_SETTINGS_TXT );
|
|
1136 |
HBufC* listItemBuffer = CreateListBoxItemLC( *localizedText );
|
|
1137 |
AppendItemL( *listItemBuffer );
|
|
1138 |
CleanupStack::PopAndDestroy( 2, localizedText ); // localizedText listItemBuffer
|
|
1139 |
|
|
1140 |
// get mailboxes from every plugin
|
|
1141 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
1142 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
1143 |
mailBoxes.Reset();
|
|
1144 |
TFSMailMsgId plugin;
|
|
1145 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
1146 |
|
|
1147 |
TUid PIMpluginUid = TUid::Null();
|
|
1148 |
// Set initial pim sync values
|
|
1149 |
iPIMSyncCount = 0;
|
|
1150 |
iPIMSyncMailboxIndex = KErrNotFound;
|
|
1151 |
|
|
1152 |
iMailboxCount = mailBoxes.Count();
|
|
1153 |
|
|
1154 |
|
|
1155 |
for ( TInt i=0 ; i < iMailboxCount ; ++i )
|
|
1156 |
{
|
|
1157 |
CFSMailBox* mailBox = mailBoxes[i];
|
|
1158 |
|
|
1159 |
// get protocol icon index
|
|
1160 |
ProtocolBrandingIconL( mailBox->GetId() );
|
|
1161 |
|
|
1162 |
// get mailbox name and insert it to listBox
|
|
1163 |
TPtrC mbName = GetMailBoxNameL( *mailBox );
|
|
1164 |
listItemBuffer = CreateListBoxItemLC( mbName, i );
|
|
1165 |
AppendItemL( *listItemBuffer );
|
|
1166 |
CleanupStack::PopAndDestroy( listItemBuffer ); // listItemBuffer
|
|
1167 |
|
|
1168 |
// Does mailbox have settings plugin
|
|
1169 |
if ( mailBox->GetSettingsUid() != TUid::Null() )
|
|
1170 |
{
|
|
1171 |
// load settings ECOM plugin
|
|
1172 |
TUid pluginUid = mailBox->GetSettingsUid();
|
|
1173 |
CESMailSettingsPlugin* tempPlugin;
|
|
1174 |
tempPlugin = GetSettingsPluginL( pluginUid ); // ownership not transferred
|
|
1175 |
|
|
1176 |
if ( tempPlugin != NULL )
|
|
1177 |
{
|
|
1178 |
// check if mailboxes can handle PIM sync
|
|
1179 |
TBool canHandlePIMSync = tempPlugin->CanHandlePIMSync();
|
|
1180 |
if ( canHandlePIMSync && PIMpluginUid != pluginUid )
|
|
1181 |
{
|
|
1182 |
PIMpluginUid = pluginUid;
|
|
1183 |
++iPIMSyncCount;
|
|
1184 |
if ( tempPlugin->IsSelectedForPIMSync() )
|
|
1185 |
{
|
|
1186 |
iPIMSyncMailboxIndex = i;
|
|
1187 |
}
|
|
1188 |
// if protocol supports PIM sync, but is not selected yet
|
|
1189 |
if ( iPIMSyncCount > 0 && iPIMSyncMailboxIndex == -1 )
|
|
1190 |
{
|
|
1191 |
iPIMSyncMailboxIndex = i;
|
|
1192 |
}
|
|
1193 |
}
|
|
1194 |
}
|
|
1195 |
}
|
|
1196 |
else
|
|
1197 |
{
|
|
1198 |
}
|
|
1199 |
}
|
|
1200 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
1201 |
|
|
1202 |
// if one of the mailboxes can handle PIM sync
|
|
1203 |
// display PIM settings item in list.
|
|
1204 |
if ( iPIMSyncCount > 0 )
|
|
1205 |
{
|
|
1206 |
HBufC* text2 = StringLoader::LoadLC( R_FS_EMAIL_SETTINGS_LIST_PIM_SETTINGS_TXT );
|
|
1207 |
listItemBuffer = CreateListBoxItemLC( *text2 );
|
|
1208 |
AppendItemL( *listItemBuffer );
|
|
1209 |
CleanupStack::PopAndDestroy( 2, text2 ); // text2 listItemBuffer
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
// update list
|
|
1213 |
iListBox->HandleItemAdditionL();
|
|
1214 |
if ( GetSelectedMainListIndex() > iListBox->BottomItemIndex() )
|
|
1215 |
{
|
|
1216 |
iListBox->SetCurrentItemIndex( 0 ) ;
|
|
1217 |
}
|
|
1218 |
else if ( GetSelectedMainListIndex() < 0 )
|
|
1219 |
{
|
|
1220 |
iListBox->SetCurrentItemIndex( 0 ) ;
|
|
1221 |
}
|
|
1222 |
else
|
|
1223 |
{
|
|
1224 |
iListBox->SetCurrentItemIndex( GetSelectedMainListIndex() );
|
|
1225 |
}
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
|
|
1229 |
// ---------------------------------------------------------------------------
|
|
1230 |
// DisplayCreateMailboxNoteIfNeededL
|
|
1231 |
// @return void
|
|
1232 |
// ---------------------------------------------------------------------------
|
|
1233 |
//
|
|
1234 |
void CFsEmailSettingsList::DisplayCreateMailboxNoteIfNeededL()
|
|
1235 |
{
|
|
1236 |
FUNC_LOG;
|
|
1237 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
1238 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
1239 |
mailBoxes.Reset();
|
|
1240 |
TFSMailMsgId plugin;
|
|
1241 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
1242 |
|
|
1243 |
// display "create mailbox" query if no mailboxes defined
|
|
1244 |
TInt mailboxCount = mailBoxes.Count();
|
|
1245 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
1246 |
|
|
1247 |
// Display query if count == zero
|
|
1248 |
if ( mailboxCount == 0 )
|
|
1249 |
{
|
|
1250 |
if ( TFsEmailUiUtility::ShowConfirmationQueryL( R_FS_EMAIL_SETTINGS_ADD_MAILBOX_TXT ) )
|
|
1251 |
{
|
|
1252 |
AddAccountL();
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
|
|
1258 |
// ---------------------------------------------------------------------------
|
|
1259 |
// CreatePluginSubviewListL
|
|
1260 |
// Fill list with captions returned by settings ECOM plugin
|
|
1261 |
// @param aPluginId implementation TUid of the settings ECom plugin
|
|
1262 |
// @return void
|
|
1263 |
// ---------------------------------------------------------------------------
|
|
1264 |
//
|
|
1265 |
void CFsEmailSettingsList::CreatePluginSubviewListL( const TUid& aPluginId )
|
|
1266 |
{
|
|
1267 |
FUNC_LOG;
|
|
1268 |
|
|
1269 |
// Remove items
|
|
1270 |
ClearListL();
|
|
1271 |
|
|
1272 |
// change list content to account specific settings
|
|
1273 |
HBufC *listString = NULL;
|
|
1274 |
|
|
1275 |
// get pointer to plugin settings that user selected
|
|
1276 |
iSelectedPluginSettings = aPluginId;
|
|
1277 |
CESMailSettingsPlugin* settingsPlugin = GetSettingsPluginL(
|
|
1278 |
iSelectedPluginSettings );
|
|
1279 |
|
|
1280 |
// check do we want to load long or short caption depending on screen size
|
|
1281 |
TBool longCaption = EFalse;
|
|
1282 |
if ( Rect().Width() > 240 )
|
|
1283 |
{
|
|
1284 |
longCaption = ETrue;
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
TInt subViewCount( 0 );
|
|
1288 |
if ( settingsPlugin != NULL )
|
|
1289 |
{
|
|
1290 |
subViewCount = settingsPlugin->MailSettingsSubviewCount();
|
|
1291 |
}
|
|
1292 |
else
|
|
1293 |
{
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
// load setting view names to list
|
|
1297 |
TInt index = 0;
|
|
1298 |
if ( subViewCount > 0 )
|
|
1299 |
{
|
|
1300 |
while ( index < subViewCount )
|
|
1301 |
{
|
|
1302 |
TPtrC subViewCaption = settingsPlugin->MailSettingsSubviewCaption(
|
|
1303 |
iSelectedAccountInfo, index, longCaption );
|
|
1304 |
listString = CreateListBoxItemLC( subViewCaption );
|
|
1305 |
AppendItemL( *listString );
|
|
1306 |
CleanupStack::PopAndDestroy( listString );
|
|
1307 |
++index;
|
|
1308 |
}
|
|
1309 |
iListBox->HandleItemAdditionL();
|
|
1310 |
iListBox->SetCurrentItemIndex( iSelectedSubListIndex );
|
|
1311 |
}
|
|
1312 |
else
|
|
1313 |
{
|
|
1314 |
// activate POP/IMAP view
|
|
1315 |
ActivateMailSettingsPluginSubViewL( -1 );
|
|
1316 |
}
|
|
1317 |
iCurrentSubView = EFsEmailSettingsMailboxView;
|
|
1318 |
}
|
|
1319 |
|
|
1320 |
// ---------------------------------------------------------------------------
|
|
1321 |
// CreatePluginPIMListL
|
|
1322 |
// Fill list with PIM captions returned by settings ECOM plugin
|
|
1323 |
// This list is displayed only with Intellisync or Mfe account
|
|
1324 |
// @param aPluginId implementation TUid of the settings ECom plugin
|
|
1325 |
// @return void
|
|
1326 |
// ---------------------------------------------------------------------------
|
|
1327 |
//
|
|
1328 |
void CFsEmailSettingsList::CreatePluginPIMListL( const TUid& aPluginId )
|
|
1329 |
{
|
|
1330 |
FUNC_LOG;
|
|
1331 |
|
|
1332 |
// Remove items
|
|
1333 |
ClearListL();
|
|
1334 |
|
|
1335 |
// change list content to account specific settings
|
|
1336 |
TInt index = 0;
|
|
1337 |
HBufC *listString = NULL;
|
|
1338 |
|
|
1339 |
// get pointer to plugin settings that user selected
|
|
1340 |
iSelectedPluginSettings = aPluginId;
|
|
1341 |
CESMailSettingsPlugin* settingsPlugin = GetSettingsPluginL(
|
|
1342 |
iSelectedPluginSettings );
|
|
1343 |
|
|
1344 |
// When we return from the plugin PIM settings we don't know if there is
|
|
1345 |
// one or two mailboxes that contains PIM settings.
|
|
1346 |
// So we veed to check that here:
|
|
1347 |
if(iPIMSyncCount == 0)
|
|
1348 |
{
|
|
1349 |
TUid PIMpluginUid = TUid::Null();
|
|
1350 |
// get mailboxes from every plugin
|
|
1351 |
RPointerArray<CFSMailBox> mailBoxes;
|
|
1352 |
CleanupResetAndDestroyClosePushL( mailBoxes );
|
|
1353 |
mailBoxes.Reset();
|
|
1354 |
TFSMailMsgId plugin;
|
|
1355 |
iMailClient.ListMailBoxes( plugin, mailBoxes );
|
|
1356 |
|
|
1357 |
for ( TInt i = 0; i < mailBoxes.Count(); ++i )
|
|
1358 |
{
|
|
1359 |
// get mailbox name and insert it to listBox
|
|
1360 |
CFSMailBox* mailBox = mailBoxes[i];
|
|
1361 |
// Does mailbox have settings plugin
|
|
1362 |
if ( mailBox->GetSettingsUid() != TUid::Null() )
|
|
1363 |
{
|
|
1364 |
// load settings ECOM plugin
|
|
1365 |
TUid pluginUid = mailBox->GetSettingsUid();
|
|
1366 |
CESMailSettingsPlugin* tempPlugin;
|
|
1367 |
tempPlugin = GetSettingsPluginL( pluginUid ); // ownership not transferred
|
|
1368 |
|
|
1369 |
if ( tempPlugin != NULL )
|
|
1370 |
{
|
|
1371 |
// check if mailboxes can handle PIM sync
|
|
1372 |
TBool canHandlePIMSync = tempPlugin->CanHandlePIMSync();
|
|
1373 |
if ( canHandlePIMSync && PIMpluginUid != pluginUid )
|
|
1374 |
{
|
|
1375 |
++iPIMSyncCount;
|
|
1376 |
}
|
|
1377 |
}
|
|
1378 |
}
|
|
1379 |
}
|
|
1380 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
1381 |
}
|
|
1382 |
|
|
1383 |
// If there are more than one plugin that is capable of syncing personal
|
|
1384 |
// information, then user needs to select which is used
|
|
1385 |
if ( iPIMSyncCount > 1 )
|
|
1386 |
{
|
|
1387 |
HBufC* text = StringLoader::LoadLC( R_FS_EMAIL_SETTINGS_PIM_SERVICE_TXT );
|
|
1388 |
listString = CreateListBoxItemLC( *text );
|
|
1389 |
AppendItemL( *listString );
|
|
1390 |
CleanupStack::PopAndDestroy( 2, text ); // text, listString
|
|
1391 |
iPIMServiceSettingsSelection = ETrue;
|
|
1392 |
}
|
|
1393 |
|
|
1394 |
|
|
1395 |
// check do we want to load long or short caption depending on screen size
|
|
1396 |
TBool longCaption = EFalse;
|
|
1397 |
if ( Rect().Width() > 240 )
|
|
1398 |
{
|
|
1399 |
longCaption = ETrue;
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
TInt subViewCount(0);
|
|
1403 |
if ( settingsPlugin )
|
|
1404 |
{
|
|
1405 |
subViewCount = settingsPlugin->PIMSettingsSubviewCount();
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
// load setting view names to list
|
|
1409 |
while ( subViewCount > index )
|
|
1410 |
{
|
|
1411 |
TPtrC subViewCaption = settingsPlugin->PIMSettingsSubviewCaption(
|
|
1412 |
iSelectedAccountInfo, index, longCaption );
|
|
1413 |
listString = CreateListBoxItemLC( subViewCaption );
|
|
1414 |
AppendItemL( *listString );
|
|
1415 |
CleanupStack::PopAndDestroy( listString ); // listString
|
|
1416 |
++index;
|
|
1417 |
}
|
|
1418 |
|
|
1419 |
iListBox->HandleItemAdditionL();
|
|
1420 |
iListBox->SetCurrentItemIndex( iSelectedSubListIndex );
|
|
1421 |
iCurrentSubView = EFsEmailSettingsPimView;
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
|
|
1425 |
// ---------------------------------------------------------------------------
|
|
1426 |
// SetDefaultPIMAccountL
|
|
1427 |
// Set account specific variables point to a selected PIM account
|
|
1428 |
// @return void
|
|
1429 |
// ---------------------------------------------------------------------------
|
|
1430 |
//
|
|
1431 |
void CFsEmailSettingsList::SetDefaultPIMAccountL()
|
|
1432 |
{
|
|
1433 |
FUNC_LOG;
|
|
1434 |
CFSMailBox* mailbox;
|
|
1435 |
|
|
1436 |
for ( TInt i = 0 ; i < iMailboxCount ; ++i )
|
|
1437 |
{
|
|
1438 |
mailbox = GetMailboxByIndexLC(i);
|
|
1439 |
TUid pluginUid = mailbox->GetSettingsUid();
|
|
1440 |
CESMailSettingsPlugin* tempPlugin;
|
|
1441 |
tempPlugin = GetSettingsPluginL( pluginUid );
|
|
1442 |
if ( tempPlugin != NULL
|
|
1443 |
&& tempPlugin->CanHandlePIMSync()
|
|
1444 |
&& tempPlugin->IsSelectedForPIMSync() )
|
|
1445 |
{
|
|
1446 |
SetSelectedAccountInfo( mailbox->GetId() );
|
|
1447 |
iSelectedPluginSettings = pluginUid;
|
|
1448 |
}
|
|
1449 |
CleanupStack::PopAndDestroy( mailbox );
|
|
1450 |
}
|
|
1451 |
}
|
|
1452 |
|
|
1453 |
// ---------------------------------------------------------------------------
|
|
1454 |
// GetMailBoxNameL
|
|
1455 |
// Get text pointer with the (possibly branded) mailbox name. Mailbox or
|
|
1456 |
// framework owns the pointed data.
|
|
1457 |
// ---------------------------------------------------------------------------
|
|
1458 |
//
|
|
1459 |
TPtrC CFsEmailSettingsList::GetMailBoxNameL( const CFSMailBox& aMailBox ) const
|
|
1460 |
{
|
|
1461 |
FUNC_LOG;
|
|
1462 |
// Branded mailbox name is nowadays set in new mailbox event
|
|
1463 |
// handling, so we don't need to use brand manager here anymore.
|
|
1464 |
const TDesC& name = aMailBox.GetName();
|
|
1465 |
|
|
1466 |
TPtrC ret;
|
|
1467 |
ret.Set( name );
|
|
1468 |
|
|
1469 |
return ret;
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
// ---------------------------------------------------------------------------
|
|
1473 |
// ActivateMailSettingsPluginSubViewL
|
|
1474 |
// Activate selected mail settings plugin subview
|
|
1475 |
// @return void
|
|
1476 |
// ---------------------------------------------------------------------------
|
|
1477 |
//
|
|
1478 |
void CFsEmailSettingsList::ActivateMailSettingsPluginSubViewL( TInt aSubViewId )
|
|
1479 |
{
|
|
1480 |
FUNC_LOG;
|
|
1481 |
|
|
1482 |
TUid messageId;
|
|
1483 |
CESMailSettingsPlugin::TSubViewActivationData activationData;
|
|
1484 |
TInt subViewId = iListBox->CurrentItemIndex();
|
|
1485 |
activationData.iAccount = iSelectedAccountInfo;
|
|
1486 |
activationData.iSubviewId = aSubViewId;
|
|
1487 |
activationData.iLaunchedOutsideFSEmail = EFalse;
|
|
1488 |
|
|
1489 |
if ( iPIMListActivation )
|
|
1490 |
{
|
|
1491 |
messageId = TUid::Uid( CESMailSettingsPlugin::EActivatePIMSettingsSubview );
|
|
1492 |
// use account selected for PIM sync
|
|
1493 |
SetDefaultPIMAccountL();
|
|
1494 |
iPIMListActivation = EFalse;
|
|
1495 |
// pass information to the plugin side that we were in the personal information management subview
|
|
1496 |
activationData.iPimAccount = ETrue;
|
|
1497 |
}
|
|
1498 |
else
|
|
1499 |
{
|
|
1500 |
messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview );
|
|
1501 |
activationData.iPimAccount = EFalse;
|
|
1502 |
}
|
|
1503 |
|
|
1504 |
const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData>
|
|
1505 |
pluginMessagePkg( activationData );
|
|
1506 |
TInt errNo( KErrNone );
|
|
1507 |
TRAP( errNo, iAppUi.EnterPluginSettingsViewL(
|
|
1508 |
iSelectedPluginSettings, messageId, pluginMessagePkg ); );
|
|
1509 |
if ( errNo != KErrNone )
|
|
1510 |
{
|
|
1511 |
}
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
// ---------------------------------------------------------------------------
|
|
1515 |
// SetSelectedAccountInfo
|
|
1516 |
// Set given account info as a member data
|
|
1517 |
// @param aAccountInfo
|
|
1518 |
// @return void
|
|
1519 |
// ---------------------------------------------------------------------------
|
|
1520 |
//
|
|
1521 |
void CFsEmailSettingsList::SetSelectedAccountInfo( const TFSMailMsgId& aAccountInfo )
|
|
1522 |
{
|
|
1523 |
FUNC_LOG;
|
|
1524 |
|
|
1525 |
iSelectedAccountInfo = aAccountInfo;
|
|
1526 |
|
|
1527 |
}
|
|
1528 |
|
|
1529 |
// ---------------------------------------------------------------------------
|
|
1530 |
// AddAccount
|
|
1531 |
// Handles new account creation with wizard
|
|
1532 |
// @return void
|
|
1533 |
// ---------------------------------------------------------------------------
|
|
1534 |
//
|
|
1535 |
void CFsEmailSettingsList::AddAccountL()
|
|
1536 |
{
|
|
1537 |
FUNC_LOG;
|
|
1538 |
|
|
1539 |
iAppUi.LaunchWizardL();
|
|
1540 |
|
|
1541 |
}
|
|
1542 |
|
|
1543 |
// ---------------------------------------------------------------------------
|
|
1544 |
// RemoveAccountL()
|
|
1545 |
// Handle account removal from fs mail client.
|
|
1546 |
// ---------------------------------------------------------------------------
|
|
1547 |
//
|
|
1548 |
TBool CFsEmailSettingsList::RemoveAccountL()
|
|
1549 |
{
|
|
1550 |
FUNC_LOG;
|
|
1551 |
TBool wasDeleted( EFalse );
|
|
1552 |
|
|
1553 |
// Make sure that FSMailServer is running, so that the mailbox is removed
|
|
1554 |
// also from MCE. Let's do it already here, so that the server has some
|
|
1555 |
// time to launch itself before the actual mailbox deletion happens.
|
|
1556 |
TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() );
|
|
1557 |
|
|
1558 |
// if item index is 0 then we are on global settings item
|
|
1559 |
// this shouldn't be happening, but just in case
|
|
1560 |
iDeletedIndex = iListBox->CurrentItemIndex();
|
|
1561 |
|
|
1562 |
if ( iDeletedIndex == 0 )
|
|
1563 |
{
|
|
1564 |
return EFalse;
|
|
1565 |
}
|
|
1566 |
|
|
1567 |
// get mailbox
|
|
1568 |
CFSMailBox* mailBox = GetMailboxByIndexLC(iDeletedIndex-1);
|
|
1569 |
CAknQueryDialog* queryNote = new ( ELeave ) CAknQueryDialog();
|
|
1570 |
CleanupStack::PushL( queryNote );
|
|
1571 |
|
|
1572 |
// load remove mailbox text from resource
|
|
1573 |
HBufC* question = StringLoader::LoadLC(
|
|
1574 |
R_FS_EMAIL_SETTINGS_REMOVE_MAILBOX_TXT,
|
|
1575 |
mailBox->GetName() );
|
|
1576 |
|
|
1577 |
queryNote->SetPromptL( *question );
|
|
1578 |
CleanupStack::PopAndDestroy( question );
|
|
1579 |
CleanupStack::Pop( queryNote );
|
|
1580 |
|
|
1581 |
// launch note and check answer
|
|
1582 |
if ( queryNote->ExecuteLD( R_FSEMAIL_QUERY_DIALOG ) )
|
|
1583 |
{
|
|
1584 |
// check if protocol supports delete
|
|
1585 |
if ( mailBox->HasCapability( EFSMBoxCapaCanBeDeleted ) )
|
|
1586 |
{
|
|
1587 |
// start wait note
|
|
1588 |
iWaitDialog = new (ELeave) CAknWaitDialog(
|
|
1589 |
(REINTERPRET_CAST(CEikDialog**, &iWaitDialog)), ETrue );
|
|
1590 |
iWaitDialog->PrepareLC( R_FS_WAIT_NOTE_REMOVING_MAILBOX );
|
|
1591 |
iWaitDialog->SetCallback( this );
|
|
1592 |
iWaitDialog->RunLD();
|
|
1593 |
|
|
1594 |
//emailindicator handling, is removed from 9.2
|
|
1595 |
//TRAP_IGNORE(TFsEmailStatusPaneIndicatorHandler::StatusPaneMailIndicatorHandlingL( mailBox->GetId().Id()));
|
|
1596 |
|
|
1597 |
// delete mailbox and wait event (RequestResponseL)
|
|
1598 |
iDeleteMailboxId = iMailClient.DeleteMailBoxByUidL( mailBox->GetId(), *this );
|
|
1599 |
wasDeleted = ETrue;
|
|
1600 |
}
|
|
1601 |
}
|
|
1602 |
CleanupStack::PopAndDestroy(); // mailBox
|
|
1603 |
return wasDeleted;
|
|
1604 |
}
|
|
1605 |
|
|
1606 |
|
|
1607 |
// ---------------------------------------------------------------------------
|
|
1608 |
// RequestResponseL
|
|
1609 |
// handles request state from mail client
|
|
1610 |
// @return void
|
|
1611 |
// ---------------------------------------------------------------------------
|
|
1612 |
//
|
|
1613 |
void CFsEmailSettingsList::RequestResponseL( TFSProgress /*aEvent*/, TInt /*aRequestId*/ )
|
|
1614 |
{
|
|
1615 |
FUNC_LOG;
|
|
1616 |
if( iWaitDialog )
|
|
1617 |
{
|
|
1618 |
iWaitDialog->ProcessFinishedL();
|
|
1619 |
// refresh settings mailboxlist
|
|
1620 |
if ( GetSelectedMainListIndex() > 0 )
|
|
1621 |
{
|
|
1622 |
SetSelectedMainListIndex( GetSelectedMainListIndex()-1 );
|
|
1623 |
}
|
|
1624 |
else
|
|
1625 |
{
|
|
1626 |
SetSelectedMainListIndex( 0 );
|
|
1627 |
}
|
|
1628 |
|
|
1629 |
LoadAccountsToListL();
|
|
1630 |
// refresh launcher grid
|
|
1631 |
CFSEmailUiLauncherGridVisualiser* grid =
|
|
1632 |
static_cast<CFSEmailUiLauncherGridVisualiser*>( iAppUi.View( AppGridId ) );
|
|
1633 |
grid->RefreshLauncherViewL();
|
|
1634 |
}
|
|
1635 |
iWaitDialog = NULL;
|
|
1636 |
}
|
|
1637 |
|
|
1638 |
// ---------------------------------------------------------------------------
|
|
1639 |
// DialogDismissedL
|
|
1640 |
// called when wait has ended
|
|
1641 |
// @return void
|
|
1642 |
// ---------------------------------------------------------------------------
|
|
1643 |
//
|
|
1644 |
void CFsEmailSettingsList::DialogDismissedL( TInt /*aButtonId */ )
|
|
1645 |
{
|
|
1646 |
FUNC_LOG;
|
|
1647 |
iWaitDialog = NULL;
|
|
1648 |
}
|
|
1649 |
|
|
1650 |
// ---------------------------------------------------------------------------
|
|
1651 |
// OpenPIMServiceDialog
|
|
1652 |
// @return void
|
|
1653 |
// ---------------------------------------------------------------------------
|
|
1654 |
//
|
|
1655 |
void CFsEmailSettingsList::OpenPIMServiceDialogL()
|
|
1656 |
{
|
|
1657 |
FUNC_LOG;
|
|
1658 |
CPIMSettingItemListDlg* dlg = new (ELeave) CPIMSettingItemListDlg( iMailClient );
|
|
1659 |
dlg->ExecuteLD( R_FS_PIMSETTINGITEMLIST_DIALOG );
|
|
1660 |
}
|
|
1661 |
|
|
1662 |
// ---------------------------------------------------------------------------
|
|
1663 |
// SetPimListActivation
|
|
1664 |
// @return void
|
|
1665 |
// ---------------------------------------------------------------------------
|
|
1666 |
//
|
|
1667 |
void CFsEmailSettingsList::SetPimListActivation(TBool aActivation)
|
|
1668 |
{
|
|
1669 |
FUNC_LOG;
|
|
1670 |
iPIMListActivation = aActivation;
|
|
1671 |
}
|
|
1672 |
|
|
1673 |
// ---------------------------------------------------------------------------
|
|
1674 |
// Creates and passes ownership of title pane text appropriate for the current
|
|
1675 |
// view
|
|
1676 |
// ---------------------------------------------------------------------------
|
|
1677 |
//
|
|
1678 |
HBufC* CFsEmailSettingsList::CreateTitlePaneTextLC() const
|
|
1679 |
{
|
|
1680 |
FUNC_LOG;
|
|
1681 |
HBufC* text = NULL;
|
|
1682 |
|
|
1683 |
switch ( iCurrentSubView )
|
|
1684 |
{
|
|
1685 |
case EFsEmailSettingsMailboxView:
|
|
1686 |
{
|
|
1687 |
// Use mailbox name as title pane text in the mailbox view
|
|
1688 |
TInt curMailBoxIdx = GetSelectedMainListIndex()-1;
|
|
1689 |
if ( curMailBoxIdx < 0 )
|
|
1690 |
{
|
|
1691 |
text = StringLoader::LoadLC( R_FS_EMAIL_SETTINGS_TITLE );
|
|
1692 |
break;
|
|
1693 |
}
|
|
1694 |
CFSMailBox* mailBox = GetMailboxByIndexLC( curMailBoxIdx );
|
|
1695 |
TPtrC mailBoxName = GetMailBoxNameL( *mailBox );
|
|
1696 |
text = mailBoxName.AllocL();
|
|
1697 |
CleanupStack::PopAndDestroy( mailBox );
|
|
1698 |
CleanupStack::PushL( text );
|
|
1699 |
}
|
|
1700 |
break;
|
|
1701 |
case EFsEmailSettingsPimView:
|
|
1702 |
{
|
|
1703 |
text = StringLoader::LoadLC( R_FS_EMAIL_PIM_SETTINGS_TITLE );
|
|
1704 |
}
|
|
1705 |
break;
|
|
1706 |
case EFsEmailSettingsMainListView:
|
|
1707 |
default:
|
|
1708 |
{
|
|
1709 |
text = StringLoader::LoadLC( R_FS_EMAIL_SETTINGS_TITLE );
|
|
1710 |
}
|
|
1711 |
break;
|
|
1712 |
}
|
|
1713 |
|
|
1714 |
return text;
|
|
1715 |
}
|
|
1716 |
|
|
1717 |
// ---------------------------------------------------------------------------
|
|
1718 |
// Move list focus to top
|
|
1719 |
// ---------------------------------------------------------------------------
|
|
1720 |
//
|
|
1721 |
void CFsEmailSettingsList::GoToTop()
|
|
1722 |
{
|
|
1723 |
FUNC_LOG;
|
|
1724 |
TInt count = iListBox->Model()->NumberOfItems();
|
|
1725 |
if ( count )
|
|
1726 |
{
|
|
1727 |
iListBox->SetCurrentItemIndexAndDraw( 0 );
|
|
1728 |
}
|
|
1729 |
}
|
|
1730 |
|
|
1731 |
// ---------------------------------------------------------------------------
|
|
1732 |
// Move list focus to bottom
|
|
1733 |
// ---------------------------------------------------------------------------
|
|
1734 |
//
|
|
1735 |
void CFsEmailSettingsList::GoToBottom()
|
|
1736 |
{
|
|
1737 |
FUNC_LOG;
|
|
1738 |
TInt count = iListBox->Model()->NumberOfItems();
|
|
1739 |
if ( count )
|
|
1740 |
{
|
|
1741 |
iListBox->SetCurrentItemIndexAndDraw( count-1 );
|
|
1742 |
}
|
|
1743 |
}
|
|
1744 |
|
|
1745 |
// ---------------------------------------------------------------------------
|
|
1746 |
// Move selector one page up
|
|
1747 |
// ---------------------------------------------------------------------------
|
|
1748 |
//
|
|
1749 |
void CFsEmailSettingsList::PageUp()
|
|
1750 |
{
|
|
1751 |
FUNC_LOG;
|
|
1752 |
TInt count = iListBox->Model()->NumberOfItems();
|
|
1753 |
if ( count )
|
|
1754 |
{
|
|
1755 |
TInt itemsOnPage = ListBox()->BottomItemIndex() - ListBox()->TopItemIndex();
|
|
1756 |
TInt currentIdx = ListBox()->CurrentItemIndex();
|
|
1757 |
TInt newIdx = Max( 0, currentIdx - itemsOnPage );
|
|
1758 |
ListBox()->SetCurrentItemIndexAndDraw( newIdx );
|
|
1759 |
}
|
|
1760 |
}
|
|
1761 |
|
|
1762 |
// ---------------------------------------------------------------------------
|
|
1763 |
// Move selector one page down
|
|
1764 |
// ---------------------------------------------------------------------------
|
|
1765 |
//
|
|
1766 |
void CFsEmailSettingsList::PageDown()
|
|
1767 |
{
|
|
1768 |
FUNC_LOG;
|
|
1769 |
TInt count = ListBox()->Model()->NumberOfItems();
|
|
1770 |
if ( count )
|
|
1771 |
{
|
|
1772 |
TInt itemsOnPage = ListBox()->BottomItemIndex() - ListBox()->TopItemIndex();
|
|
1773 |
TInt currentIdx = ListBox()->CurrentItemIndex();
|
|
1774 |
TInt newIdx = Min( count-1, currentIdx + itemsOnPage );
|
|
1775 |
ListBox()->SetCurrentItemIndexAndDraw( newIdx );
|
|
1776 |
}
|
|
1777 |
}
|
|
1778 |
|
|
1779 |
|
|
1780 |
// ---------------------------------------------------------------------------
|
|
1781 |
// CFsEmailSettingsList::SelectedItemIsMailbox()
|
|
1782 |
// Used to check if the currently selected item is a mailbox.
|
|
1783 |
// ---------------------------------------------------------------------------
|
|
1784 |
//
|
|
1785 |
TBool CFsEmailSettingsList::SelectedItemIsMailbox() const
|
|
1786 |
{
|
|
1787 |
// Check if the current view is the main level and the selected list item
|
|
1788 |
// is a mailbox.
|
|
1789 |
const TInt index( iListBox->CurrentItemIndex() );
|
|
1790 |
|
|
1791 |
if ( iCurrentSubView == EFsEmailSettingsMainListView &&
|
|
1792 |
index > 0 && index <= iMailboxCount )
|
|
1793 |
{
|
|
1794 |
// Is a mailbox.
|
|
1795 |
return ETrue;
|
|
1796 |
}
|
|
1797 |
|
|
1798 |
// Is something else.
|
|
1799 |
return EFalse;
|
|
1800 |
}
|
|
1801 |
|
|
1802 |
|
|
1803 |
// ---------------------------------------------------------------------------
|
|
1804 |
// CFsEmailSettingsList::ClearFocus()
|
|
1805 |
// Removes the focus.
|
|
1806 |
// ---------------------------------------------------------------------------
|
|
1807 |
//
|
|
1808 |
void CFsEmailSettingsList::ClearFocus()
|
|
1809 |
{
|
|
1810 |
FUNC_LOG;
|
|
1811 |
iListBox->ItemDrawer()->ClearFlags( CListItemDrawer::EPressedDownState );
|
|
1812 |
iListBox->ItemDrawer()->SetFlags( CListItemDrawer::ESingleClickDisabledHighlight
|
|
1813 |
| CListItemDrawer::ESingleClickEnabled );
|
|
1814 |
TInt ci( iListBox->CurrentItemIndex() );
|
|
1815 |
if ( KErrNotFound != ci )
|
|
1816 |
{
|
|
1817 |
iListBox->DrawItem( ci );
|
|
1818 |
}
|
|
1819 |
}
|
|
1820 |
|
|
1821 |
|
|
1822 |
// End of file.
|