|
1 // Copyright (c) 2004-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // CreateImapAccount |
|
17 // [Action Parameters] |
|
18 // configFile input TInt |
|
19 // accountId output TIMAP4Account |
|
20 // ImapSettings output CImImap4Settings |
|
21 // ImapIAP output CImIAPPreferences |
|
22 // SMTPSettings output CImSMTPSettings |
|
23 // SmtpIAP output CImIAPPreferences |
|
24 // [Action Description] |
|
25 // CreateImapAccount Test Action is intended to create an IMAP account in the |
|
26 // Central Repository using the configuration settings from ini file. This ini |
|
27 // file includes both IMAP, SMTP settings and IAP preference settings for both |
|
28 // IMAP and SMTP. |
|
29 // [APIs Used] |
|
30 // CEmailAccounts::CreateImapAccountL |
|
31 // CImImap4Settings::SetServerAddressL |
|
32 // CImImap4Settings::SetUserAddressL |
|
33 // CImImap4Settings::SetLoginNameL |
|
34 // CImImap4Settings::SetPasswordL |
|
35 // CImImap4Settings::SetPort |
|
36 // CImImap4Settings::SetSecureSockets |
|
37 // CImImap4Settings::SetVersion |
|
38 // CImImap4Settings::SetFolderPathL |
|
39 // CImImap4Settings::SetPathSeparator |
|
40 // CImImap4Settings::SetMaxEmailSize |
|
41 // CImImap4Settings::SetGetMailOptions |
|
42 // CImImap4Settings::SetInboxSynchronisationLimit |
|
43 // CImImap4Settings::SetMailboxSynchronisationLimit |
|
44 // CImSmtpSettings::SetServerAddressL |
|
45 // CImSmtpSettings::SetEmailAddressL |
|
46 // CImSmtpSettings::SetBodyEncoding |
|
47 // CImSmtpSettings::SetReceiptAddressL |
|
48 // CImSmtpSettings::SetRequestReceipts |
|
49 // CImSmtpSettings::SetSendMessageOption |
|
50 // CImSmtpSettings::SetPort |
|
51 // CImSmtpSettings::SetEmailAliasL |
|
52 // CImSmtpSettings::SetBodyEncoding |
|
53 // CImSmtpSettings::SetDefaultMsgCharSet |
|
54 // CImSmtpSettings::SetUserAddress |
|
55 // CImSmtpSettings::SetVersion |
|
56 // CImIAPPreferences::Version |
|
57 // CImIAPPreferences::AddIAPL |
|
58 // __ACTION_INFO_END__ |
|
59 // |
|
60 // |
|
61 |
|
62 |
|
63 |
|
64 #include <imapset.h> |
|
65 #include <smtpset.h> |
|
66 |
|
67 #include <cemailaccounts.h> |
|
68 |
|
69 #include <iapprefs.h> |
|
70 |
|
71 #include "CMtfTestCase.h" |
|
72 #include "CMtfTestActionParameters.h" |
|
73 #include "CMtfTestActionUtilsImapScripts.h" |
|
74 #include "CMtfTestActionCreateImapAccount.h" |
|
75 |
|
76 /** |
|
77 Function : NewL |
|
78 Description : |
|
79 @internalTechnology |
|
80 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
81 @param : aActionParams - CMtfTestActionParameters |
|
82 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionCreateImapAccount object |
|
83 @pre none |
|
84 @post none |
|
85 */ |
|
86 CMtfTestAction* CMtfTestActionCreateImapAccount::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
87 { |
|
88 CMtfTestActionCreateImapAccount* self = new (ELeave) CMtfTestActionCreateImapAccount(aTestCase); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(aActionParameters); |
|
91 CleanupStack::Pop(self); |
|
92 return self; |
|
93 } |
|
94 |
|
95 /** |
|
96 Function : CMtfTestActionCreateImapAccount |
|
97 Description : Constructor |
|
98 @internalTechnology |
|
99 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
100 @return : N/A |
|
101 @pre none |
|
102 @post none |
|
103 */ |
|
104 CMtfTestActionCreateImapAccount::CMtfTestActionCreateImapAccount(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
105 { |
|
106 } |
|
107 |
|
108 /** |
|
109 Function : ~CMtfTestActionCreateImapAccount |
|
110 Description : Destructor |
|
111 @internalTechnology |
|
112 @param : |
|
113 @return : |
|
114 @pre |
|
115 @post |
|
116 */ |
|
117 CMtfTestActionCreateImapAccount::~CMtfTestActionCreateImapAccount() |
|
118 { |
|
119 } |
|
120 |
|
121 /** |
|
122 Function : ExecuteActionL |
|
123 Description : Entry point for the this test action in the test framework |
|
124 @internalTechnology |
|
125 @param : none |
|
126 @return : void |
|
127 @pre none |
|
128 @post none |
|
129 */ |
|
130 void CMtfTestActionCreateImapAccount::ExecuteActionL() |
|
131 { |
|
132 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateImapAccount); |
|
133 HBufC* paramAccountName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0) ); |
|
134 HBufC* settingsFile = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(1) ); |
|
135 |
|
136 // create the objects neccesary for creating IMAP settings in central repository |
|
137 CEmailAccounts *emailAccounts = CEmailAccounts::NewLC(); |
|
138 |
|
139 CImImap4Settings* imapSet = new(ELeave) CImImap4Settings(); |
|
140 CleanupStack::PushL(imapSet); |
|
141 CImIAPPreferences* imapIapPref = CImIAPPreferences::NewLC(); |
|
142 CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings(); |
|
143 CleanupStack::PushL(smtpSet); |
|
144 CImIAPPreferences* smtpIapPref = CImIAPPreferences::NewLC(); |
|
145 |
|
146 emailAccounts->PopulateDefaultImapSettingsL(*imapSet, *imapIapPref); |
|
147 emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSet, *smtpIapPref); |
|
148 |
|
149 if( settingsFile->CompareF( _L("none") ) != 0 ) |
|
150 { |
|
151 CMtfTestActionUtilsImapScripts::ReadImapSettingsFromConfigurationFileL( |
|
152 TestCase(), settingsFile->Des(), *imapSet, *imapIapPref, *smtpSet, *smtpIapPref); |
|
153 } |
|
154 |
|
155 //Store settings for later comparison |
|
156 StoreParameterL<CImImap4Settings>(TestCase(), *imapSet , ActionParameters().Parameter(3) ); |
|
157 StoreParameterL<CImIAPPreferences>(TestCase(), *imapIapPref , ActionParameters().Parameter(4) ); |
|
158 StoreParameterL<CImSmtpSettings>(TestCase(), *smtpSet , ActionParameters().Parameter(5) ); |
|
159 StoreParameterL<CImIAPPreferences>(TestCase(), *smtpIapPref , ActionParameters().Parameter(6) ); |
|
160 |
|
161 TImapAccount imapAccount = emailAccounts->CreateImapAccountL(*paramAccountName, *imapSet, *imapIapPref, EFalse); |
|
162 TSmtpAccount smtpAccount = emailAccounts->CreateSmtpAccountL(imapAccount, *smtpSet, *smtpIapPref, EFalse); |
|
163 emailAccounts->SetDefaultSmtpAccountL(smtpAccount); |
|
164 |
|
165 StoreParameterL<TImapAccount>(TestCase(), imapAccount, ActionParameters().Parameter(2) ); |
|
166 |
|
167 CleanupStack::Pop(4, imapSet); // smtpIapPref, smtpSet, imapIapPref, imapSet |
|
168 CleanupStack::PopAndDestroy(emailAccounts); |
|
169 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateImapAccount); |
|
170 TestCase().ActionCompletedL(*this); |
|
171 } |
|
172 |
|
173 |