25
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 - 2010 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: CEmailWidgetSettingsListViewContainer implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <eikclbd.h>
|
|
20 |
#include <eikmop.h>
|
|
21 |
#include <bacline.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <AknIconArray.h>
|
|
24 |
#include <emailwidgetsettings.rsg>
|
|
25 |
#include <emailwidgetsettings.mbg>
|
|
26 |
#include <emailobserverinterface.hrh>
|
|
27 |
#include <memaildata.h>
|
|
28 |
|
|
29 |
#include "emailtrace.h"
|
|
30 |
#include "emailwidgetsettingslistview.h"
|
|
31 |
#include "cmailwidgetcenrepkeys.h"
|
|
32 |
#include "cfsmailclient.h"
|
|
33 |
|
|
34 |
using namespace AknLayout;
|
|
35 |
using namespace EmailInterface;
|
|
36 |
|
|
37 |
const TInt KMaxMailboxCount = 18;
|
|
38 |
const TInt KMaxExternalBoxCount = 10;
|
|
39 |
_LIT( KDissociated,"0");
|
|
40 |
const TInt KMaxDescLen = 256;
|
|
41 |
const TUid KUidWizardApp = { 0x10281c96 };
|
|
42 |
const TUid KUidEmailWizardView = { 0x10281C9A };
|
|
43 |
_LIT( KMifPath, "z:\\resource\\apps\\emailwidgetsettings.mif");
|
|
44 |
_LIT( KMifPrefix, "mif(" );
|
|
45 |
|
|
46 |
// ======== MEMBER FUNCTIONS ========
|
|
47 |
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// CEmailWidgetSettingsListViewContainer::CEmailWidgetSettingsListViewContainer
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CEmailWidgetSettingsListViewContainer::CEmailWidgetSettingsListViewContainer()
|
|
53 |
{
|
|
54 |
FUNC_LOG;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// CEmailWidgetSettingsListViewContainer::ConstructL
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void CEmailWidgetSettingsListViewContainer::ConstructL(CEmailWidgetSettingsListView* aView,
|
|
62 |
const TRect& aRect)
|
|
63 |
{
|
|
64 |
FUNC_LOG;
|
|
65 |
iEnv = CEikonEnv::Static( );
|
|
66 |
iMailboxes = CEmailWidgetSettingsMailboxes::NewL();
|
|
67 |
CreateWindowL();
|
|
68 |
SetBlank();
|
|
69 |
|
|
70 |
CreateCbaL(aView);
|
|
71 |
CreateListBoxL(aView);
|
|
72 |
SetRect(aRect);
|
|
73 |
ActivateL();
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CEmailWidgetSettingsListViewContainer::CreateListBoxL
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CEmailWidgetSettingsListViewContainer::CreateListBoxL(MEikListBoxObserver* aObserver)
|
|
81 |
{
|
|
82 |
FUNC_LOG;
|
|
83 |
|
|
84 |
|
|
85 |
TInt nativeMailboxCount = iMailboxes->MailboxCount();
|
|
86 |
|
|
87 |
iListBox = new(ELeave) CAknSingleGraphicStyleListBox;
|
|
88 |
iListBox->SetContainerWindowL( *this);
|
|
89 |
iListBox->ConstructL( this, EAknListBoxSelectionList );
|
|
90 |
|
|
91 |
iAccountNames = new (ELeave) CDesCArrayFlat(nativeMailboxCount + 1); // +1 for creating new mailbox
|
|
92 |
iDomains = new (ELeave) CDesCArrayFlat(1);
|
|
93 |
iAccountIds = new ( ELeave ) CArrayFixFlat<TFSMailMsgId>(1);
|
|
94 |
|
|
95 |
// First items on the selection list are native mailboxes.
|
|
96 |
// Append name, domain and id information to the arrays.
|
|
97 |
for (TInt i = 0; i < nativeMailboxCount; i++)
|
|
98 |
{
|
|
99 |
TBuf<KMaxDescLen> name;
|
|
100 |
TBuf<KMaxDescLen> domain;
|
|
101 |
TFSMailMsgId id;
|
|
102 |
iMailboxes->GetMailboxNameL(i, name);
|
|
103 |
iMailboxes->GetDomainL(i, domain);
|
|
104 |
iMailboxes->GetMailboxIdL(i, id);
|
|
105 |
iAccountNames->AppendL(name);
|
|
106 |
iDomains->AppendL(domain);
|
|
107 |
iAccountIds->AppendL(id);
|
|
108 |
}
|
|
109 |
|
|
110 |
// Continue with external mailboxes.
|
|
111 |
// List plugins implementing the interface.
|
|
112 |
TUid interfaceUid = TUid::Uid( KEmailObserverInterfaceUid );
|
|
113 |
RImplInfoPtrArray pluginArray;
|
|
114 |
REComSession::ListImplementationsL( interfaceUid, pluginArray);
|
|
115 |
|
|
116 |
const TInt pluginCount = pluginArray.Count();
|
|
117 |
INFO_1("***** NUMBER OF plugins == %d", pluginCount);
|
|
118 |
for ( TInt ii = 0; ii < pluginCount; ii++ )
|
|
119 |
{
|
|
120 |
TUid implUid = pluginArray[ii]->ImplementationUid();
|
|
121 |
|
|
122 |
// load external email client plugin
|
|
123 |
INFO_1("***** BEFORE instantiating plugin %d", implUid.iUid);
|
|
124 |
EmailInterface::CEmailObserverPlugin* plugin = EmailInterface::CEmailObserverPlugin::NewL( implUid, this );
|
|
125 |
CleanupStack::PushL( plugin );
|
|
126 |
INFO("***** AFTER instantiating plugin ");
|
|
127 |
|
|
128 |
// list mailboxes of the plugin
|
|
129 |
MEmailData& data( plugin->EmailDataL() );
|
|
130 |
RPointerArray<MMailboxData> extMailboxes = data.MailboxesL();
|
|
131 |
|
|
132 |
const TInt extMailboxCount = extMailboxes.Count();
|
|
133 |
|
|
134 |
for ( TInt jj = 0; jj < extMailboxCount; jj++ )
|
|
135 |
{
|
|
136 |
// Append mailbox name using indexed format ( e.g. "1\tMailboxName\t\t" )
|
|
137 |
TBuf<KMaxDescLen> name;
|
|
138 |
name.AppendNum(nativeMailboxCount + 1 + jj);
|
|
139 |
name.Append(_L("\t"));
|
|
140 |
name.Append(extMailboxes[jj]->Name());
|
|
141 |
name.Append(_L("\t\t"));
|
|
142 |
iAccountNames->AppendL(name);
|
|
143 |
|
|
144 |
// Instead of domain information, external mail clients are requested
|
|
145 |
// to provide a string containing a mif file path and icon/mask numbers.
|
|
146 |
// The provided string is stored to domain list.
|
|
147 |
iDomains->AppendL( extMailboxes[jj]->BrandingIcon());
|
|
148 |
|
|
149 |
|
|
150 |
// Combine plugin uid and mailbox id and add to the list.
|
|
151 |
TFSMailMsgId uid( implUid, extMailboxes[jj]->MailboxId() );
|
|
152 |
iAccountIds->AppendL( uid );
|
|
153 |
}
|
|
154 |
CleanupStack::PopAndDestroy(plugin);
|
|
155 |
plugin = NULL;
|
|
156 |
}
|
|
157 |
pluginArray.ResetAndDestroy();
|
|
158 |
|
|
159 |
HBufC* createNewMailbox = StringLoader::LoadLC(R_EMAILWIDGETSETTINGS_CREATE_NEW_MAILBOX);
|
|
160 |
iAccountNames->AppendL(createNewMailbox->Des());
|
|
161 |
CleanupStack::PopAndDestroy(createNewMailbox);
|
|
162 |
iListBox->Model()->SetItemTextArray(iAccountNames);
|
|
163 |
|
|
164 |
iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
|
|
165 |
iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
|
|
166 |
iListBox->SetBorder(TGulBorder::ESingleBlack);
|
|
167 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
168 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
169 |
iListBox->SetListBoxObserver(aObserver);
|
|
170 |
|
|
171 |
|
|
172 |
SetupListIconsL();
|
|
173 |
|
|
174 |
}
|
|
175 |
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
// CEmailWidgetSettingsListViewContainer::SetupListIconsL
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CEmailWidgetSettingsListViewContainer::SetupListIconsL()
|
|
181 |
{
|
|
182 |
FUNC_LOG;
|
|
183 |
CFSMailClient* mailClient = CFSMailClient::NewL();
|
|
184 |
CleanupClosePushL(*mailClient);
|
|
185 |
MFSMailBrandManager& brandManager = mailClient->GetBrandManagerL();
|
|
186 |
|
|
187 |
TInt count = iAccountIds->Count();
|
|
188 |
|
|
189 |
CArrayPtr<CGulIcon>* icons = new(ELeave) CArrayPtrFlat<CGulIcon>( count + 1 );
|
|
190 |
CleanupStack::PushL( icons );
|
|
191 |
|
|
192 |
// Add "new mailbox" icon to the list
|
|
193 |
AppendIconL(icons, EMbmEmailwidgetsettingsQgn_prop_cmail_new_mailbox,
|
|
194 |
EMbmEmailwidgetsettingsQgn_prop_cmail_new_mailbox_mask);
|
|
195 |
|
|
196 |
for (TInt i = 0; i < count; i++)
|
|
197 |
{
|
|
198 |
CGulIcon* brandIcon;
|
|
199 |
brandIcon = brandManager.GetGraphicL( EFSMailboxIcon, iDomains->MdcaPoint(i) );
|
|
200 |
|
|
201 |
if (brandIcon)
|
|
202 |
{
|
|
203 |
// Add branded mailbox icon to the list
|
|
204 |
icons->AppendL(brandIcon);
|
|
205 |
}
|
|
206 |
else
|
|
207 |
{
|
|
208 |
TInt err(KErrNotFound);
|
|
209 |
|
|
210 |
// Check if domain list item contains mif file path (instead of domain)
|
|
211 |
// Path follows the format: "mif(z:\\resource\\apps\\myemailplugin.mif N1 N2)"
|
|
212 |
|
|
213 |
TBufC<KMaxDescLen> temp( iDomains->MdcaPoint(i) );
|
|
214 |
if( temp.Find(KMifPrefix) == 0 )
|
|
215 |
{
|
|
216 |
TInt p1 = KMifPrefix().Length();
|
|
217 |
TInt p2 = temp.Locate(' ') + 1;
|
|
218 |
TInt p3 = temp.LocateReverse(' ') + 1;
|
|
219 |
TInt end = temp.Length() - 1;
|
|
220 |
|
|
221 |
TInt p1Len = p2-p1-1;
|
|
222 |
TInt p2Len = p3-p2-1;
|
|
223 |
TInt p3Len = end-p3;
|
|
224 |
|
|
225 |
// negative lengths not allowed
|
|
226 |
if ( p1Len > 0 && p2Len > 0 && p3Len > 0 )
|
|
227 |
{
|
|
228 |
TBufC<KMaxDescLen> mifPath(temp.Mid( p1, p1Len ));
|
|
229 |
TBufC<16> iconString(temp.Mid( p2, p2Len ));
|
|
230 |
TBufC<16> maskString(temp.Mid( p3, p3Len ));
|
|
231 |
|
|
232 |
TLex lexIcon(iconString);
|
|
233 |
TLex lexMask(maskString);
|
|
234 |
TInt icon(0), mask(0);
|
|
235 |
lexIcon.Val(icon);
|
|
236 |
lexMask.Val(mask);
|
|
237 |
|
|
238 |
// Add 3rd party mailbox icon to the list
|
|
239 |
err = AppendExternalIconL( icons, mifPath, icon, mask );
|
|
240 |
}
|
|
241 |
}
|
|
242 |
if ( err )
|
|
243 |
{
|
|
244 |
// Add default mailbox icon to the list
|
|
245 |
AppendIconL(icons, EMbmEmailwidgetsettingsQgn_indi_cmail_drop_email_account,
|
|
246 |
EMbmEmailwidgetsettingsQgn_indi_cmail_drop_email_account_mask);
|
|
247 |
}
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
// clear any previous icon array
|
|
252 |
CAknIconArray* oldIconArray = static_cast<CAknIconArray*>(iListBox->ItemDrawer()->ColumnData()->IconArray());
|
|
253 |
if (oldIconArray)
|
|
254 |
delete oldIconArray;
|
|
255 |
|
|
256 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
|
|
257 |
CleanupStack::Pop(icons);
|
|
258 |
CleanupStack::PopAndDestroy( mailClient );
|
|
259 |
}
|
|
260 |
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
// CEmailWidgetSettingsListViewContainer::AppendIconL
|
|
263 |
//
|
|
264 |
// Loads and appends an icon to the icon array.
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
|
|
268 |
void CEmailWidgetSettingsListViewContainer::AppendIconL(
|
|
269 |
CArrayPtr<CGulIcon>* aIcons,
|
|
270 |
const TInt aFileBitmapId,
|
|
271 |
const TInt aFileMaskId)
|
|
272 |
{
|
|
273 |
FUNC_LOG;
|
|
274 |
CGulIcon* newIcon;
|
|
275 |
CFbsBitmap* newIconBmp;
|
|
276 |
CFbsBitmap* newIconMaskBmp;
|
|
277 |
AknIconUtils::CreateIconLC( newIconBmp, newIconMaskBmp, KMifPath,
|
|
278 |
aFileBitmapId,
|
|
279 |
aFileMaskId );
|
|
280 |
newIcon = CGulIcon::NewL(newIconBmp, newIconMaskBmp);
|
|
281 |
CleanupStack::Pop(newIconMaskBmp);
|
|
282 |
CleanupStack::Pop(newIconBmp);
|
|
283 |
CleanupStack::PushL(newIcon);
|
|
284 |
aIcons->AppendL(newIcon);
|
|
285 |
CleanupStack::Pop(newIcon);
|
|
286 |
}
|
|
287 |
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
// CEmailWidgetSettingsListViewContainer::AppendExternalIconL
|
|
290 |
//
|
|
291 |
// Loads and appends an 3rd party icon to the icon array.
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
//
|
|
294 |
TInt CEmailWidgetSettingsListViewContainer::AppendExternalIconL(
|
|
295 |
CArrayPtr<CGulIcon>* aIcons,
|
|
296 |
const TDesC& aMifPath,
|
|
297 |
const TInt aFileBitmapId,
|
|
298 |
const TInt aFileMaskId)
|
|
299 |
{
|
|
300 |
FUNC_LOG;
|
|
301 |
CGulIcon* newIcon;
|
|
302 |
CFbsBitmap* newIconBmp;
|
|
303 |
CFbsBitmap* newIconMaskBmp;
|
|
304 |
// Trap when faulty mif path, missing graphic file, etc.
|
|
305 |
TRAPD( err, AknIconUtils::CreateIconL( newIconBmp, newIconMaskBmp, aMifPath,
|
|
306 |
aFileBitmapId,
|
|
307 |
aFileMaskId ) );
|
|
308 |
if (!err)
|
|
309 |
{
|
|
310 |
CleanupStack::PushL(newIconBmp);
|
|
311 |
CleanupStack::PushL(newIconMaskBmp);
|
|
312 |
newIcon = CGulIcon::NewL(newIconBmp, newIconMaskBmp);
|
|
313 |
CleanupStack::Pop(newIconMaskBmp);
|
|
314 |
CleanupStack::Pop(newIconBmp);
|
|
315 |
CleanupStack::PushL(newIcon);
|
|
316 |
aIcons->AppendL(newIcon);
|
|
317 |
CleanupStack::Pop(newIcon);
|
|
318 |
}
|
|
319 |
return err;
|
|
320 |
}
|
|
321 |
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
// CEmailWidgetSettingsListViewContainer::CreateCbaL
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
void CEmailWidgetSettingsListViewContainer::CreateCbaL( MEikCommandObserver* aObserver )
|
|
327 |
{
|
|
328 |
FUNC_LOG;
|
|
329 |
const TSize screenSize= iCoeEnv->ScreenDevice()->SizeInPixels();
|
|
330 |
iPopoutCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba,
|
|
331 |
CEikButtonGroupContainer::EHorizontal, aObserver, R_AVKON_SOFTKEYS_SELECT_CANCEL);
|
|
332 |
iPopoutCba->SetBoundingRect(TRect(screenSize));
|
|
333 |
}
|
|
334 |
|
|
335 |
// ---------------------------------------------------------------------------
|
|
336 |
// CEmailWidgetSettingsListViewContainer::~CEmailWidgetSettingsListViewContainer
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
CEmailWidgetSettingsListViewContainer::~CEmailWidgetSettingsListViewContainer()
|
|
340 |
{
|
|
341 |
FUNC_LOG;
|
|
342 |
delete iMailboxes;
|
|
343 |
delete iPopoutCba;
|
|
344 |
delete iListBox;
|
|
345 |
delete iAccountNames;
|
|
346 |
delete iDomains;
|
|
347 |
delete iAccountIds;
|
|
348 |
REComSession::FinalClose();
|
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------------------------
|
|
352 |
// CEmailWidgetSettingsListViewContainer::SizeChanged
|
|
353 |
// ---------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void CEmailWidgetSettingsListViewContainer::SizeChanged()
|
|
356 |
{
|
|
357 |
FUNC_LOG;
|
|
358 |
TRect mainPaneRect;
|
|
359 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
|
|
360 |
TRect listBoxRect(mainPaneRect.Size());
|
|
361 |
iListBox->SetRect(listBoxRect);
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------------------------
|
|
365 |
// CEmailWidgetSettingsListViewContainer::CountComponentControls
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
TInt CEmailWidgetSettingsListViewContainer::CountComponentControls() const
|
|
369 |
{
|
|
370 |
FUNC_LOG;
|
|
371 |
return iListBox ? 1 : 0;
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------------------------
|
|
375 |
// CEmailWidgetSettingsListViewContainer::ComponentControl
|
|
376 |
// ---------------------------------------------------------------------------
|
|
377 |
//
|
|
378 |
CCoeControl* CEmailWidgetSettingsListViewContainer::ComponentControl(TInt /*aIndex*/) const
|
|
379 |
{
|
|
380 |
FUNC_LOG;
|
|
381 |
return iListBox;
|
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
// CEmailWidgetSettingsListViewContainer::OfferKeyEventL
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
TKeyResponse CEmailWidgetSettingsListViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
|
|
389 |
{
|
|
390 |
FUNC_LOG;
|
|
391 |
return iListBox->OfferKeyEventL(aKeyEvent, aType);
|
|
392 |
}
|
|
393 |
|
|
394 |
// ---------------------------------------------------------------------------
|
|
395 |
// CEmailWidgetSettingsListViewContainer::MinimumSize
|
|
396 |
// ---------------------------------------------------------------------------
|
|
397 |
//
|
|
398 |
TSize CEmailWidgetSettingsListViewContainer::MinimumSize()
|
|
399 |
{
|
|
400 |
FUNC_LOG;
|
|
401 |
return iEikonEnv->EikAppUi()->ClientRect().Size();
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
// CEmailWidgetSettingsListViewContainer::CurrentIndex
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
TInt CEmailWidgetSettingsListViewContainer::CurrentIndex() const
|
|
409 |
{
|
|
410 |
FUNC_LOG;
|
|
411 |
return iListBox->CurrentItemIndex();
|
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
// CEmailWidgetSettingsListViewContainer::MopSupplyObject
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
TTypeUid::Ptr CEmailWidgetSettingsListViewContainer::MopSupplyObject(TTypeUid aId)
|
|
419 |
{
|
|
420 |
FUNC_LOG;
|
|
421 |
return SupplyMopObject(aId, iPopoutCba);
|
|
422 |
}
|
|
423 |
|
|
424 |
// ---------------------------------------------------------------------------
|
|
425 |
// CEmailWidgetSettingsListViewContainer::SaveSelectedL
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
//
|
|
428 |
void CEmailWidgetSettingsListViewContainer::SaveSelectedL()
|
|
429 |
{
|
|
430 |
FUNC_LOG;
|
|
431 |
|
|
432 |
if (CurrentIndex() == iAccountNames->Count() - 1)
|
|
433 |
{
|
|
434 |
LaunchEmailWizardL();
|
|
435 |
return;
|
|
436 |
}
|
|
437 |
|
|
438 |
CCommandLineArguments* args = CCommandLineArguments::NewLC();
|
|
439 |
const TInt argumentCount = args->Count();
|
|
440 |
if (argumentCount!=2)
|
|
441 |
{
|
|
442 |
User::LeaveIfError(KErrNotFound);
|
|
443 |
}
|
|
444 |
CRepository* cenRep = CRepository::NewL( KCRUidCmailWidget );
|
|
445 |
|
|
446 |
// Check whether selected box is native or external mailbox
|
|
447 |
TInt index = CurrentIndex();
|
|
448 |
TInt nativeBoxCount = iMailboxes->MailboxCount();
|
|
449 |
|
|
450 |
TBool nativeBox(ETrue);
|
|
451 |
if ( index >= nativeBoxCount )
|
|
452 |
{
|
|
453 |
nativeBox = EFalse;
|
|
454 |
}
|
|
455 |
|
|
456 |
if ( cenRep )
|
|
457 |
{
|
|
458 |
TInt setId ( GetSettingToAssociateL(args->Arg(1), nativeBox, cenRep) );
|
|
459 |
if (setId >= 0)
|
|
460 |
{
|
|
461 |
TFSMailMsgId msgId = (*iAccountIds)[CurrentIndex()];
|
|
462 |
TInt id = msgId.Id();
|
|
463 |
TUid pluginId = msgId.PluginId();
|
|
464 |
TInt pId(pluginId.iUid);
|
|
465 |
TInt ret = cenRep->StartTransaction(CRepository::EConcurrentReadWriteTransaction);
|
|
466 |
|
|
467 |
if ( nativeBox )
|
|
468 |
{
|
|
469 |
ResetExtAccountWithSameId( args->Arg(1), cenRep );
|
|
470 |
|
|
471 |
ret = cenRep->Set( KCMailMailboxIdBase+setId, id );
|
|
472 |
ret = cenRep->Set( KCMailPluginIdBase+setId, pId );
|
|
473 |
ret = cenRep->Set( KCMailWidgetContentIdBase+setId, args->Arg(1) );
|
|
474 |
}
|
|
475 |
else // external mailbox
|
|
476 |
{
|
|
477 |
ResetNatAccountWithSameId( args->Arg(1), cenRep );
|
|
478 |
|
|
479 |
ret = cenRep->Set( KCMailExtMailboxBase+setId, id );
|
|
480 |
ret = cenRep->Set( KCMailExtMailboxBase+KCMailExtPluginIdOffset+setId, pId );
|
|
481 |
ret = cenRep->Set( KCMailExtMailboxBase+KCMailExtWidgetCidOffset+setId, args->Arg(1) );
|
|
482 |
}
|
|
483 |
|
|
484 |
TUint32 errorKey( 0 );
|
|
485 |
cenRep->CommitTransaction(errorKey);
|
|
486 |
INFO_1("Errorkey == %d", errorKey);
|
|
487 |
}
|
|
488 |
}
|
|
489 |
delete cenRep;
|
|
490 |
CleanupStack::PopAndDestroy(args);
|
|
491 |
}
|
|
492 |
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
// CEmailWidgetSettingsListViewContainer::ResetExtAccountWithSameId
|
|
495 |
// ---------------------------------------------------------------------------
|
|
496 |
//
|
|
497 |
void CEmailWidgetSettingsListViewContainer::ResetExtAccountWithSameId( const TDesC& aContentId, CRepository* aCenRep )
|
|
498 |
{
|
|
499 |
FUNC_LOG;
|
|
500 |
for ( TInt i = 0; i < KMaxExternalBoxCount; i++ )
|
|
501 |
{
|
|
502 |
TBuf<10> value;
|
|
503 |
TInt ret = aCenRep->Get( KCMailExtMailboxBase+KCMailExtWidgetCidOffset+i, value );
|
|
504 |
if ( !value.Compare( aContentId ) )
|
|
505 |
{
|
|
506 |
// found
|
|
507 |
ret = aCenRep->Set(KCMailExtMailboxBase+i, 0);
|
|
508 |
ret = aCenRep->Set(KCMailExtMailboxBase+KCMailExtPluginIdOffset+i, 0);
|
|
509 |
ret = aCenRep->Set(KCMailExtMailboxBase+KCMailExtWidgetCidOffset+i, KDissociated);
|
|
510 |
}
|
|
511 |
}
|
|
512 |
}
|
|
513 |
|
|
514 |
// ---------------------------------------------------------------------------
|
|
515 |
// CEmailWidgetSettingsListViewContainer::ResetNatAccountWithSameId
|
|
516 |
// ---------------------------------------------------------------------------
|
|
517 |
void CEmailWidgetSettingsListViewContainer::ResetNatAccountWithSameId( const TDesC& aContentId, CRepository* aCenRep )
|
|
518 |
{
|
|
519 |
FUNC_LOG;
|
|
520 |
for ( TInt i = 0; i < KMaxMailboxCount; i++ )
|
|
521 |
{
|
|
522 |
TBuf<10> value;
|
|
523 |
TInt ret = aCenRep->Get( KCMailWidgetContentIdBase+i, value );
|
|
524 |
if ( !value.Compare( aContentId ) )
|
|
525 |
{
|
|
526 |
// found
|
|
527 |
ret = aCenRep->Set(KCMailMailboxIdBase+i, 0);
|
|
528 |
ret = aCenRep->Set(KCMailPluginIdBase+i, 0);
|
|
529 |
ret = aCenRep->Set(KCMailWidgetContentIdBase+i, KDissociated);
|
|
530 |
}
|
|
531 |
}
|
|
532 |
}
|
|
533 |
|
|
534 |
// ---------------------------------------------------------------------------
|
|
535 |
// CEmailWidgetSettingsListViewContainer::GetSettingToAssociateL
|
|
536 |
// ---------------------------------------------------------------------------
|
|
537 |
//
|
|
538 |
TInt CEmailWidgetSettingsListViewContainer::GetSettingToAssociateL(const TDesC& aCid,
|
|
539 |
const TBool aNativeBox,
|
|
540 |
CRepository* aCenRep)
|
|
541 |
{
|
|
542 |
FUNC_LOG;
|
|
543 |
TUint32 keyBase;
|
|
544 |
TInt mailboxCount;
|
|
545 |
if (aNativeBox)
|
|
546 |
{
|
|
547 |
keyBase = KCMailWidgetContentIdBase;
|
|
548 |
mailboxCount = KMaxMailboxCount;
|
|
549 |
}
|
|
550 |
else // external mailbox
|
|
551 |
{
|
|
552 |
keyBase = KCMailExtMailboxBase + KCMailExtWidgetCidOffset;
|
|
553 |
mailboxCount = KMaxExternalBoxCount;
|
|
554 |
}
|
|
555 |
|
|
556 |
TInt ret(KErrNotFound);
|
|
557 |
|
|
558 |
// Search selected widget content id from cenrep settings
|
|
559 |
for (TInt i = 0; i < mailboxCount; i++)
|
|
560 |
{
|
|
561 |
TBuf<KMaxDescLen> value;
|
|
562 |
aCenRep->Get( keyBase+i, value );
|
|
563 |
TInt result = value.Compare(aCid);
|
|
564 |
if (!result)
|
|
565 |
{
|
|
566 |
// Content id found
|
|
567 |
ret = i;
|
|
568 |
break;
|
|
569 |
}
|
|
570 |
}
|
|
571 |
if (ret < 0 )
|
|
572 |
{
|
|
573 |
// Content id not found. Search first free space.
|
|
574 |
for (TInt i = 0; i < mailboxCount; i++)
|
|
575 |
{
|
|
576 |
TBuf<KMaxDescLen> value;
|
|
577 |
aCenRep->Get( keyBase+i, value );
|
|
578 |
TInt result = value.Compare(KDissociated);
|
|
579 |
if (!result)
|
|
580 |
{
|
|
581 |
// Free space found
|
|
582 |
ret = i;
|
|
583 |
break;
|
|
584 |
}
|
|
585 |
}
|
|
586 |
}
|
|
587 |
return ret;
|
|
588 |
}
|
|
589 |
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
// CEmailWidgetSettingsListViewContainer::LaunchEmailWizardL
|
|
592 |
// Launches Email Settings Wizard
|
|
593 |
// -----------------------------------------------------------------------------
|
|
594 |
//
|
|
595 |
void CEmailWidgetSettingsListViewContainer::LaunchEmailWizardL()
|
|
596 |
{
|
|
597 |
FUNC_LOG;
|
|
598 |
if ( iEnv )
|
|
599 |
{
|
|
600 |
CCoeAppUi* appui = iEnv-> EikAppUi( );
|
|
601 |
if ( appui )
|
|
602 |
{
|
|
603 |
appui->ActivateViewL(TVwsViewId(KUidWizardApp, KUidEmailWizardView));
|
|
604 |
}
|
|
605 |
}
|
|
606 |
}
|
|
607 |
|
|
608 |
void CEmailWidgetSettingsListViewContainer::EmailObserverEvent(
|
|
609 |
EmailInterface::MEmailData& /*aEmailData*/ )
|
|
610 |
{
|
|
611 |
FUNC_LOG;
|
|
612 |
}
|
|
613 |
|
|
614 |
// End of File
|