47
|
1 |
/*
|
|
2 |
* Copyright (c) 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "nmapipopimapsettingsmanager.h"
|
|
19 |
|
|
20 |
#include <imapset.h>
|
|
21 |
#include <pop3set.h>
|
|
22 |
#include <iapprefs.h>
|
|
23 |
#include <cemailaccounts.h>
|
|
24 |
#include <xqconversions.h>
|
|
25 |
|
|
26 |
|
|
27 |
static const int DefaultPopPort = 110;
|
|
28 |
static const int DefaultImapPort = 993;
|
|
29 |
|
|
30 |
using namespace EmailClientApi;
|
|
31 |
|
|
32 |
NmApiPopImapSettingsManager::NmApiPopImapSettingsManager()
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
NmApiPopImapSettingsManager::~NmApiPopImapSettingsManager()
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
bool NmApiPopImapSettingsManager::populateDefaults(const QString &mailboxType, NmApiMailboxSettingsData &data)
|
|
41 |
{
|
|
42 |
bool ret = false;
|
|
43 |
|
|
44 |
QT_TRY {
|
|
45 |
if (mailboxType==NmApiMailboxTypePop) {
|
|
46 |
populatePopDefs(data);
|
|
47 |
ret = true;
|
|
48 |
}
|
|
49 |
else if (mailboxType==NmApiMailboxTypeImap) {
|
|
50 |
populateImapDefs(data);
|
|
51 |
ret = true;
|
|
52 |
}
|
|
53 |
else {
|
|
54 |
ret = false;
|
|
55 |
}
|
|
56 |
}
|
|
57 |
QT_CATCH(...){
|
|
58 |
ret = false;
|
|
59 |
}
|
|
60 |
|
|
61 |
return ret;
|
|
62 |
}
|
|
63 |
|
|
64 |
void NmApiPopImapSettingsManager::populateImapDefs(NmApiMailboxSettingsData &data)
|
|
65 |
{
|
|
66 |
QScopedPointer<CImImap4Settings> imapSettings(new CImImap4Settings());
|
|
67 |
|
|
68 |
QScopedPointer<CImIAPPreferences> iapPref;
|
|
69 |
QT_TRAP_THROWING(iapPref.reset(CImIAPPreferences::NewLC());
|
|
70 |
CleanupStack::Pop(iapPref.data()));
|
|
71 |
|
|
72 |
QScopedPointer<CEmailAccounts> mailAccounts;
|
|
73 |
QT_TRAP_THROWING(mailAccounts.reset(CEmailAccounts::NewL()));
|
|
74 |
|
|
75 |
QT_TRAP_THROWING( mailAccounts->PopulateDefaultImapSettingsL(*imapSettings,*iapPref));
|
|
76 |
|
|
77 |
data.setValue(IncomingLoginName,
|
|
78 |
XQConversions::s60Desc8ToQString(imapSettings->LoginName()));
|
|
79 |
|
|
80 |
data.setValue(IncomingPassword,
|
|
81 |
XQConversions::s60Desc8ToQString(imapSettings->Password()));
|
|
82 |
|
|
83 |
data.setValue(IncomingMailServer,
|
|
84 |
XQConversions::s60DescToQString(imapSettings->ServerAddress()));
|
|
85 |
|
|
86 |
if (imapSettings->Port()) {
|
|
87 |
data.setValue(IncomingPort, imapSettings->Port());
|
|
88 |
}
|
|
89 |
else {
|
|
90 |
data.setValue(IncomingPort, DefaultImapPort);
|
|
91 |
}
|
|
92 |
|
|
93 |
data.setValue(OutgoingSecureSockets, imapSettings->SecureSockets());
|
|
94 |
data.setValue(OutgoingSSLWrapper, imapSettings->SSLWrapper());
|
|
95 |
}
|
|
96 |
|
|
97 |
void NmApiPopImapSettingsManager::populatePopDefs(NmApiMailboxSettingsData &data)
|
|
98 |
{
|
|
99 |
QScopedPointer<CImPop3Settings> popSettings(new CImPop3Settings());
|
|
100 |
|
|
101 |
QScopedPointer<CImIAPPreferences> iapPref;
|
|
102 |
QT_TRAP_THROWING(iapPref.reset(CImIAPPreferences::NewLC());
|
|
103 |
CleanupStack::Pop(iapPref.data()));
|
|
104 |
|
|
105 |
QScopedPointer<CEmailAccounts> mailAccounts;
|
|
106 |
QT_TRAP_THROWING(mailAccounts.reset(CEmailAccounts::NewL()));
|
|
107 |
|
|
108 |
QT_TRAP_THROWING( mailAccounts->PopulateDefaultPopSettingsL(*popSettings,*iapPref));
|
|
109 |
|
|
110 |
data.setValue(IncomingLoginName,
|
|
111 |
XQConversions::s60Desc8ToQString(popSettings->LoginName()));
|
|
112 |
|
|
113 |
data.setValue(IncomingPassword,
|
|
114 |
XQConversions::s60Desc8ToQString(popSettings->Password()));
|
|
115 |
|
|
116 |
data.setValue(IncomingMailServer,
|
|
117 |
XQConversions::s60DescToQString(popSettings->ServerAddress()));
|
|
118 |
|
|
119 |
if (popSettings->Port()) {
|
|
120 |
data.setValue(IncomingPort, popSettings->Port());
|
|
121 |
}
|
|
122 |
else {
|
|
123 |
data.setValue(IncomingPort, DefaultPopPort);
|
|
124 |
}
|
|
125 |
|
|
126 |
data.setValue(OutgoingSecureSockets, popSettings->SecureSockets());
|
|
127 |
data.setValue(OutgoingSSLWrapper, popSettings->SSLWrapper());
|
|
128 |
}
|
|
129 |
|
|
130 |
|