|
1 // Copyright (c) 2003-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 // SetImap4ServiceParameters |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // ServiceId <input>: Value of the Imap4 service id. |
|
20 // (ConfigIndexSettingsFile) <input>: Value of config index for settings file. Default is 0. |
|
21 // [Action Description] |
|
22 // Sets parameters of Imap4 service. |
|
23 // [APIs Used] |
|
24 // CMsvEntry::SetEntryL |
|
25 // CMsvEntry::EditStoreL |
|
26 // CImImap4Settings::Reset |
|
27 // CImImap4Settings::SetServerAddressL |
|
28 // CImImap4Settings::SetLoginNameL |
|
29 // CImImap4Settings::SetPasswordL |
|
30 // CImImap4Settings::SetAutoSendOnConnect |
|
31 // CImImap4Settings::StoreL |
|
32 // CMsvStore::CommitL |
|
33 // __ACTION_INFO_END__ |
|
34 // |
|
35 // |
|
36 |
|
37 /** |
|
38 @file |
|
39 */ |
|
40 |
|
41 |
|
42 #include <cemailaccounts.h> |
|
43 |
|
44 #include <msvapi.h> |
|
45 #include <imapset.h> |
|
46 #include <iapprefs.h> |
|
47 |
|
48 #include "CMtfTestActionSetImap4ServiceParameters.h" |
|
49 #include "CMtfTestCase.h" |
|
50 #include "CMtfTestActionParameters.h" |
|
51 #include "CMtfConfigurationType.h" |
|
52 #include "CMtfTestActionUtilsImapScripts.h" |
|
53 #include "CMtfTestActionUtilsConfigFileMachineName.h" |
|
54 |
|
55 _LIT(KServerName, "ServerName"); |
|
56 _LIT(KEmailAddressExtension, "EmailAddressExtension"); |
|
57 _LIT(KLoginName, "LoginName"); |
|
58 _LIT(KPassword, "Password"); |
|
59 _LIT(KFolderPath, "FolderPath"); |
|
60 _LIT(KEmailDeleteFlag, "DeleteEmailWhenDisconnected"); |
|
61 _LIT(KAutoSendFlag, "AutoSendFlag"); |
|
62 _LIT(KImapSearchString,"ImapSearchString"); |
|
63 |
|
64 CMtfTestAction* CMtfTestActionSetImap4ServiceParameters::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
65 { |
|
66 CMtfTestActionSetImap4ServiceParameters* self = new (ELeave) CMtfTestActionSetImap4ServiceParameters(aTestCase); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(aActionParameters); |
|
69 CleanupStack::Pop(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 CMtfTestActionSetImap4ServiceParameters::CMtfTestActionSetImap4ServiceParameters(CMtfTestCase& aTestCase) |
|
75 : CMtfSynchronousTestAction(aTestCase) |
|
76 { |
|
77 } |
|
78 |
|
79 |
|
80 CMtfTestActionSetImap4ServiceParameters::~CMtfTestActionSetImap4ServiceParameters() |
|
81 { |
|
82 delete iParser; |
|
83 } |
|
84 |
|
85 |
|
86 |
|
87 void CMtfTestActionSetImap4ServiceParameters::ExecuteActionL() |
|
88 { |
|
89 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetImap4ServiceParameters); |
|
90 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
91 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
92 TInt paramConfigIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2),0); |
|
93 |
|
94 CImImap4Settings* settings = new(ELeave) CImImap4Settings(); |
|
95 CleanupStack::PushL(settings); |
|
96 TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfImap4Settings,paramConfigIndex); |
|
97 iParser = CMtfTestActionUtilsConfigFileParser::NewL(fileName); |
|
98 |
|
99 settings->Reset(); |
|
100 |
|
101 TPtrC serverName; |
|
102 User::LeaveIfError(iParser->GetFieldAsString(KServerName,serverName)); |
|
103 settings->SetServerAddressL(serverName); |
|
104 |
|
105 CMtfTestActionUtilsConfigFileMachineName* machineNameFile = NULL; |
|
106 |
|
107 TPtrC emailAddressExtension; |
|
108 if (iParser->GetFieldAsString(KEmailAddressExtension, emailAddressExtension) == KErrNone) |
|
109 { |
|
110 machineNameFile = CMtfTestActionUtilsConfigFileMachineName::NewLC(emailAddressExtension); |
|
111 } |
|
112 else |
|
113 { |
|
114 machineNameFile = CMtfTestActionUtilsConfigFileMachineName::NewLC(serverName); |
|
115 } |
|
116 |
|
117 TPtrC8 machineName(machineNameFile->MachineName()); |
|
118 |
|
119 TPtrC8 loginName; |
|
120 if(iParser->GetFieldAsString8(KLoginName,loginName)==KErrNone) |
|
121 { |
|
122 settings->SetLoginNameL(loginName); |
|
123 } |
|
124 else |
|
125 { |
|
126 settings->SetLoginNameL(machineName); |
|
127 } |
|
128 |
|
129 TPtrC8 password; |
|
130 if(iParser->GetFieldAsString8(KPassword,password)==KErrNone) |
|
131 { |
|
132 settings->SetPasswordL(password); |
|
133 } |
|
134 else |
|
135 { |
|
136 settings->SetPasswordL(machineName); |
|
137 } |
|
138 |
|
139 TPtrC8 folderPath; |
|
140 TInt err = iParser->GetFieldAsString8(KFolderPath,folderPath); |
|
141 if (err == KErrNone) |
|
142 settings->SetFolderPathL(folderPath); |
|
143 |
|
144 TPtrC8 imapSearchString; |
|
145 err = iParser->GetFieldAsString8(KImapSearchString,imapSearchString); |
|
146 if (err == KErrNone) |
|
147 settings->SetSearchStringL(imapSearchString); |
|
148 |
|
149 TInt emailDeleteFlag; |
|
150 err = iParser->GetFieldAsInteger(KEmailDeleteFlag,emailDeleteFlag); |
|
151 if (err == KErrNone) |
|
152 settings->SetDeleteEmailsWhenDisconnecting(emailDeleteFlag); |
|
153 |
|
154 TInt autoSendFlag; |
|
155 err = iParser->GetFieldAsInteger(KAutoSendFlag,autoSendFlag); |
|
156 if (err == KErrNone) |
|
157 settings->SetAutoSendOnConnect(autoSendFlag); |
|
158 |
|
159 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
160 TImapAccount imapAccount; |
|
161 accounts->GetImapAccountL(paramServiceId, imapAccount); |
|
162 accounts->SaveImapSettingsL(imapAccount, *settings); |
|
163 //Pop and destroy settings, machineNameFile and accounts |
|
164 CleanupStack::PopAndDestroy(3, settings); |
|
165 |
|
166 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetImap4ServiceParameters); |
|
167 |
|
168 TestCase().ActionCompletedL(*this); |
|
169 } |
|
170 |