27
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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:
|
|
15 |
* Encapsulates saving and removing email accounts
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <msvapi.h> // CMsvEntry
|
|
23 |
#include <cemailaccounts.h> // CEmailAccounts
|
|
24 |
#include <smtpset.h> // CImSmtpSettings
|
|
25 |
#include <pop3set.h> // CImPop3Settings
|
|
26 |
#include <imapset.h> // CImImap4Settings
|
|
27 |
#include <iapprefs.h> // CImIAPPreferences
|
|
28 |
#include <muiumsvuiserviceutilitiesinternal.h>
|
|
29 |
#include <SendUiConsts.h>
|
|
30 |
|
|
31 |
#include "ImumInternalApiImpl.h"
|
|
32 |
#include "ImumMboxSymbianDataConverter.h"
|
|
33 |
#include "ImumMboxInternalDataConverter.h"
|
|
34 |
#include "ImumMboxManager.h"
|
|
35 |
#include "ImumInHealthServicesImpl.h"
|
|
36 |
#include "ImumMboxData.h"
|
|
37 |
#include "ImumMboxSettingsCtrl.h"
|
|
38 |
#include "IMSSettingsNoteUi.h"
|
|
39 |
#include "ImumUtilsLogging.h"
|
|
40 |
#include "EmailUtils.H"
|
|
41 |
#include "ImumPanic.h"
|
|
42 |
|
|
43 |
#include <mtudreg.h>
|
|
44 |
#include <muiumsvuiserviceutilitiesinternal.h>
|
|
45 |
#include <featmgr.h>
|
|
46 |
|
|
47 |
// EXTERNAL DATA STRUCTURES
|
|
48 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
49 |
// CONSTANTS
|
|
50 |
const TInt KImumMboxQueryTextLength = 100;
|
|
51 |
const TInt KImumMboxArrayGranularity = 4;
|
|
52 |
|
|
53 |
// MACROS
|
|
54 |
// LOCAL CONSTANTS AND MACROS
|
|
55 |
// MODULE DATA STRUCTURES
|
|
56 |
// LOCAL FUNCTION PROTOTYPES
|
|
57 |
// FORWARD DECLARATIONS
|
|
58 |
|
|
59 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
60 |
|
|
61 |
|
|
62 |
// ----------------------------------------------------------------------------
|
|
63 |
// CImumMboxManager::CImumMboxManager()
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CImumMboxManager::CImumMboxManager(
|
|
67 |
CImumInternalApiImpl& aMailboxApi )
|
|
68 |
:
|
|
69 |
iMailboxApi( aMailboxApi ),
|
|
70 |
iMboxSettingsCtrl( NULL ),
|
|
71 |
iAccounts( NULL ),
|
|
72 |
iCleaner( NULL )
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
// CImumMboxManager::ConstructL()
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CImumMboxManager::ConstructL()
|
|
81 |
{
|
|
82 |
IMUM_CONTEXT( CImumMboxManager::ConstructL, 0, KLogData );
|
|
83 |
IMUM_IN();
|
|
84 |
|
|
85 |
FeatureManager::InitializeLibL();
|
|
86 |
|
|
87 |
iAccounts = CEmailAccounts::NewL();
|
|
88 |
iMboxSettingsCtrl = CImumMboxSettingsCtrl::NewL( iMailboxApi );
|
|
89 |
iCleaner = CImumInHealthServicesImpl::NewL( iMailboxApi );
|
|
90 |
|
|
91 |
IMUM_OUT();
|
|
92 |
}
|
|
93 |
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
// CImumMboxManager::~CImumMboxManager()
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CImumMboxManager::~CImumMboxManager()
|
|
99 |
{
|
|
100 |
IMUM_CONTEXT( CImumMboxManager::~CImumMboxManager, 0, KLogData );
|
|
101 |
IMUM_IN();
|
|
102 |
|
|
103 |
FeatureManager::UnInitializeLib();
|
|
104 |
delete iMboxSettingsCtrl;
|
|
105 |
iMboxSettingsCtrl = NULL;
|
|
106 |
delete iAccounts;
|
|
107 |
iAccounts = NULL;
|
|
108 |
delete iCleaner;
|
|
109 |
iCleaner = NULL;
|
|
110 |
|
|
111 |
IMUM_OUT();
|
|
112 |
}
|
|
113 |
|
|
114 |
// ----------------------------------------------------------------------------
|
|
115 |
// CImumMboxManager::NewL()
|
|
116 |
// ----------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
CImumMboxManager* CImumMboxManager::NewL(
|
|
119 |
CImumInternalApiImpl& aMailboxApi )
|
|
120 |
{
|
|
121 |
IMUM_STATIC_CONTEXT( CImumMboxManager::NewL, 0, utils, KLogData );
|
|
122 |
IMUM_IN();
|
|
123 |
|
|
124 |
CImumMboxManager* self = NewLC( aMailboxApi );
|
|
125 |
CleanupStack::Pop( self );
|
|
126 |
|
|
127 |
IMUM_OUT();
|
|
128 |
|
|
129 |
return self;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ----------------------------------------------------------------------------
|
|
133 |
// CImumMboxManager::NewLC()
|
|
134 |
// ----------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
CImumMboxManager* CImumMboxManager::NewLC(
|
|
137 |
CImumInternalApiImpl& aMailboxApi )
|
|
138 |
{
|
|
139 |
IMUM_STATIC_CONTEXT( CImumMboxManager::NewLC, 0, utils, KLogData );
|
|
140 |
IMUM_IN();
|
|
141 |
|
|
142 |
CImumMboxManager* self =
|
|
143 |
new ( ELeave ) CImumMboxManager( aMailboxApi );
|
|
144 |
CleanupStack::PushL( self );
|
|
145 |
self->ConstructL();
|
|
146 |
|
|
147 |
IMUM_OUT();
|
|
148 |
|
|
149 |
return self;
|
|
150 |
}
|
|
151 |
|
|
152 |
/******************************************************************************
|
|
153 |
|
|
154 |
Static Functions
|
|
155 |
|
|
156 |
******************************************************************************/
|
|
157 |
|
|
158 |
// ----------------------------------------------------------------------------
|
|
159 |
// CImumMboxManager::GetIapPreferencesL()
|
|
160 |
// ----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
TInt CImumMboxManager::GetIapPreferencesL(
|
|
163 |
const TMsvId aMailboxId,
|
|
164 |
CEmailAccounts& aAccounts,
|
|
165 |
CImIAPPreferences& aIapPrefs,
|
|
166 |
CImumInternalApiImpl& aMailboxApi,
|
|
167 |
const TBool aSmtp )
|
|
168 |
{
|
|
169 |
IMUM_STATIC_CONTEXT( CImumMboxManager::GetIapPreferencesL, 0, utils, KLogData );
|
|
170 |
IMUM_IN();
|
|
171 |
|
|
172 |
TMsvEntry entry;
|
|
173 |
|
|
174 |
// Get the correct part of the mailbox
|
|
175 |
if ( aSmtp )
|
|
176 |
{
|
|
177 |
// Get SMTP part of the mailbox
|
|
178 |
entry = aMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
179 |
aMailboxId, MImumInMailboxUtilities::ERequestSending );
|
|
180 |
|
|
181 |
// Define the account id
|
|
182 |
TSmtpAccount smtpAccountId;
|
|
183 |
smtpAccountId.iSmtpAccountId = entry.iMtmData2;
|
|
184 |
|
|
185 |
// Load preferences
|
|
186 |
aAccounts.LoadSmtpIapSettingsL( smtpAccountId, aIapPrefs );
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
// Get POP3 or IMAP4 part of the mailbox
|
|
191 |
entry = aMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
192 |
aMailboxId, MImumInMailboxUtilities::ERequestReceiving );
|
|
193 |
|
|
194 |
// Load settings based on the mtm type
|
|
195 |
if ( entry.iMtm.iUid == KSenduiMtmImap4UidValue )
|
|
196 |
{
|
|
197 |
// Define imap4 account id
|
|
198 |
TImapAccount imapAccountId;
|
|
199 |
imapAccountId.iImapAccountId = entry.iMtmData2;
|
|
200 |
|
|
201 |
// Load preferences
|
|
202 |
aAccounts.LoadImapIapSettingsL( imapAccountId, aIapPrefs );
|
|
203 |
}
|
|
204 |
else
|
|
205 |
{
|
|
206 |
// Define pop3 account id
|
|
207 |
TPopAccount popAccountId;
|
|
208 |
popAccountId.iPopAccountId = entry.iMtmData2;
|
|
209 |
|
|
210 |
// Load preferences
|
|
211 |
aAccounts.LoadPopIapSettingsL( popAccountId, aIapPrefs );
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
IMUM_OUT();
|
|
216 |
|
|
217 |
return KErrNone;
|
|
218 |
}
|
|
219 |
|
|
220 |
// ----------------------------------------------------------------------------
|
|
221 |
// CImumMboxManager::SetIapPreferencesL()
|
|
222 |
// ----------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
TInt CImumMboxManager::SetIapPreferencesL(
|
|
225 |
const TMsvId aMailboxId,
|
|
226 |
CEmailAccounts& aAccounts,
|
|
227 |
const CImIAPPreferences& aIapPrefs,
|
|
228 |
CImumInternalApiImpl& aMailboxApi,
|
|
229 |
const TBool aSmtp )
|
|
230 |
{
|
|
231 |
IMUM_STATIC_CONTEXT( CImumMboxManager::SetIapPreferencesL, 0, utils, KLogData );
|
|
232 |
IMUM_IN();
|
|
233 |
|
|
234 |
TMsvEntry entry;
|
|
235 |
TInt error = KErrNone;
|
|
236 |
|
|
237 |
// Get the correct part of the mailbox
|
|
238 |
if ( aSmtp )
|
|
239 |
{
|
|
240 |
// Get SMTP part of the mailbox
|
|
241 |
entry = aMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
242 |
aMailboxId, MImumInMailboxUtilities::ERequestSending );
|
|
243 |
|
|
244 |
// Define the account id
|
|
245 |
TSmtpAccount smtpAccountId;
|
|
246 |
smtpAccountId.iSmtpAccountId = entry.iMtmData2;
|
|
247 |
|
|
248 |
// Load preferences
|
|
249 |
aAccounts.SaveSmtpIapSettingsL( smtpAccountId, aIapPrefs );
|
|
250 |
}
|
|
251 |
else
|
|
252 |
{
|
|
253 |
// Get POP3 or IMAP4 part of the mailbox
|
|
254 |
entry = aMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
255 |
aMailboxId, MImumInMailboxUtilities::ERequestReceiving );
|
|
256 |
|
|
257 |
// Load settings based on the mtm type
|
|
258 |
if ( entry.iMtm.iUid == KSenduiMtmImap4UidValue )
|
|
259 |
{
|
|
260 |
// Define imap4 account id
|
|
261 |
TImapAccount imapAccountId;
|
|
262 |
imapAccountId.iImapAccountId = entry.iMtmData2;
|
|
263 |
|
|
264 |
// Load preferences
|
|
265 |
aAccounts.SaveImapIapSettingsL( imapAccountId, aIapPrefs );
|
|
266 |
}
|
|
267 |
else
|
|
268 |
{
|
|
269 |
// Define pop3 account id
|
|
270 |
TPopAccount popAccountId;
|
|
271 |
popAccountId.iPopAccountId = entry.iMtmData2;
|
|
272 |
|
|
273 |
// Load preferences
|
|
274 |
aAccounts.SavePopIapSettingsL( popAccountId, aIapPrefs );
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
IMUM_OUT();
|
|
279 |
|
|
280 |
return error;
|
|
281 |
}
|
|
282 |
|
|
283 |
// ----------------------------------------------------------------------------
|
|
284 |
// CImumMboxManager::ForceAlwaysAskL()
|
|
285 |
// ----------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
void CImumMboxManager::ForceAlwaysAskL(
|
|
288 |
const TMsvId aMailboxId,
|
|
289 |
CEmailAccounts& aAccounts,
|
|
290 |
CImIAPPreferences& aIapPrefs,
|
|
291 |
CImumInternalApiImpl& aMailboxApi,
|
|
292 |
const TBool aSmtp )
|
|
293 |
{
|
|
294 |
IMUM_STATIC_CONTEXT( CImumMboxManager::ForceAlwaysAskL, 0, utils, KLogData );
|
|
295 |
IMUM_IN();
|
|
296 |
|
|
297 |
aIapPrefs.RemoveIAPL( 0 );
|
|
298 |
TImIAPChoice iap;
|
|
299 |
iap.iDialogPref = ECommDbDialogPrefPrompt;
|
|
300 |
iap.iIAP = 0;
|
|
301 |
aIapPrefs.AddIAPL( iap );
|
|
302 |
User::LeaveIfError( CImumMboxManager::SetIapPreferencesL(
|
|
303 |
aMailboxId, aAccounts, aIapPrefs, aMailboxApi, aSmtp ) );
|
|
304 |
|
|
305 |
IMUM_OUT();
|
|
306 |
}
|
|
307 |
|
|
308 |
/******************************************************************************
|
|
309 |
|
|
310 |
Manager tools
|
|
311 |
|
|
312 |
******************************************************************************/
|
|
313 |
|
|
314 |
// ----------------------------------------------------------------------------
|
|
315 |
// CImumMboxManager::CreateAccountFillIapL()
|
|
316 |
// ----------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
void CImumMboxManager::CreateAccountFillIapL(
|
|
319 |
CImumMboxData& aSettings )
|
|
320 |
{
|
|
321 |
IMUM_CONTEXT( CImumMboxManager::CreateAccountFillIapL, 0, KLogData );
|
|
322 |
IMUM_IN();
|
|
323 |
|
|
324 |
// This is not ideal choice, but current situation forces to do this,
|
|
325 |
// until Reset() funcion is exported from class CImIAPPreferences
|
|
326 |
delete aSettings.iIncomingIapPref;
|
|
327 |
aSettings.iIncomingIapPref = NULL;
|
|
328 |
delete aSettings.iOutgoingIapPref;
|
|
329 |
aSettings.iOutgoingIapPref = NULL;
|
|
330 |
|
|
331 |
// Make sure the preferences are made
|
|
332 |
if ( !aSettings.iIncomingIapPref )
|
|
333 |
{
|
|
334 |
aSettings.iIncomingIapPref = CImIAPPreferences::NewLC();
|
|
335 |
CleanupStack::Pop( aSettings.iIncomingIapPref );
|
|
336 |
}
|
|
337 |
|
|
338 |
if ( !aSettings.iOutgoingIapPref )
|
|
339 |
{
|
|
340 |
aSettings.iOutgoingIapPref = CImIAPPreferences::NewLC();
|
|
341 |
CleanupStack::Pop( aSettings.iOutgoingIapPref );
|
|
342 |
}
|
|
343 |
|
|
344 |
// Set incoming internet access point
|
|
345 |
TImIAPChoice incomingIapChoice;
|
|
346 |
incomingIapChoice.iIAP = aSettings.iIncomingIap;
|
|
347 |
incomingIapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
|
|
348 |
aSettings.iIncomingIapPref->AddIAPL( incomingIapChoice );
|
|
349 |
|
|
350 |
// Set outgoing internet access point
|
|
351 |
TImIAPChoice outgoingIapChoice;
|
|
352 |
outgoingIapChoice.iIAP = aSettings.iOutgoingIap;
|
|
353 |
outgoingIapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
|
|
354 |
aSettings.iOutgoingIapPref->AddIAPL( outgoingIapChoice );
|
|
355 |
|
|
356 |
IMUM_OUT();
|
|
357 |
}
|
|
358 |
|
|
359 |
// ----------------------------------------------------------------------------
|
|
360 |
// CImumMboxManager::LoadAccountFillIapL()
|
|
361 |
// ----------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void CImumMboxManager::LoadAccountFillIapL(
|
|
364 |
CImumMboxData& aSettings )
|
|
365 |
{
|
|
366 |
IMUM_CONTEXT( CImumMboxManager::LoadAccountFillIapL, 0, KLogData );
|
|
367 |
IMUM_IN();
|
|
368 |
|
|
369 |
//check Incoming IAP number
|
|
370 |
if ( aSettings.iIncomingIapPref->NumberOfIAPs() > 0 )
|
|
371 |
{
|
|
372 |
// Set internet access point (incoming IAP)
|
|
373 |
TImIAPChoice incomingIapChoice =
|
|
374 |
aSettings.iIncomingIapPref->IAPPreference( 0 );
|
|
375 |
aSettings.iIncomingIap = incomingIapChoice.iIAP;
|
|
376 |
}
|
|
377 |
|
|
378 |
//check SNAP define
|
|
379 |
else if( aSettings.iIncomingIapPref->SNAPDefined() )
|
|
380 |
{
|
|
381 |
aSettings.iIncomingIap = aSettings.iIncomingIapPref->SNAPPreference();
|
|
382 |
}
|
|
383 |
else
|
|
384 |
{
|
|
385 |
aSettings.iIncomingIap = 0;
|
|
386 |
}
|
|
387 |
|
|
388 |
//check Outgoing IAP number
|
|
389 |
if ( aSettings.iOutgoingIapPref->NumberOfIAPs() > 0 )
|
|
390 |
{
|
|
391 |
// Set internet access point (Outgoing IAP)
|
|
392 |
TImIAPChoice outgoingIapChoice =
|
|
393 |
aSettings.iOutgoingIapPref->IAPPreference( 0 );
|
|
394 |
aSettings.iOutgoingIap = outgoingIapChoice.iIAP;
|
|
395 |
}
|
|
396 |
//check SNAP define
|
|
397 |
else if( aSettings.iOutgoingIapPref->SNAPDefined() )
|
|
398 |
{
|
|
399 |
aSettings.iOutgoingIap = aSettings.iOutgoingIapPref->SNAPPreference();
|
|
400 |
}
|
|
401 |
else
|
|
402 |
{
|
|
403 |
aSettings.iOutgoingIap = 0;
|
|
404 |
}
|
|
405 |
|
|
406 |
IMUM_OUT();
|
|
407 |
}
|
|
408 |
|
|
409 |
// ----------------------------------------------------------------------------
|
|
410 |
// CImumMboxManager::DetermineDefaultAccountL()
|
|
411 |
// ----------------------------------------------------------------------------
|
|
412 |
//
|
|
413 |
void CImumMboxManager::DetermineDefaultAccountL(
|
|
414 |
CImumMboxData& aSettings )
|
|
415 |
{
|
|
416 |
IMUM_CONTEXT( CImumMboxManager::DetermineDefaultAccountL, 0, KLogData );
|
|
417 |
IMUM_IN();
|
|
418 |
|
|
419 |
// First check if default account id is set
|
|
420 |
aSettings.iDefaultAccountId =
|
|
421 |
MsvUiServiceUtilitiesInternal::DefaultServiceForMTML(
|
|
422 |
iMailboxApi.MsvSession(), KSenduiMtmSmtpUid, EFalse );
|
|
423 |
|
|
424 |
// Set the newly created one as a default account
|
|
425 |
if ( aSettings.iDefaultAccountId == KMsvUnknownServiceIndexEntryId )
|
|
426 |
{
|
|
427 |
if( !FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) ||
|
|
428 |
!MsvUiServiceUtilitiesInternal::OtherEmailMTMExistL(
|
|
429 |
iMailboxApi.MsvSession(), aSettings.iMailboxId ) )
|
|
430 |
{
|
|
431 |
TSmtpAccount smtpAccountId;
|
|
432 |
iAccounts->GetSmtpAccountL( aSettings.iMailboxId, smtpAccountId );
|
|
433 |
iAccounts->SetDefaultSmtpAccountL( smtpAccountId );
|
|
434 |
|
|
435 |
MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML(
|
|
436 |
iMailboxApi.MsvSession(), KSenduiMtmSmtpUid,
|
|
437 |
aSettings.iMailboxId );
|
|
438 |
aSettings.iDefaultAccountId = aSettings.iMailboxId;
|
|
439 |
}
|
|
440 |
}
|
|
441 |
IMUM_OUT();
|
|
442 |
}
|
|
443 |
|
|
444 |
// ----------------------------------------------------------------------------
|
|
445 |
// CImumMboxManager::RemoveAccountL()
|
|
446 |
// ----------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
void CImumMboxManager::RemoveAccountL(
|
|
449 |
const CImumMboxData& aSettings )
|
|
450 |
{
|
|
451 |
IMUM_CONTEXT( CImumMboxManager::RemoveAccountL, 0, KLogData );
|
|
452 |
IMUM_IN();
|
|
453 |
|
|
454 |
// Delete Imap4 or Pop3 account
|
|
455 |
if ( aSettings.iIsImap4 )
|
|
456 |
{
|
|
457 |
DeleteExtendedSettings( TIMAStorerParams(
|
|
458 |
aSettings.iImap4AccountId.iImapAccountId, KSenduiMtmImap4Uid ) );
|
|
459 |
|
|
460 |
DeleteBaseSettingsL( aSettings );
|
|
461 |
}
|
|
462 |
else
|
|
463 |
{
|
|
464 |
DeleteExtendedSettings( TIMAStorerParams(
|
|
465 |
aSettings.iPop3AccountId.iPopAccountId, KSenduiMtmPop3Uid ) );
|
|
466 |
|
|
467 |
DeleteBaseSettingsL( aSettings );
|
|
468 |
}
|
|
469 |
|
|
470 |
IMUM_OUT();
|
|
471 |
}
|
|
472 |
|
|
473 |
// ----------------------------------------------------------------------------
|
|
474 |
// CImumMboxManager::RemoveAccountL()
|
|
475 |
// ----------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CImumMboxManager::RemoveAccountL(
|
|
478 |
const TMsvEntry& aMailboxEntry, TBool aSilent )
|
|
479 |
{
|
|
480 |
IMUM_CONTEXT( CImumMboxManager::RemoveAccountL, 0, KLogData );
|
|
481 |
IMUM_IN();
|
|
482 |
|
|
483 |
if ( aSilent || AccountDeletionConditionsOkL( aMailboxEntry.Id() ) )
|
|
484 |
{
|
|
485 |
// Delete Imap4 or Pop3 account
|
|
486 |
if ( aMailboxEntry.iMtm == KSenduiMtmImap4Uid )
|
|
487 |
{
|
|
488 |
DeleteExtendedSettings( TIMAStorerParams(
|
|
489 |
aMailboxEntry.iMtmData2, KSenduiMtmImap4Uid ) );
|
|
490 |
|
|
491 |
DeleteBaseSettingsL( aMailboxEntry.iMtmData2, ETrue );
|
|
492 |
}
|
|
493 |
else
|
|
494 |
{
|
|
495 |
DeleteExtendedSettings( TIMAStorerParams(
|
|
496 |
aMailboxEntry.iMtmData2, KSenduiMtmPop3Uid ) );
|
|
497 |
|
|
498 |
DeleteBaseSettingsL( aMailboxEntry.iMtmData2, EFalse );
|
|
499 |
}
|
|
500 |
}
|
|
501 |
|
|
502 |
IMUM_OUT();
|
|
503 |
}
|
|
504 |
|
|
505 |
// ----------------------------------------------------------------------------
|
|
506 |
// CImumMboxManager::RemoveAccountL()
|
|
507 |
// ----------------------------------------------------------------------------
|
|
508 |
//
|
|
509 |
void CImumMboxManager::RemoveAccountL(
|
|
510 |
const TUint32 aRelatedAccountId,
|
|
511 |
const TUid& aMtmId )
|
|
512 |
{
|
|
513 |
IMUM_CONTEXT( CImumMboxManager::RemoveAccountL, 0, KLogData );
|
|
514 |
IMUM_IN();
|
|
515 |
|
|
516 |
// First remove the extended settings, as this cannot leave
|
|
517 |
DeleteExtendedSettings(
|
|
518 |
TIMAStorerParams( aRelatedAccountId, aMtmId ) );
|
|
519 |
|
|
520 |
// Delete Imap4 or Pop3 account
|
|
521 |
DeleteBaseSettingsL(
|
|
522 |
aRelatedAccountId, aMtmId == KSenduiMtmImap4Uid );
|
|
523 |
|
|
524 |
IMUM_OUT();
|
|
525 |
}
|
|
526 |
|
|
527 |
// ---------------------------------------------------------------------------
|
|
528 |
// CImumMboxManager::RemoveAccount()
|
|
529 |
// ---------------------------------------------------------------------------
|
|
530 |
//
|
|
531 |
void CImumMboxManager::RemoveAccount( const TMsvId aMailboxId, TBool aSilent )
|
|
532 |
{
|
|
533 |
IMUM_CONTEXT( CImumMboxManager::RemoveAccount, 0, KLogData );
|
|
534 |
IMUM_IN();
|
|
535 |
|
|
536 |
TMsvEntry entry;
|
|
537 |
TRAPD( error, entry = iMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
538 |
aMailboxId,
|
|
539 |
MImumInMailboxUtilities::ERequestReceiving ) );
|
|
540 |
|
|
541 |
if ( !error )
|
|
542 |
{
|
|
543 |
TRAP_IGNORE( RemoveAccountL( entry, aSilent ) );
|
|
544 |
}
|
|
545 |
|
|
546 |
IMUM_OUT();
|
|
547 |
}
|
|
548 |
|
|
549 |
|
|
550 |
/******************************************************************************
|
|
551 |
|
|
552 |
Account creation
|
|
553 |
|
|
554 |
******************************************************************************/
|
|
555 |
|
|
556 |
// ----------------------------------------------------------------------------
|
|
557 |
// CImumMboxManager::CreateEmailAccount()
|
|
558 |
// ----------------------------------------------------------------------------
|
|
559 |
//
|
|
560 |
void CImumMboxManager::CreateEmailAccount(
|
|
561 |
CImumMboxData& aSettings,
|
|
562 |
const TBool aPopulateDefaults )
|
|
563 |
{
|
|
564 |
IMUM_CONTEXT( CImumMboxManager::CreateEmailAccount, 0, KLogData );
|
|
565 |
IMUM_IN();
|
|
566 |
|
|
567 |
// If settings not ready, don't try to create
|
|
568 |
if ( aSettings.IsOk() )
|
|
569 |
{
|
|
570 |
// Attempt to create the mailaccount
|
|
571 |
TRAPD( error, CreateEmailAccountL( aSettings, aPopulateDefaults ) );
|
|
572 |
|
|
573 |
// Creating mailbox has failed, delete entries and cenrep settings
|
|
574 |
if ( error != KErrNone )
|
|
575 |
{
|
|
576 |
TRAP_IGNORE( RemoveAccountL( aSettings ) );
|
|
577 |
__ASSERT_DEBUG( EFalse, User::Panic( KImumMtmUiPanic, error ) );
|
|
578 |
}
|
|
579 |
}
|
|
580 |
|
|
581 |
IMUM_OUT();
|
|
582 |
}
|
|
583 |
|
|
584 |
// ---------------------------------------------------------------------------
|
|
585 |
// CImumMboxManager::CreateEmailAccountL()
|
|
586 |
// ---------------------------------------------------------------------------
|
|
587 |
//
|
|
588 |
TMsvId CImumMboxManager::CreateEmailAccountL(
|
|
589 |
const CImumInSettingsData& aSettingsData )
|
|
590 |
{
|
|
591 |
IMUM_CONTEXT( CImumMboxManager::CreateEmailAccountL, 0, KLogData );
|
|
592 |
IMUM_IN();
|
|
593 |
|
|
594 |
CImumMboxData* settings =
|
|
595 |
CImumMboxSymbianDataConverter::ConvertToSymbianMboxDataLC(
|
|
596 |
iMailboxApi, aSettingsData );
|
|
597 |
|
|
598 |
CreateEmailAccountL( *settings, EFalse );
|
|
599 |
|
|
600 |
TMsvId mboxId = settings->iMailboxId;
|
|
601 |
CleanupStack::PopAndDestroy( settings );
|
|
602 |
settings = NULL;
|
|
603 |
|
|
604 |
IMUM_OUT();
|
|
605 |
|
|
606 |
return mboxId;
|
|
607 |
}
|
|
608 |
|
|
609 |
// ----------------------------------------------------------------------------
|
|
610 |
// CImumMboxManager::CreateEmailAccountL()
|
|
611 |
// ----------------------------------------------------------------------------
|
|
612 |
//
|
|
613 |
void CImumMboxManager::CreateEmailAccountL(
|
|
614 |
CImumMboxData& aSettings,
|
|
615 |
const TBool aPopulateDefaults )
|
|
616 |
{
|
|
617 |
IMUM_CONTEXT( CImumMboxManager::CreateEmailAccountL, 0, KLogData );
|
|
618 |
IMUM_IN();
|
|
619 |
|
|
620 |
TUint32 id = 0;
|
|
621 |
TUid mtmId;
|
|
622 |
TMsvId serviceId = 0;
|
|
623 |
IMUM0(0, " ### Starting mailbox creation processs");
|
|
624 |
|
|
625 |
// Check for imap4
|
|
626 |
if ( aSettings.iIsImap4 )
|
|
627 |
{
|
|
628 |
IMUM0( 0, " # STEP1 : Create IMAP4 account" );
|
|
629 |
// Catch all the problems with account creation
|
|
630 |
id = CreateImap4AccountL( aSettings, aPopulateDefaults );
|
|
631 |
serviceId = aSettings.iImap4AccountId.iImapService;
|
|
632 |
mtmId = KSenduiMtmImap4Uid;
|
|
633 |
}
|
|
634 |
else
|
|
635 |
{
|
|
636 |
IMUM0( 0, " # STEP1 : Create POP3 account" );
|
|
637 |
|
|
638 |
id = CreatePop3AccountL( aSettings, aPopulateDefaults );
|
|
639 |
serviceId = aSettings.iPop3AccountId.iPopService;
|
|
640 |
mtmId = KSenduiMtmPop3Uid;
|
|
641 |
}
|
|
642 |
|
|
643 |
IMUM0( 0, " # STEP1.5 : Store IMEI" );
|
|
644 |
iCleaner->StoreIMEIToMailbox( aSettings.iMailboxId );
|
|
645 |
|
|
646 |
IMUM0( 0, " # STEP2 : Create extended settings" );
|
|
647 |
CreateExtendedSettingsL( aSettings.iMailboxId, id, mtmId, aSettings, aPopulateDefaults );
|
|
648 |
|
|
649 |
IMUM0( 0, " # STEP3 : Store account ID to entry" );
|
|
650 |
StoreAccountIdToEntryL( aSettings );
|
|
651 |
|
|
652 |
IMUM0( 0, " # STEP4 : Choose default account" );
|
|
653 |
DetermineDefaultAccountL( aSettings );
|
|
654 |
|
|
655 |
IMUM0( 0, " # STEP5 : Store signature" );
|
|
656 |
TRAP_IGNORE( StoreSignatureL( aSettings ) );
|
|
657 |
|
|
658 |
IMUM0( 0, " # STEP6 : Activate AO Email plugin if needed" );
|
|
659 |
if( serviceId && (
|
|
660 |
EMailAoOff != aSettings.iExtendedSettings->AlwaysOnlineState() ||
|
|
661 |
EMailEmnOff != aSettings.iExtendedSettings->EmailNotificationState() ) )
|
|
662 |
{
|
|
663 |
TRAPD( error, MsvEmailMtmUiUtils::SendAOCommandL( EServerAPIEmailTurnOn, serviceId ) );
|
|
664 |
if ( error != KErrNotFound )
|
|
665 |
{
|
|
666 |
User::LeaveIfError( error );
|
|
667 |
}
|
|
668 |
}
|
|
669 |
IMUM0(0, " ### Finishing mailbox creation processs");
|
|
670 |
IMUM_OUT();
|
|
671 |
}
|
|
672 |
|
|
673 |
// ----------------------------------------------------------------------------
|
|
674 |
// CImumMboxManager::CreateImap4AccountL()
|
|
675 |
// ----------------------------------------------------------------------------
|
|
676 |
//
|
|
677 |
TUint32 CImumMboxManager::CreateImap4AccountL(
|
|
678 |
CImumMboxData& aSettings,
|
|
679 |
const TBool aPopulateDefaults,
|
|
680 |
const TBool aReadOnly )
|
|
681 |
{
|
|
682 |
IMUM_CONTEXT( CImumMboxManager::CreateImap4AccountL, 0, KLogData );
|
|
683 |
IMUM_IN();
|
|
684 |
|
|
685 |
// Populate defaults
|
|
686 |
if ( aPopulateDefaults )
|
|
687 |
{
|
|
688 |
iAccounts->PopulateDefaultImapSettingsL(
|
|
689 |
*aSettings.iImap4Settings, *aSettings.iIncomingIapPref );
|
|
690 |
iAccounts->PopulateDefaultSmtpSettingsL(
|
|
691 |
*aSettings.iSmtpSettings, *aSettings.iOutgoingIapPref );
|
|
692 |
}
|
|
693 |
|
|
694 |
// Fill iap preferences
|
|
695 |
CreateAccountFillIapL( aSettings );
|
|
696 |
|
|
697 |
// Create the account
|
|
698 |
aSettings.iImap4AccountId = iAccounts->CreateImapAccountL(
|
|
699 |
aSettings.iName, *aSettings.iImap4Settings,
|
|
700 |
*aSettings.iIncomingIapPref, aReadOnly );
|
|
701 |
iAccounts->CreateSmtpAccountL( aSettings.iImap4AccountId,
|
|
702 |
*aSettings.iSmtpSettings, *aSettings.iOutgoingIapPref, aReadOnly );
|
|
703 |
|
|
704 |
aSettings.iMailboxId = aSettings.iImap4AccountId.iSmtpService;
|
|
705 |
|
|
706 |
IMUM_OUT();
|
|
707 |
|
|
708 |
return aSettings.iImap4AccountId.iImapAccountId;
|
|
709 |
}
|
|
710 |
|
|
711 |
// ----------------------------------------------------------------------------
|
|
712 |
// CImumMboxManager::CreatePop3AccountL()
|
|
713 |
// ----------------------------------------------------------------------------
|
|
714 |
//
|
|
715 |
TUint32 CImumMboxManager::CreatePop3AccountL(
|
|
716 |
CImumMboxData& aSettings,
|
|
717 |
const TBool aPopulateDefaults,
|
|
718 |
const TBool aReadOnly )
|
|
719 |
{
|
|
720 |
IMUM_CONTEXT( CImumMboxManager::CreatePop3AccountL, 0, KLogData );
|
|
721 |
IMUM_IN();
|
|
722 |
|
|
723 |
// Populate defaults
|
|
724 |
if ( aPopulateDefaults )
|
|
725 |
{
|
|
726 |
iAccounts->PopulateDefaultPopSettingsL(
|
|
727 |
*aSettings.iPop3Settings, *aSettings.iIncomingIapPref );
|
|
728 |
iAccounts->PopulateDefaultSmtpSettingsL(
|
|
729 |
*aSettings.iSmtpSettings, *aSettings.iOutgoingIapPref );
|
|
730 |
}
|
|
731 |
|
|
732 |
// Fill iap preferences
|
|
733 |
CreateAccountFillIapL( aSettings );
|
|
734 |
|
|
735 |
// Create the account
|
|
736 |
aSettings.iPop3AccountId = iAccounts->CreatePopAccountL(
|
|
737 |
aSettings.iName,
|
|
738 |
*aSettings.iPop3Settings, *aSettings.iIncomingIapPref, aReadOnly );
|
|
739 |
iAccounts->CreateSmtpAccountL( aSettings.iPop3AccountId,
|
|
740 |
*aSettings.iSmtpSettings, *aSettings.iOutgoingIapPref, aReadOnly );
|
|
741 |
|
|
742 |
aSettings.iMailboxId = aSettings.iPop3AccountId.iSmtpService;
|
|
743 |
|
|
744 |
IMUM_OUT();
|
|
745 |
|
|
746 |
return aSettings.iPop3AccountId.iPopAccountId;
|
|
747 |
}
|
|
748 |
|
|
749 |
// ----------------------------------------------------------------------------
|
|
750 |
// CImumMboxManager::CreateExtendedSettingsL()
|
|
751 |
// ----------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
void CImumMboxManager::CreateExtendedSettingsL(
|
|
754 |
const TMsvId aMailboxId,
|
|
755 |
const TUint32 aAccountId,
|
|
756 |
const TUid& aProtocol,
|
|
757 |
CImumMboxData& aSettings,
|
|
758 |
const TBool aPopulateDefaults )
|
|
759 |
{
|
|
760 |
IMUM_CONTEXT( CImumMboxManager::CreateExtendedSettingsL, 0, KLogData );
|
|
761 |
IMUM_IN();
|
|
762 |
|
|
763 |
// If populating has been successful
|
|
764 |
User::LeaveIfError( iMboxSettingsCtrl->CreateSettings(
|
|
765 |
aMailboxId, aAccountId, aProtocol,
|
|
766 |
*aSettings.iExtendedSettings, aPopulateDefaults ) );
|
|
767 |
|
|
768 |
IMUM_OUT();
|
|
769 |
}
|
|
770 |
|
|
771 |
/******************************************************************************
|
|
772 |
|
|
773 |
Account Deletion
|
|
774 |
|
|
775 |
******************************************************************************/
|
|
776 |
|
|
777 |
// ----------------------------------------------------------------------------
|
|
778 |
// CImumMboxManager::DeleteExtendedSettings()
|
|
779 |
// ----------------------------------------------------------------------------
|
|
780 |
//
|
|
781 |
TInt CImumMboxManager::DeleteExtendedSettings(
|
|
782 |
const TIMAStorerParams& aParams )
|
|
783 |
{
|
|
784 |
// Delete the settings
|
|
785 |
return iMboxSettingsCtrl->DeleteExtendedSettings( aParams );
|
|
786 |
}
|
|
787 |
|
|
788 |
// ----------------------------------------------------------------------------
|
|
789 |
// CImumMboxManager::DeleteRelatedSmtpAccountsL()
|
|
790 |
// ----------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
void CImumMboxManager::DeleteRelatedSmtpAccountsL(
|
|
793 |
const CImumMboxData& aSettings )
|
|
794 |
{
|
|
795 |
IMUM_CONTEXT( CImumMboxManager::DeleteRelatedSmtpAccountsL, 0, KLogData );
|
|
796 |
IMUM_IN();
|
|
797 |
|
|
798 |
// Get the available smtp accounts
|
|
799 |
RArray<TSmtpAccount> smtpAccountArray;
|
|
800 |
iAccounts->GetSmtpAccountsL( smtpAccountArray );
|
|
801 |
|
|
802 |
// Get the related service id
|
|
803 |
TMsvId relatedServiceId = aSettings.iIsImap4 ?
|
|
804 |
aSettings.iImap4AccountId.iImapService :
|
|
805 |
aSettings.iPop3AccountId.iPopService;
|
|
806 |
|
|
807 |
// Delete the accounts
|
|
808 |
DeleteSmtpAccountsL( relatedServiceId, smtpAccountArray );
|
|
809 |
|
|
810 |
smtpAccountArray.Reset();
|
|
811 |
|
|
812 |
IMUM_OUT();
|
|
813 |
}
|
|
814 |
|
|
815 |
// ----------------------------------------------------------------------------
|
|
816 |
// CImumMboxManager::DeleteRelatedSmtpAccountsL()
|
|
817 |
// ----------------------------------------------------------------------------
|
|
818 |
//
|
|
819 |
void CImumMboxManager::DeleteRelatedSmtpAccountsL(
|
|
820 |
const TUint32 aRelatedAccountId,
|
|
821 |
const TBool aIsImap4 )
|
|
822 |
{
|
|
823 |
IMUM_CONTEXT( CImumMboxManager::DeleteRelatedSmtpAccountsL, 0, KLogData );
|
|
824 |
IMUM_IN();
|
|
825 |
|
|
826 |
// Get the available imap accounts
|
|
827 |
TMsvId relatedService = KMsvNullIndexEntryId;
|
|
828 |
|
|
829 |
if ( aIsImap4 )
|
|
830 |
{
|
|
831 |
// Get Imap account
|
|
832 |
RIMASImap4IdArray imapAccountArray;
|
|
833 |
iAccounts->GetImapAccountsL( imapAccountArray );
|
|
834 |
|
|
835 |
// Find the account from imap accounts
|
|
836 |
for ( TInt mailbox = imapAccountArray.Count();
|
|
837 |
--mailbox >= 0 && relatedService == KMsvNullIndexEntryId; )
|
|
838 |
{
|
|
839 |
TUint32 imapId = imapAccountArray[mailbox].iImapAccountId;
|
|
840 |
if ( imapId == aRelatedAccountId )
|
|
841 |
{
|
|
842 |
relatedService = imapAccountArray[mailbox].iImapService;
|
|
843 |
}
|
|
844 |
}
|
|
845 |
|
|
846 |
imapAccountArray.Reset();
|
|
847 |
}
|
|
848 |
else
|
|
849 |
{
|
|
850 |
// Get pop account
|
|
851 |
RIMASPop3IdArray popAccountArray;
|
|
852 |
iAccounts->GetPopAccountsL( popAccountArray );
|
|
853 |
|
|
854 |
// Find the account from pop accounts
|
|
855 |
for ( TInt mailbox = popAccountArray.Count();
|
|
856 |
--mailbox >= 0 && relatedService == KMsvNullIndexEntryId; )
|
|
857 |
{
|
|
858 |
TUint32 popId = popAccountArray[mailbox].iPopAccountId;
|
|
859 |
if ( popId == aRelatedAccountId )
|
|
860 |
{
|
|
861 |
relatedService = popAccountArray[mailbox].iPopService;
|
|
862 |
}
|
|
863 |
}
|
|
864 |
|
|
865 |
popAccountArray.Reset();
|
|
866 |
}
|
|
867 |
|
|
868 |
// If found, remove the accounts
|
|
869 |
if ( relatedService != KMsvNullIndexEntryId )
|
|
870 |
{
|
|
871 |
RIMASSmtpIdArray smtpAccountArray;
|
|
872 |
iAccounts->GetSmtpAccountsL( smtpAccountArray );
|
|
873 |
|
|
874 |
// Delete the accounts
|
|
875 |
DeleteSmtpAccountsL( relatedService, smtpAccountArray );
|
|
876 |
smtpAccountArray.Reset();
|
|
877 |
}
|
|
878 |
|
|
879 |
IMUM_OUT();
|
|
880 |
}
|
|
881 |
|
|
882 |
// ----------------------------------------------------------------------------
|
|
883 |
// CImumMboxManager::DeleteSmtpAccountsL()
|
|
884 |
// ----------------------------------------------------------------------------
|
|
885 |
//
|
|
886 |
void CImumMboxManager::DeleteSmtpAccountsL(
|
|
887 |
const TMsvId aRelatedMailboxId,
|
|
888 |
const RIMASSmtpIdArray& aSmtpAccountArray )
|
|
889 |
{
|
|
890 |
IMUM_CONTEXT( CImumMboxManager::DeleteSmtpAccountsL, 0, KLogData );
|
|
891 |
IMUM_IN();
|
|
892 |
|
|
893 |
TSmtpAccount smtpId;
|
|
894 |
|
|
895 |
// Start checking the mailboxes
|
|
896 |
for ( TInt mailbox = aSmtpAccountArray.Count(); --mailbox >= 0; )
|
|
897 |
{
|
|
898 |
smtpId = aSmtpAccountArray[mailbox];
|
|
899 |
|
|
900 |
// If the related id matches with the smtp accounts related service
|
|
901 |
// id, the account can be deleted.
|
|
902 |
if ( aRelatedMailboxId == smtpId.iRelatedService )
|
|
903 |
{
|
|
904 |
iAccounts->DeleteSmtpAccountL( smtpId );
|
|
905 |
}
|
|
906 |
}
|
|
907 |
|
|
908 |
IMUM_OUT();
|
|
909 |
}
|
|
910 |
|
|
911 |
// ----------------------------------------------------------------------------
|
|
912 |
// CImumMboxManager::DeleteBaseSettingsL()
|
|
913 |
// ----------------------------------------------------------------------------
|
|
914 |
//
|
|
915 |
void CImumMboxManager::DeleteBaseSettingsL(
|
|
916 |
const TUint32 aRelatedAccountId,
|
|
917 |
const TBool aIsImap4 )
|
|
918 |
{
|
|
919 |
IMUM_CONTEXT( CImumMboxManager::DeleteBaseSettingsL, 0, KLogData );
|
|
920 |
|
|
921 |
// Remove the related smtp accounts
|
|
922 |
DeleteRelatedSmtpAccountsL( aRelatedAccountId, aIsImap4 );
|
|
923 |
|
|
924 |
// Determine the account type
|
|
925 |
if ( aIsImap4 )
|
|
926 |
{
|
|
927 |
// Remove the Imap4 account
|
|
928 |
TImapAccount imapId;
|
|
929 |
imapId.iImapAccountId = aRelatedAccountId;
|
|
930 |
iAccounts->DeleteImapAccountL( imapId );
|
|
931 |
}
|
|
932 |
else
|
|
933 |
{
|
|
934 |
// Remove the Pop3 account
|
|
935 |
TPopAccount popId;
|
|
936 |
popId.iPopAccountId = aRelatedAccountId;
|
|
937 |
iAccounts->DeletePopAccountL( popId );
|
|
938 |
}
|
|
939 |
|
|
940 |
IMUM_OUT();
|
|
941 |
}
|
|
942 |
|
|
943 |
// ----------------------------------------------------------------------------
|
|
944 |
// CImumMboxManager::DeleteBaseSettingsL()
|
|
945 |
// ----------------------------------------------------------------------------
|
|
946 |
//
|
|
947 |
void CImumMboxManager::DeleteBaseSettingsL(
|
|
948 |
const CImumMboxData& aSettings )
|
|
949 |
{
|
|
950 |
IMUM_CONTEXT( CImumMboxManager::DeleteBaseSettingsL, 0, KLogData );
|
|
951 |
IMUM_IN();
|
|
952 |
|
|
953 |
// Remove the related smtp accounts
|
|
954 |
DeleteRelatedSmtpAccountsL( aSettings );
|
|
955 |
|
|
956 |
// Determine the account type
|
|
957 |
if ( aSettings.iIsImap4 )
|
|
958 |
{
|
|
959 |
// Remove the Imap4 account
|
|
960 |
iAccounts->DeleteImapAccountL( aSettings.iImap4AccountId );
|
|
961 |
}
|
|
962 |
else
|
|
963 |
{
|
|
964 |
// Remove the Pop3 account
|
|
965 |
iAccounts->DeletePopAccountL( aSettings.iPop3AccountId );
|
|
966 |
}
|
|
967 |
|
|
968 |
IMUM_OUT();
|
|
969 |
}
|
|
970 |
|
|
971 |
// ----------------------------------------------------------------------------
|
|
972 |
// CImumMboxManager::DeleteAccountSettings()
|
|
973 |
// ----------------------------------------------------------------------------
|
|
974 |
//
|
|
975 |
TInt CImumMboxManager::DeleteAccountSettings(
|
|
976 |
const TUint32 aAccountId,
|
|
977 |
const TUid& aMtmId )
|
|
978 |
{
|
|
979 |
IMUM_CONTEXT( CImumMboxManager::DeleteAccountSettings, 0, KLogData );
|
|
980 |
IMUM_IN();
|
|
981 |
|
|
982 |
TInt error = KErrNone;
|
|
983 |
|
|
984 |
// Delete the related extended settings
|
|
985 |
if ( aMtmId == KSenduiMtmImap4Uid )
|
|
986 |
{
|
|
987 |
// Delete Imap4 or Pop3 account
|
|
988 |
TImapAccount imapId;
|
|
989 |
imapId.iImapAccountId = aAccountId;
|
|
990 |
TRAP( error, iAccounts->DeleteImapAccountL( imapId ) );
|
|
991 |
}
|
|
992 |
else if ( aMtmId == KSenduiMtmPop3Uid )
|
|
993 |
{
|
|
994 |
// Remove the Pop3 account
|
|
995 |
TPopAccount popId;
|
|
996 |
popId.iPopAccountId = aAccountId;
|
|
997 |
TRAP( error, iAccounts->DeletePopAccountL( popId ) );
|
|
998 |
}
|
|
999 |
else
|
|
1000 |
{
|
|
1001 |
// Remove the Smtp account
|
|
1002 |
TSmtpAccount smtpId;
|
|
1003 |
smtpId.iSmtpAccountId = aAccountId;
|
|
1004 |
TRAP( error, iAccounts->DeleteSmtpAccountL( smtpId ) );
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
if ( aMtmId != KSenduiMtmSmtpUid )
|
|
1008 |
{
|
|
1009 |
DeleteExtendedSettings(
|
|
1010 |
TIMAStorerParams( aAccountId, aMtmId ) );
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
IMUM_OUT();
|
|
1014 |
|
|
1015 |
return error;
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
// ---------------------------------------------------------------------------
|
|
1019 |
// CImumMboxManager::CheckAccountDeletionConditionsL()
|
|
1020 |
// ---------------------------------------------------------------------------
|
|
1021 |
//
|
|
1022 |
TBool CImumMboxManager::CheckAccountDeletionConditionsL(
|
|
1023 |
const TMsvId aMailboxId )
|
|
1024 |
{
|
|
1025 |
return AccountDeletionConditionsOkL( aMailboxId );
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
/******************************************************************************
|
|
1029 |
|
|
1030 |
Account Saving
|
|
1031 |
|
|
1032 |
******************************************************************************/
|
|
1033 |
|
|
1034 |
// ---------------------------------------------------------------------------
|
|
1035 |
// CImumMboxManager::SaveEmailSettingsL()
|
|
1036 |
// ---------------------------------------------------------------------------
|
|
1037 |
//
|
|
1038 |
void CImumMboxManager::SaveEmailSettingsL(
|
|
1039 |
const CImumInSettingsData& aSettingsData )
|
|
1040 |
{
|
|
1041 |
IMUM_CONTEXT( CImumMboxManager::SaveEmailSettingsL, 0, KLogData );
|
|
1042 |
IMUM_IN();
|
|
1043 |
|
|
1044 |
CImumMboxData* settings =
|
|
1045 |
CImumMboxSymbianDataConverter::ConvertToSymbianMboxDataLC(
|
|
1046 |
iMailboxApi, aSettingsData );
|
|
1047 |
|
|
1048 |
SaveEmailSettingsL( *settings );
|
|
1049 |
|
|
1050 |
CleanupStack::PopAndDestroy( settings );
|
|
1051 |
settings = NULL;
|
|
1052 |
|
|
1053 |
IMUM_OUT();
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
// ----------------------------------------------------------------------------
|
|
1057 |
// CImumMboxManager::SaveEmailSettingsL()
|
|
1058 |
// ----------------------------------------------------------------------------
|
|
1059 |
//
|
|
1060 |
TInt CImumMboxManager::SaveEmailSettingsL(
|
|
1061 |
CImumMboxData& aSettings )
|
|
1062 |
{
|
|
1063 |
IMUM_CONTEXT( CImumMboxManager::SaveEmailSettingsL, 0, KLogData );
|
|
1064 |
IMUM_IN();
|
|
1065 |
|
|
1066 |
// If settings not ready, don't try to create
|
|
1067 |
if ( !aSettings.IsOk() )
|
|
1068 |
{
|
|
1069 |
return KErrNotFound;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
TInt error = KErrNone;
|
|
1073 |
CreateAccountFillIapL( aSettings );
|
|
1074 |
|
|
1075 |
// Check for imap4
|
|
1076 |
if ( aSettings.iIsImap4 )
|
|
1077 |
{
|
|
1078 |
// Catch all the problems with account creation
|
|
1079 |
TRAP( error, SaveImap4SettingsL( aSettings ) );
|
|
1080 |
|
|
1081 |
// Attempt to save the extended settings, even if other settings have
|
|
1082 |
// failed to save
|
|
1083 |
iMboxSettingsCtrl->SaveSettings( *aSettings.iExtendedSettings );
|
|
1084 |
TRAP_IGNORE( StoreSignatureL( aSettings ) );
|
|
1085 |
}
|
|
1086 |
// It's a pop
|
|
1087 |
else
|
|
1088 |
{
|
|
1089 |
// Catch all the problems with account creation
|
|
1090 |
TRAP( error, SavePop3SettingsL( aSettings ) );
|
|
1091 |
|
|
1092 |
// Attempt to save the extended settings, even if other settings have
|
|
1093 |
// failed to save
|
|
1094 |
iMboxSettingsCtrl->SaveSettings( *aSettings.iExtendedSettings );
|
|
1095 |
TRAP_IGNORE( StoreSignatureL( aSettings ) );
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
IMUM_OUT();
|
|
1099 |
|
|
1100 |
return error;
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
// ----------------------------------------------------------------------------
|
|
1104 |
// CImumMboxManager::SavePop3SettingsL()
|
|
1105 |
// ----------------------------------------------------------------------------
|
|
1106 |
//
|
|
1107 |
void CImumMboxManager::SavePop3SettingsL(
|
|
1108 |
CImumMboxData& aSettings )
|
|
1109 |
{
|
|
1110 |
IMUM_CONTEXT( CImumMboxManager::SavePop3SettingsL, 0, KLogData );
|
|
1111 |
IMUM_IN();
|
|
1112 |
|
|
1113 |
TSmtpAccount smtpAccountId;
|
|
1114 |
iAccounts->GetSmtpAccountL(
|
|
1115 |
aSettings.iPop3AccountId.iSmtpService, smtpAccountId );
|
|
1116 |
|
|
1117 |
// Store the mailbox name
|
|
1118 |
aSettings.iPop3AccountId.iPopAccountName.Copy(
|
|
1119 |
aSettings.iName );
|
|
1120 |
smtpAccountId.iSmtpAccountName.Copy(
|
|
1121 |
aSettings.iName );
|
|
1122 |
|
|
1123 |
// Load mailbox settings
|
|
1124 |
iAccounts->SavePopSettingsL(
|
|
1125 |
aSettings.iPop3AccountId, *aSettings.iPop3Settings );
|
|
1126 |
iAccounts->SavePopIapSettingsL(
|
|
1127 |
aSettings.iPop3AccountId, *aSettings.iIncomingIapPref );
|
|
1128 |
iAccounts->SaveSmtpSettingsL(
|
|
1129 |
smtpAccountId, *aSettings.iSmtpSettings );
|
|
1130 |
iAccounts->SaveSmtpIapSettingsL(
|
|
1131 |
smtpAccountId, *aSettings.iOutgoingIapPref );
|
|
1132 |
|
|
1133 |
IMUM_OUT();
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
// ----------------------------------------------------------------------------
|
|
1137 |
// CImumMboxManager::SaveImap4SettingsL()
|
|
1138 |
// ----------------------------------------------------------------------------
|
|
1139 |
//
|
|
1140 |
void CImumMboxManager::SaveImap4SettingsL(
|
|
1141 |
CImumMboxData& aSettings )
|
|
1142 |
{
|
|
1143 |
IMUM_CONTEXT( CImumMboxManager::SaveImap4SettingsL, 0, KLogData );
|
|
1144 |
IMUM_IN();
|
|
1145 |
|
|
1146 |
TSmtpAccount smtpAccountId;
|
|
1147 |
iAccounts->GetSmtpAccountL(
|
|
1148 |
aSettings.iImap4AccountId.iSmtpService, smtpAccountId );
|
|
1149 |
|
|
1150 |
// Store the mailbox name
|
|
1151 |
aSettings.iImap4AccountId.iImapAccountName.Copy(
|
|
1152 |
aSettings.iName );
|
|
1153 |
smtpAccountId.iSmtpAccountName.Copy(
|
|
1154 |
aSettings.iName );
|
|
1155 |
|
|
1156 |
// Load mailbox settings
|
|
1157 |
iAccounts->SaveImapSettingsL(
|
|
1158 |
aSettings.iImap4AccountId, *aSettings.iImap4Settings );
|
|
1159 |
iAccounts->SaveImapIapSettingsL(
|
|
1160 |
aSettings.iImap4AccountId, *aSettings.iIncomingIapPref );
|
|
1161 |
iAccounts->SaveSmtpSettingsL(
|
|
1162 |
smtpAccountId, *aSettings.iSmtpSettings );
|
|
1163 |
iAccounts->SaveSmtpIapSettingsL(
|
|
1164 |
smtpAccountId, *aSettings.iOutgoingIapPref );
|
|
1165 |
|
|
1166 |
IMUM_OUT();
|
|
1167 |
}
|
|
1168 |
|
|
1169 |
// ----------------------------------------------------------------------------
|
|
1170 |
// CImumMboxManager::StoreAccountIdToEntryL()
|
|
1171 |
// ----------------------------------------------------------------------------
|
|
1172 |
//
|
|
1173 |
void CImumMboxManager::StoreAccountIdToEntryL(
|
|
1174 |
const TMsvId aMailboxId,
|
|
1175 |
const TUint32 aAccountId )
|
|
1176 |
{
|
|
1177 |
IMUM_CONTEXT( CImumMboxManager::StoreAccountIdToEntryL, 0, KLogData );
|
|
1178 |
IMUM_IN();
|
|
1179 |
|
|
1180 |
// Get the entry
|
|
1181 |
CMsvEntry* cEntry = iMailboxApi.MsvSession().GetEntryL( aMailboxId );
|
|
1182 |
CleanupStack::PushL( cEntry );
|
|
1183 |
|
|
1184 |
// Store the value to the entry
|
|
1185 |
TMsvEntry tEntry( cEntry->Entry() );
|
|
1186 |
tEntry.iMtmData2 = aAccountId;
|
|
1187 |
cEntry->ChangeL( tEntry );
|
|
1188 |
|
|
1189 |
CleanupStack::PopAndDestroy( cEntry );
|
|
1190 |
cEntry = NULL;
|
|
1191 |
|
|
1192 |
IMUM_OUT();
|
|
1193 |
}
|
|
1194 |
|
|
1195 |
// ----------------------------------------------------------------------------
|
|
1196 |
// CImumMboxManager::GetMailboxAccountIdsL()
|
|
1197 |
// ----------------------------------------------------------------------------
|
|
1198 |
//
|
|
1199 |
void CImumMboxManager::GetMailboxAccountIdsL(
|
|
1200 |
const TMsvId aMailboxId,
|
|
1201 |
TMsvId& aReceivingMailboxId,
|
|
1202 |
TUint32& aReceivingAccountId,
|
|
1203 |
TMsvId& aSendingMailboxId,
|
|
1204 |
TUint32& aSendingAccountId )
|
|
1205 |
{
|
|
1206 |
IMUM_CONTEXT( CImumMboxManager::GetMailboxAccountIdsL, 0, KLogData );
|
|
1207 |
IMUM_IN();
|
|
1208 |
|
|
1209 |
MImumInMailboxUtilities::RMsvEntryArray entries;
|
|
1210 |
iMailboxApi.MailboxUtilitiesL().GetMailboxEntriesL(
|
|
1211 |
aMailboxId, entries );
|
|
1212 |
TMsvEntry receiving = entries[0];
|
|
1213 |
TMsvEntry sending = entries[1];
|
|
1214 |
entries.Reset();
|
|
1215 |
|
|
1216 |
if ( receiving.iMtm == KSenduiMtmImap4Uid )
|
|
1217 |
{
|
|
1218 |
// Get Imap account id
|
|
1219 |
TImapAccount imapAccountId;
|
|
1220 |
iAccounts->GetImapAccountL( receiving.Id(), imapAccountId );
|
|
1221 |
|
|
1222 |
aReceivingMailboxId = receiving.Id();
|
|
1223 |
aReceivingAccountId = imapAccountId.iImapAccountId;
|
|
1224 |
aSendingMailboxId = sending.Id();
|
|
1225 |
}
|
|
1226 |
else if ( receiving.iMtm == KSenduiMtmPop3Uid )
|
|
1227 |
{
|
|
1228 |
// Get Pop account id
|
|
1229 |
TPopAccount popAccountId;
|
|
1230 |
iAccounts->GetPopAccountL( receiving.Id(), popAccountId );
|
|
1231 |
|
|
1232 |
aReceivingMailboxId = receiving.Id();
|
|
1233 |
aReceivingAccountId = popAccountId.iPopAccountId;
|
|
1234 |
aSendingMailboxId = sending.Id();
|
|
1235 |
}
|
|
1236 |
else
|
|
1237 |
{
|
|
1238 |
// This should not happen ever, but if it does for some reason
|
|
1239 |
// then leave, as the leave will be trapped and the mailbox
|
|
1240 |
// shall be removed after it
|
|
1241 |
User::Leave( KErrUnknown );
|
|
1242 |
}
|
|
1243 |
|
|
1244 |
// Get smtp account id
|
|
1245 |
TSmtpAccount smtpAccountId;
|
|
1246 |
iAccounts->GetSmtpAccountL( aSendingMailboxId, smtpAccountId );
|
|
1247 |
|
|
1248 |
aSendingAccountId = smtpAccountId.iSmtpAccountId;
|
|
1249 |
|
|
1250 |
IMUM_OUT();
|
|
1251 |
}
|
|
1252 |
|
|
1253 |
// ----------------------------------------------------------------------------
|
|
1254 |
// CImumMboxManager::StoreAccountIdToEntryL()
|
|
1255 |
// ----------------------------------------------------------------------------
|
|
1256 |
//
|
|
1257 |
void CImumMboxManager::StoreAccountIdToEntryL(
|
|
1258 |
CImumMboxData& aSettings )
|
|
1259 |
{
|
|
1260 |
IMUM_CONTEXT( CImumMboxManager::StoreAccountIdToEntryL, 0, KLogData );
|
|
1261 |
IMUM_IN();
|
|
1262 |
|
|
1263 |
TMsvId sendingMailboxId;
|
|
1264 |
TMsvId receivingMailboxId;
|
|
1265 |
TUint32 sendingAccountId;
|
|
1266 |
TUint32 receivingAccountId;
|
|
1267 |
GetMailboxAccountIdsL( aSettings.iMailboxId,
|
|
1268 |
receivingMailboxId, receivingAccountId,
|
|
1269 |
sendingMailboxId, sendingAccountId );
|
|
1270 |
|
|
1271 |
StoreAccountIdToEntryL( receivingMailboxId, receivingAccountId );
|
|
1272 |
StoreAccountIdToEntryL( sendingMailboxId, sendingAccountId );
|
|
1273 |
|
|
1274 |
IMUM_OUT();
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
/******************************************************************************
|
|
1278 |
|
|
1279 |
Account Loading
|
|
1280 |
|
|
1281 |
******************************************************************************/
|
|
1282 |
|
|
1283 |
// ----------------------------------------------------------------------------
|
|
1284 |
// CImumMboxManager::LoadEmailSettingsL()
|
|
1285 |
// ----------------------------------------------------------------------------
|
|
1286 |
//
|
|
1287 |
void CImumMboxManager::LoadEmailSettingsL(
|
|
1288 |
const TMsvEntry& aEntry,
|
|
1289 |
CImumMboxData& aSettings )
|
|
1290 |
{
|
|
1291 |
IMUM_CONTEXT( CImumMboxManager::LoadEmailSettingsL, 0, KLogData );
|
|
1292 |
IMUM_IN();
|
|
1293 |
|
|
1294 |
// Get both of the entries
|
|
1295 |
TMsvEntry receiving = iMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
1296 |
aEntry.Id(), MImumInMailboxUtilities::ERequestReceiving );
|
|
1297 |
|
|
1298 |
// Store the id and protocol
|
|
1299 |
aSettings.iMailboxId = receiving.iRelatedId;
|
|
1300 |
aSettings.iIsImap4 = ( receiving.iMtm == KSenduiMtmImap4Uid );
|
|
1301 |
|
|
1302 |
// Load settings based on the protocol
|
|
1303 |
if ( aSettings.iIsImap4 )
|
|
1304 |
{
|
|
1305 |
iAccounts->GetImapAccountL(
|
|
1306 |
receiving.Id(), aSettings.iImap4AccountId );
|
|
1307 |
LoadImap4SettingsL( aSettings );
|
|
1308 |
|
|
1309 |
// Load extended settings
|
|
1310 |
TUint32 accountId = aSettings.iImap4AccountId.iImapAccountId;
|
|
1311 |
iMboxSettingsCtrl->LoadSettings(
|
|
1312 |
TIMAStorerParams( accountId, receiving.iMtm ),
|
|
1313 |
*aSettings.iExtendedSettings );
|
|
1314 |
|
|
1315 |
// Attempt to read the signature
|
|
1316 |
TRAP_IGNORE( RestoreSignatureL( aSettings ) );
|
|
1317 |
}
|
|
1318 |
else // pop3
|
|
1319 |
{
|
|
1320 |
iAccounts->GetPopAccountL(
|
|
1321 |
receiving.Id(), aSettings.iPop3AccountId );
|
|
1322 |
LoadPop3SettingsL( aSettings );
|
|
1323 |
|
|
1324 |
// Load extended settings
|
|
1325 |
TUint32 accountId = aSettings.iPop3AccountId.iPopAccountId;
|
|
1326 |
iMboxSettingsCtrl->LoadSettings(
|
|
1327 |
TIMAStorerParams( accountId, receiving.iMtm ),
|
|
1328 |
*aSettings.iExtendedSettings );
|
|
1329 |
|
|
1330 |
// Attempt to read the signature
|
|
1331 |
TRAP_IGNORE( RestoreSignatureL( aSettings ) );
|
|
1332 |
}
|
|
1333 |
|
|
1334 |
IMUM_OUT();
|
|
1335 |
}
|
|
1336 |
|
|
1337 |
// ---------------------------------------------------------------------------
|
|
1338 |
// CImumMboxManager::LoadEmailSettingsL()
|
|
1339 |
// ---------------------------------------------------------------------------
|
|
1340 |
//
|
|
1341 |
CImumInSettingsData* CImumMboxManager::LoadEmailSettingsL(
|
|
1342 |
const TMsvId aMailboxId )
|
|
1343 |
{
|
|
1344 |
IMUM_CONTEXT( CImumMboxManager::LoadEmailSettingsL, 0, KLogData );
|
|
1345 |
IMUM_IN();
|
|
1346 |
|
|
1347 |
CImumMboxData* oldData = CImumMboxData::NewLC();
|
|
1348 |
TMsvEntry mailbox =
|
|
1349 |
iMailboxApi.MailboxUtilitiesL().GetMailboxEntryL( aMailboxId );
|
|
1350 |
LoadEmailSettingsL( mailbox, *oldData );
|
|
1351 |
|
|
1352 |
CImumInSettingsData* internalData =
|
|
1353 |
CImumMboxInternalDataConverter::ConvertToInternalMboxDataLC(
|
|
1354 |
iMailboxApi, *oldData );
|
|
1355 |
CleanupStack::Pop( internalData );
|
|
1356 |
CleanupStack::PopAndDestroy( oldData );
|
|
1357 |
oldData = NULL;
|
|
1358 |
|
|
1359 |
IMUM_OUT();
|
|
1360 |
|
|
1361 |
return internalData;
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
// ----------------------------------------------------------------------------
|
|
1365 |
// CImumMboxManager::LoadPop3SettingsL()
|
|
1366 |
// ----------------------------------------------------------------------------
|
|
1367 |
//
|
|
1368 |
void CImumMboxManager::LoadPop3SettingsL(
|
|
1369 |
CImumMboxData& aSettings )
|
|
1370 |
{
|
|
1371 |
IMUM_CONTEXT( CImumMboxManager::LoadPop3SettingsL, 0, KLogData );
|
|
1372 |
IMUM_IN();
|
|
1373 |
|
|
1374 |
TSmtpAccount smtpAccountId;
|
|
1375 |
iAccounts->GetSmtpAccountL(
|
|
1376 |
aSettings.iPop3AccountId.iSmtpService, smtpAccountId );
|
|
1377 |
|
|
1378 |
// Load mailbox settings
|
|
1379 |
iAccounts->LoadPopSettingsL(
|
|
1380 |
aSettings.iPop3AccountId, *aSettings.iPop3Settings );
|
|
1381 |
iAccounts->LoadPopIapSettingsL(
|
|
1382 |
aSettings.iPop3AccountId, *aSettings.iIncomingIapPref );
|
|
1383 |
iAccounts->LoadSmtpSettingsL(
|
|
1384 |
smtpAccountId, *aSettings.iSmtpSettings );
|
|
1385 |
iAccounts->LoadSmtpIapSettingsL(
|
|
1386 |
smtpAccountId, *aSettings.iOutgoingIapPref );
|
|
1387 |
|
|
1388 |
LoadAccountFillIapL( aSettings );
|
|
1389 |
aSettings.iName.Copy( aSettings.iPop3AccountId.iPopAccountName );
|
|
1390 |
|
|
1391 |
IMUM_OUT();
|
|
1392 |
}
|
|
1393 |
|
|
1394 |
// ----------------------------------------------------------------------------
|
|
1395 |
// CImumMboxManager::LoadImap4SettingsL()
|
|
1396 |
// ----------------------------------------------------------------------------
|
|
1397 |
//
|
|
1398 |
void CImumMboxManager::LoadImap4SettingsL(
|
|
1399 |
CImumMboxData& aSettings )
|
|
1400 |
{
|
|
1401 |
IMUM_CONTEXT( CImumMboxManager::LoadImap4SettingsL, 0, KLogData );
|
|
1402 |
IMUM_IN();
|
|
1403 |
|
|
1404 |
TSmtpAccount smtpAccountId;
|
|
1405 |
iAccounts->GetSmtpAccountL(
|
|
1406 |
aSettings.iImap4AccountId.iSmtpService, smtpAccountId );
|
|
1407 |
|
|
1408 |
// Load mailbox settings
|
|
1409 |
iAccounts->LoadImapSettingsL(
|
|
1410 |
aSettings.iImap4AccountId, *aSettings.iImap4Settings );
|
|
1411 |
iAccounts->LoadImapIapSettingsL(
|
|
1412 |
aSettings.iImap4AccountId, *aSettings.iIncomingIapPref );
|
|
1413 |
iAccounts->LoadSmtpSettingsL(
|
|
1414 |
smtpAccountId, *aSettings.iSmtpSettings );
|
|
1415 |
iAccounts->LoadSmtpIapSettingsL(
|
|
1416 |
smtpAccountId, *aSettings.iOutgoingIapPref );
|
|
1417 |
|
|
1418 |
LoadAccountFillIapL( aSettings );
|
|
1419 |
aSettings.iName.Copy( aSettings.iImap4AccountId.iImapAccountName );
|
|
1420 |
|
|
1421 |
IMUM_OUT();
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
/******************************************************************************
|
|
1425 |
|
|
1426 |
MISC TOOLS
|
|
1427 |
|
|
1428 |
******************************************************************************/
|
|
1429 |
|
|
1430 |
// ----------------------------------------------------------------------------
|
|
1431 |
// CImumMboxManager::StoreSignatureL()
|
|
1432 |
// ----------------------------------------------------------------------------
|
|
1433 |
//
|
|
1434 |
void CImumMboxManager::StoreSignatureL(
|
|
1435 |
const CImumMboxData& aSettings )
|
|
1436 |
{
|
|
1437 |
IMUM_CONTEXT( CImumMboxManager::StoreSignatureL, 0, KLogData );
|
|
1438 |
IMUM_IN();
|
|
1439 |
|
|
1440 |
// Get Signature
|
|
1441 |
CMsvEntry* entry = iMailboxApi.MsvSession().GetEntryL( aSettings.iMailboxId );
|
|
1442 |
CleanupStack::PushL( entry );
|
|
1443 |
CMsvStore* msvStore = entry->EditStoreL();
|
|
1444 |
CleanupStack::PushL( msvStore );
|
|
1445 |
|
|
1446 |
msvStore->StoreBodyTextL( *( aSettings.iSignature->iRichText ) );
|
|
1447 |
msvStore->CommitL();
|
|
1448 |
|
|
1449 |
CleanupStack::PopAndDestroy( msvStore );
|
|
1450 |
msvStore = NULL;
|
|
1451 |
CleanupStack::PopAndDestroy( entry );
|
|
1452 |
entry = NULL;
|
|
1453 |
|
|
1454 |
IMUM_OUT();
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
// ----------------------------------------------------------------------------
|
|
1458 |
// CImumMboxManager::RestoreSignatureL()
|
|
1459 |
// ----------------------------------------------------------------------------
|
|
1460 |
//
|
|
1461 |
void CImumMboxManager::RestoreSignatureL(
|
|
1462 |
CImumMboxData& aSettings )
|
|
1463 |
{
|
|
1464 |
IMUM_CONTEXT( CImumMboxManager::RestoreSignatureL, 0, KLogData );
|
|
1465 |
IMUM_IN();
|
|
1466 |
|
|
1467 |
// Get Signature
|
|
1468 |
CMsvEntry* entry = iMailboxApi.MsvSession().GetEntryL( aSettings.iMailboxId );
|
|
1469 |
CleanupStack::PushL( entry );
|
|
1470 |
CMsvStore* msvStore = entry->ReadStoreL();
|
|
1471 |
CleanupStack::PushL( msvStore );
|
|
1472 |
|
|
1473 |
aSettings.iSignature->CreateEmptyRichTextL();
|
|
1474 |
msvStore->RestoreBodyTextL( *( aSettings.iSignature->iRichText ) );
|
|
1475 |
|
|
1476 |
CleanupStack::PopAndDestroy( msvStore );
|
|
1477 |
msvStore = NULL;
|
|
1478 |
CleanupStack::PopAndDestroy( entry );
|
|
1479 |
entry = NULL;
|
|
1480 |
|
|
1481 |
IMUM_OUT();
|
|
1482 |
}
|
|
1483 |
|
|
1484 |
// ---------------------------------------------------------------------------
|
|
1485 |
// CImumMboxManager::IsConnectedL()
|
|
1486 |
// ---------------------------------------------------------------------------
|
|
1487 |
//
|
|
1488 |
TBool CImumMboxManager::IsConnectedL( const TMsvId aMailboxId ) const
|
|
1489 |
{
|
|
1490 |
IMUM_CONTEXT( CImumMboxManager::IsConnectedL, 0, KLogData );
|
|
1491 |
IMUM_IN();
|
|
1492 |
|
|
1493 |
TBool connected = EFalse;
|
|
1494 |
|
|
1495 |
// Make sure that none of the entries is in connected state
|
|
1496 |
MImumInMailboxUtilities::RMsvEntryArray entries;
|
|
1497 |
iMailboxApi.MailboxUtilitiesL().GetMailboxEntriesL(
|
|
1498 |
aMailboxId, entries );
|
|
1499 |
CleanupClosePushL( entries );
|
|
1500 |
|
|
1501 |
for ( TInt mbox = entries.Count(); --mbox >= 0 && !connected; )
|
|
1502 |
{
|
|
1503 |
connected = entries[mbox].Connected();
|
|
1504 |
}
|
|
1505 |
|
|
1506 |
CleanupStack::PopAndDestroy( &entries );
|
|
1507 |
|
|
1508 |
IMUM_OUT();
|
|
1509 |
|
|
1510 |
return connected;
|
|
1511 |
}
|
|
1512 |
|
|
1513 |
// ---------------------------------------------------------------------------
|
|
1514 |
// CImumMboxManager::IsLockedL()
|
|
1515 |
// ---------------------------------------------------------------------------
|
|
1516 |
//
|
|
1517 |
TBool CImumMboxManager::IsLockedL( const TMsvId aMailboxId ) const
|
|
1518 |
{
|
|
1519 |
IMUM_CONTEXT( CImumMboxManager::IsLockedL, 0, KLogData );
|
|
1520 |
IMUM_IN();
|
|
1521 |
|
|
1522 |
TBool isLocked = EFalse;
|
|
1523 |
CMsvEntry* centry =
|
|
1524 |
iMailboxApi.MsvSession().GetEntryL( aMailboxId );
|
|
1525 |
CleanupStack::PushL( centry );
|
|
1526 |
|
|
1527 |
// If the entry is locked, deletion should not be possible
|
|
1528 |
TRAPD( err, centry->ChangeL( centry->Entry() ) );
|
|
1529 |
if( err != KErrNone )
|
|
1530 |
{
|
|
1531 |
isLocked = ETrue;
|
|
1532 |
}
|
|
1533 |
|
|
1534 |
CleanupStack::PopAndDestroy( centry );
|
|
1535 |
centry = NULL;
|
|
1536 |
|
|
1537 |
IMUM_OUT();
|
|
1538 |
|
|
1539 |
return isLocked;
|
|
1540 |
}
|
|
1541 |
|
|
1542 |
// ----------------------------------------------------------------------------
|
|
1543 |
// CImumMboxManager::HandleMailboxInUseDeleteL()
|
|
1544 |
// ----------------------------------------------------------------------------
|
|
1545 |
//
|
|
1546 |
TBool CImumMboxManager::HandleMailboxInUseDeleteL(
|
|
1547 |
MImumInHealthServices::RMailboxIdArray& aMailboxes,
|
|
1548 |
const TMsvEntry& aSmtpEntry ) const
|
|
1549 |
{
|
|
1550 |
IMUM_CONTEXT( CImumMboxManager::HandleMailboxInUseDeleteL, 0, KLogData );
|
|
1551 |
IMUM_IN();
|
|
1552 |
TBool continueDeletion(ETrue);
|
|
1553 |
TMsvId newDefaultId = 0;
|
|
1554 |
TInt mailboxCount = aMailboxes.Count();
|
|
1555 |
if ( mailboxCount == 2 ) // CSI: 47 # Mailbox count.
|
|
1556 |
{
|
|
1557 |
// set default to be the other one
|
|
1558 |
TInt newDefaultIndex =
|
|
1559 |
( aSmtpEntry.Id() == aMailboxes[0] ) ? 1 : 0;
|
|
1560 |
newDefaultId = aMailboxes[newDefaultIndex];
|
|
1561 |
}
|
|
1562 |
else
|
|
1563 |
{
|
|
1564 |
// To show mailbox name list, the array must be constructed here
|
|
1565 |
CDesCArrayFlat* items =
|
|
1566 |
new ( ELeave ) CDesCArrayFlat( KImumMboxArrayGranularity );
|
|
1567 |
CleanupStack::PushL( items );
|
|
1568 |
|
|
1569 |
TMsvEntry tempEntry;
|
|
1570 |
TInt delIndex=-1;
|
|
1571 |
for (TInt loop = 0; loop < mailboxCount; loop++)
|
|
1572 |
{
|
|
1573 |
TMsvId tempServiceId;
|
|
1574 |
User::LeaveIfError( iMailboxApi.MsvSession().GetEntry(
|
|
1575 |
aMailboxes[loop],
|
|
1576 |
tempServiceId,
|
|
1577 |
tempEntry ) );
|
|
1578 |
if ( aSmtpEntry.Id() != tempEntry.Id() )
|
|
1579 |
{
|
|
1580 |
items->AppendL( tempEntry.iDetails );
|
|
1581 |
}
|
|
1582 |
else
|
|
1583 |
{
|
|
1584 |
delIndex = loop;
|
|
1585 |
}
|
|
1586 |
}
|
|
1587 |
if ( delIndex>=0 )
|
|
1588 |
{
|
|
1589 |
//take the mailbox to be deleted off from the array
|
|
1590 |
aMailboxes.Remove(delIndex);
|
|
1591 |
}
|
|
1592 |
|
|
1593 |
TInt index = 0;
|
|
1594 |
CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog(&index);
|
|
1595 |
dlg->PrepareLC( R_IMUM_NEW_DEFAULT_MAILBOX_LIST_QUERY );
|
|
1596 |
dlg->SetItemTextArray( items );
|
|
1597 |
dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
1598 |
if ( dlg->RunLD( ) == EEikBidOk )
|
|
1599 |
{
|
|
1600 |
newDefaultId = aMailboxes[index];
|
|
1601 |
}
|
|
1602 |
else
|
|
1603 |
{
|
|
1604 |
continueDeletion = EFalse;
|
|
1605 |
}
|
|
1606 |
|
|
1607 |
CleanupStack::PopAndDestroy( items ); // items
|
|
1608 |
items = NULL;
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
if ( newDefaultId )
|
|
1612 |
{
|
|
1613 |
// Set default
|
|
1614 |
MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML(
|
|
1615 |
iMailboxApi.MsvSession(),
|
|
1616 |
KSenduiMtmSmtpUid,
|
|
1617 |
newDefaultId );
|
|
1618 |
}
|
|
1619 |
|
|
1620 |
IMUM_OUT();
|
|
1621 |
return continueDeletion;
|
|
1622 |
}
|
|
1623 |
|
|
1624 |
// ---------------------------------------------------------------------------
|
|
1625 |
// CImumMboxManager::AccountDeletionConditionsOkL()
|
|
1626 |
// ---------------------------------------------------------------------------
|
|
1627 |
//
|
|
1628 |
TBool CImumMboxManager::AccountDeletionConditionsOkL(
|
|
1629 |
const TMsvId aMailboxId )
|
|
1630 |
{
|
|
1631 |
IMUM_CONTEXT( CImumMboxManager::AccountDeletionConditionsOkL, 0, KLogData );
|
|
1632 |
IMUM_IN();
|
|
1633 |
|
|
1634 |
TBool conditionsOk = EFalse;
|
|
1635 |
|
|
1636 |
// Entry is required to get the name of the mailbox Id
|
|
1637 |
TMsvEntry mailbox = iMailboxApi.MailboxUtilitiesL().GetMailboxEntryL(
|
|
1638 |
aMailboxId, MImumInMailboxUtilities::ERequestSending );
|
|
1639 |
TBuf<KImumMboxQueryTextLength> name;
|
|
1640 |
name.Copy( mailbox.iDetails.Left( KImumMboxQueryTextLength ) );
|
|
1641 |
TUid mtm = KSenduiMtmSmtpUid;
|
|
1642 |
|
|
1643 |
TMsvId defaultService = MsvUiServiceUtilitiesInternal::
|
|
1644 |
DefaultServiceForMTML(
|
|
1645 |
iMailboxApi.MsvSession(), mtm, EFalse );
|
|
1646 |
|
|
1647 |
// Get the list of available mailboxes
|
|
1648 |
MImumInHealthServices::RMailboxIdArray mailboxes;
|
|
1649 |
iMailboxApi.HealthServicesL().GetMailboxList( mailboxes,
|
|
1650 |
MImumInHealthServices::EFlagGetHealthy |
|
|
1651 |
MImumInHealthServices::EFlagIncludeSmtp );
|
|
1652 |
CleanupClosePushL( mailboxes );
|
|
1653 |
|
|
1654 |
// Don't allow locked or connected mailboxes to be deleted
|
|
1655 |
if ( IsConnectedL( aMailboxId ) ||
|
|
1656 |
IsLockedL( mailbox.Id() ) )
|
|
1657 |
{
|
|
1658 |
CIMSSettingsNoteUi::ShowNoteL(
|
|
1659 |
R_IMUM_SETTINGS_MAIL_NO_DELETE, EIMSInformationNote, ETrue );
|
|
1660 |
}
|
|
1661 |
//
|
|
1662 |
else if ( mailboxes.Count() == 1 )
|
|
1663 |
{
|
|
1664 |
conditionsOk =
|
|
1665 |
CIMSSettingsNoteUi::ShowQueryL<KImumMboxQueryTextLength>(
|
|
1666 |
R_IMUM_SETTINGS_MAIL_QUEST_DEL,
|
|
1667 |
mailbox.iDetails );
|
|
1668 |
|
|
1669 |
}
|
|
1670 |
// If the current mailbox is not default, it can be deleted
|
|
1671 |
// immediately.
|
|
1672 |
else if ( mailbox.Id() != defaultService )
|
|
1673 |
{
|
|
1674 |
conditionsOk =
|
|
1675 |
CIMSSettingsNoteUi::ShowQueryL<KImumMboxQueryTextLength>(
|
|
1676 |
R_IMUM_COMMON_CONF_DELETE,
|
|
1677 |
mailbox.iDetails );
|
|
1678 |
}
|
|
1679 |
else
|
|
1680 |
{
|
|
1681 |
conditionsOk =
|
|
1682 |
CIMSSettingsNoteUi::ShowQueryL<KImumMboxQueryTextLength>(
|
|
1683 |
R_IMUM_SETTINGS_MAIL_QUEST_D,
|
|
1684 |
mailbox.iDetails );
|
|
1685 |
|
|
1686 |
if ( conditionsOk )
|
|
1687 |
{
|
|
1688 |
conditionsOk = HandleMailboxInUseDeleteL( mailboxes, mailbox );
|
|
1689 |
}
|
|
1690 |
}
|
|
1691 |
|
|
1692 |
CleanupStack::PopAndDestroy( &mailboxes );
|
|
1693 |
|
|
1694 |
IMUM_OUT();
|
|
1695 |
return conditionsOk;
|
|
1696 |
}
|
|
1697 |
|
|
1698 |
|
|
1699 |
// End Of File
|
|
1700 |
|