719
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Symbian Foundation License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// [TestStep Name]
|
|
15 |
// ModifyPopSettings
|
|
16 |
// [Paramaters]
|
|
17 |
// PopAccountName : Name of the Pop account
|
|
18 |
// ConfigFileName : Config file from which the Pop account settings are read
|
|
19 |
// [Test Step Description]
|
|
20 |
// ModifyPopSettings Test Action is intended to modify and save the existing settings to CenRep
|
|
21 |
// for the specified Pop account Id
|
|
22 |
// [APIs Used]
|
|
23 |
// CEmailAccounts::ModifyPopSettingsL
|
|
24 |
// CImPop3Settings::SetServerAddressL
|
|
25 |
// CImPop3Settings::SetUserAddressL
|
|
26 |
// CImPop3Settings::SetLoginNameL
|
|
27 |
// CImPop3Settings::SetPasswordL
|
|
28 |
// CImPop3Settings::SetPort
|
|
29 |
// CImPop3Settings::SetSecureSockets
|
|
30 |
// CImPop3Settings::SetVersion
|
|
31 |
// CImPop3Settings::SetFolderPathL
|
|
32 |
// CImPop3Settings::SetPathSeparator
|
|
33 |
// CImPop3Settings::SetMaxEmailSize
|
|
34 |
// CImPop3Settings::SetGetMailOptions
|
|
35 |
// CImPop3Settings::SetInboxSynchronisationLimit
|
|
36 |
// CImPop3Settings::SetMailboxSynchronisationLimit
|
|
37 |
// CImSmtpSettings::SetServerAddressL
|
|
38 |
// CImSmtpSettings::SetEmailAddressL
|
|
39 |
// CImSmtpSettings::SetBodyEncoding
|
|
40 |
// CImSmtpSettings::SetReceiptAddressL
|
|
41 |
// CImSmtpSettings::SetRequestReceipts
|
|
42 |
// CImSmtpSettings::SetSendMessageOption
|
|
43 |
// CImSmtpSettings::SetPort
|
|
44 |
// CImSmtpSettings::SetEmailAliasL
|
|
45 |
// CImSmtpSettings::SetBodyEncoding
|
|
46 |
// CImSmtpSettings::SetDefaultMsgCharSet
|
|
47 |
// CImSmtpSettings::SetUserAddress
|
|
48 |
// CImSmtpSettings::SetVersion
|
|
49 |
// CImIAPPreferences::Version
|
|
50 |
// CImIAPPreferences::AddIAPL
|
|
51 |
//
|
|
52 |
//
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
/**
|
|
57 |
@file
|
|
58 |
*/
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
// User include
|
|
63 |
#include "T_ModifyPopSettings.h"
|
|
64 |
#include <t_utilsreademailsettingsfromconfigfile.h>
|
|
65 |
#include <t_utilscentralrepository.h>
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
// epoc inlcudes
|
|
70 |
#include <cemailaccounts.h>
|
|
71 |
#include <pop3set.h>
|
|
72 |
#include <iapprefs.h>
|
|
73 |
#include <smtpset.h>
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
// Literals used
|
|
78 |
_LIT(KPopAccountName,"PopAccountName");
|
|
79 |
_LIT(KPopConfigFileName,"PopConfigFileName");
|
|
80 |
|
|
81 |
|
|
82 |
/**
|
|
83 |
CT_MsgModifyPopSettings()
|
|
84 |
Sets the teststep name to KModifyPopSettings
|
|
85 |
|
|
86 |
@param aSharedDataPOP
|
|
87 |
Data shared across the POP test steps. Ex. Session
|
|
88 |
*/
|
|
89 |
CT_MsgModifyPopSettings::CT_MsgModifyPopSettings(CT_MsgSharedDataPop& aSharedDataPOP)
|
|
90 |
: CT_MsgSyncStepPOP(aSharedDataPOP)
|
|
91 |
{
|
|
92 |
SetTestStepName(KModifyPopSettings);
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
/**
|
|
97 |
~CT_MsgModifyPopSettings()
|
|
98 |
Destructor
|
|
99 |
*/
|
|
100 |
CT_MsgModifyPopSettings::~CT_MsgModifyPopSettings()
|
|
101 |
{
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
/**
|
|
106 |
doTestStepL()
|
|
107 |
Reads the Pop account name, config file name from the ini file.
|
|
108 |
It then modifies the account settings with the settings read from the config file
|
|
109 |
|
|
110 |
@return
|
|
111 |
Returns the test step result
|
|
112 |
*/
|
|
113 |
TVerdict CT_MsgModifyPopSettings::doTestStepL()
|
|
114 |
{
|
|
115 |
INFO_PRINTF1(_L("Test Step: ModifyPopSettings"));
|
|
116 |
// Read the Pop account name from the ini file
|
|
117 |
TPtrC popAccountName;
|
|
118 |
if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName))
|
|
119 |
{
|
|
120 |
ERR_PRINTF1(_L("PopAccount Name is not specified"));
|
|
121 |
SetTestStepResult(EFail);
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
TPtrC configFileName;
|
|
126 |
if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, configFileName))
|
|
127 |
{
|
|
128 |
ERR_PRINTF1(_L("Configuration file path is not specified"));
|
|
129 |
SetTestStepResult(EFail);
|
|
130 |
}
|
|
131 |
else
|
|
132 |
{
|
|
133 |
// Retrieving the Pop service Id for the given Pop account
|
|
134 |
TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName);
|
|
135 |
INFO_PRINTF2(_L("Pop service id is %d"),popServiceId);
|
|
136 |
|
|
137 |
if(popServiceId == KMsvNullIndexEntryId)
|
|
138 |
{
|
|
139 |
ERR_PRINTF1(_L("Invalid POP account name specified"));
|
|
140 |
SetTestStepResult(EFail);
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
|
|
145 |
|
|
146 |
CImPop3Settings* popSettings = new(ELeave) CImPop3Settings();
|
|
147 |
CleanupStack::PushL(popSettings);
|
|
148 |
|
|
149 |
CImIAPPreferences* popIapPrefs = CImIAPPreferences::NewLC();
|
|
150 |
|
|
151 |
CImSmtpSettings* smtpSettings = new(ELeave) CImSmtpSettings();
|
|
152 |
CleanupStack::PushL(smtpSettings);
|
|
153 |
|
|
154 |
CImIAPPreferences* smtpIapPrefs = CImIAPPreferences::NewLC();
|
|
155 |
|
|
156 |
TPopAccount popAccount;
|
|
157 |
emailAccounts->GetPopAccountL(popServiceId, popAccount);
|
|
158 |
|
|
159 |
emailAccounts->PopulateDefaultPopSettingsL(*popSettings, *popIapPrefs);
|
|
160 |
emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *smtpIapPrefs);
|
|
161 |
|
|
162 |
_LIT(KEmailAdd, "EmailAdd");
|
|
163 |
|
|
164 |
TPtrC ptrEmailAdd;
|
|
165 |
if(!GetStringFromConfig(ConfigSection(), KEmailAdd, ptrEmailAdd))
|
|
166 |
{
|
|
167 |
ERR_PRINTF1(_L("Email Address not specified"));
|
|
168 |
}
|
|
169 |
|
|
170 |
TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings, *popIapPrefs, ptrEmailAdd));
|
|
171 |
if(err)
|
|
172 |
{
|
|
173 |
ERR_PRINTF2(_L("Failure while setting the Pop setting parameters, failed with error %d"), err);
|
|
174 |
SetTestStepResult(EFail);
|
|
175 |
}
|
|
176 |
else
|
|
177 |
{
|
|
178 |
TRAPD(error, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadSmtpSettingsFromConfigurationFileL(configFileName, *smtpSettings, *smtpIapPrefs, ptrEmailAdd));
|
|
179 |
if(error)
|
|
180 |
{
|
|
181 |
ERR_PRINTF2(_L("Failure while setting the SMTP setting parameters, failed with error %d"), error);
|
|
182 |
SetTestStepResult(EFail);
|
|
183 |
}
|
|
184 |
else
|
|
185 |
{
|
|
186 |
// Save the new settings
|
|
187 |
emailAccounts->SavePopSettingsL(popAccount, *popSettings);
|
|
188 |
emailAccounts->SavePopIapSettingsL(popAccount, *popIapPrefs);
|
|
189 |
|
|
190 |
TSmtpAccount smtpAccount;
|
|
191 |
emailAccounts->GetSmtpAccountL(popAccount.iSmtpService, smtpAccount);
|
|
192 |
|
|
193 |
emailAccounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings);
|
|
194 |
emailAccounts->SaveSmtpIapSettingsL(smtpAccount, *smtpIapPrefs);
|
|
195 |
}
|
|
196 |
}
|
|
197 |
CleanupStack::PopAndDestroy(5, emailAccounts); //smtpIapPrefs,smtpSettings,popIapPrefs,popSettings,emailAccounts
|
|
198 |
}
|
|
199 |
}
|
|
200 |
}
|
|
201 |
return TestStepResult();
|
|
202 |
}
|
|
203 |
|
|
204 |
|