|
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 // ModifyPopSettings2 |
|
16 // [Paramaters] |
|
17 // PopAccountName :Name of the Pop account |
|
18 // PopConfigFileName :Config file from which the Pop account settings are read |
|
19 // ModifyPopSettings2 Test Step is intended to modify existing settings and save to CenRep |
|
20 // for the specified POP account Id |
|
21 // |
|
22 // |
|
23 |
|
24 /* user includes */ |
|
25 #include "T_ModifyPopSettings2.h" |
|
26 #include <t_utilsreademailsettingsfromconfigfile.h> |
|
27 #include <t_utilscentralrepository.h> |
|
28 |
|
29 /* epoc inlcudes */ |
|
30 #include <cemailaccounts.h> |
|
31 #include <pop3set.h> |
|
32 #include <iapprefs.h> |
|
33 |
|
34 /* Literals used */ |
|
35 _LIT(KPopAccountName,"PopAccountName"); |
|
36 _LIT(KPopConfigFileName,"PopConfigFileName"); |
|
37 |
|
38 /** |
|
39 Function : CT_MsgModifyPopSettings2 |
|
40 Description : Constructor |
|
41 @param : aSharedDataPOP Reference to CT_MsgSharedDataPop |
|
42 @return : N/A |
|
43 */ |
|
44 CT_MsgModifyPopSettings2::CT_MsgModifyPopSettings2(CT_MsgSharedDataPop& aSharedDataPOP) |
|
45 : CT_MsgSyncStepPOP(aSharedDataPOP) |
|
46 { |
|
47 SetTestStepName(KModifyPopSettings2); |
|
48 } |
|
49 |
|
50 /** |
|
51 Function : ~CT_MsgModifyPopSettings2 |
|
52 Description : Destructor |
|
53 @return : N/A |
|
54 */ |
|
55 CT_MsgModifyPopSettings2::~CT_MsgModifyPopSettings2() |
|
56 { |
|
57 } |
|
58 |
|
59 /** |
|
60 Function : doTestStepL |
|
61 Description : Reads the Pop account name and config file name from the .ini file |
|
62 and it then modifies the account with the settings read from the config file. |
|
63 @return : TVerdict - Test step result |
|
64 @leave : KMsvNullIndexEntryId Invalid POP account name specified |
|
65 */ |
|
66 TVerdict CT_MsgModifyPopSettings2::doTestStepL() |
|
67 { |
|
68 INFO_PRINTF1(_L("Test Step: ModifyPopSettings2")); |
|
69 // Read the POP account name from the ini file |
|
70 TPtrC popAccountName; |
|
71 if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) |
|
72 { |
|
73 ERR_PRINTF1(_L("POP account name is not specified")); |
|
74 SetTestStepResult(EFail); |
|
75 } |
|
76 else |
|
77 { |
|
78 // Read the POP Config file name from the ini file |
|
79 TPtrC configFileName; |
|
80 if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, configFileName)) |
|
81 { |
|
82 ERR_PRINTF1(_L("Configuration file path is not specified")); |
|
83 SetTestStepResult(EFail); |
|
84 } |
|
85 else |
|
86 { |
|
87 // Retrieving the POP service Id for the given POP account |
|
88 TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); |
|
89 INFO_PRINTF2(_L("POP service Id is %d"),popServiceId); |
|
90 |
|
91 if(popServiceId == KMsvNullIndexEntryId) |
|
92 { |
|
93 ERR_PRINTF1(_L("Invalid POP account name specified")); |
|
94 SetTestStepResult(EFail); |
|
95 } |
|
96 // Creates the settings object |
|
97 else |
|
98 { |
|
99 CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); |
|
100 |
|
101 CImPop3Settings* popSettings = new(ELeave) CImPop3Settings(); |
|
102 CleanupStack::PushL(popSettings); |
|
103 |
|
104 CImIAPPreferences* popIapPrefs = CImIAPPreferences::NewLC(); |
|
105 |
|
106 // Loads the settings for the account with the current settings |
|
107 TPopAccount popAccount; |
|
108 emailAccounts->GetPopAccountL(popServiceId, popAccount); |
|
109 emailAccounts->LoadPopSettingsL(popAccount, *popSettings); |
|
110 emailAccounts->LoadPopIapSettingsL(popAccount, *popIapPrefs); |
|
111 |
|
112 // Reads the settings from the config file |
|
113 TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings, *popIapPrefs)); |
|
114 if(err) |
|
115 { |
|
116 ERR_PRINTF2(_L("Failure while setting the POP setting parameters, failed with error %d"), err); |
|
117 SetTestStepError(err); |
|
118 } |
|
119 else |
|
120 { |
|
121 // Saves the new settings |
|
122 emailAccounts->SavePopSettingsL(popAccount, *popSettings); |
|
123 emailAccounts->SavePopIapSettingsL(popAccount, *popIapPrefs); |
|
124 } |
|
125 CleanupStack::PopAndDestroy(3, emailAccounts);// popIapPrefs,popSettings,emailAccounts |
|
126 } |
|
127 } |
|
128 } |
|
129 return TestStepResult(); |
|
130 } |