|
1 // Copyright (c) 2007-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 // CreatePopAccountWithoutSmtp |
|
16 // [Paramaters] |
|
17 // PopAccountName :Name of the Pop account. |
|
18 // PopConfigFileName :Config file from which the Pop account settings are read. |
|
19 // Creates a POP account in the Central Repository with the specified name using the |
|
20 // settings read from the config file. |
|
21 // |
|
22 // |
|
23 |
|
24 //User includes |
|
25 #include "T_CreatePopAccountWithoutSmtp.h" |
|
26 #include <t_utilsreademailsettingsfromconfigfile.h> |
|
27 |
|
28 //Epoc inlcudes |
|
29 #include <cemailaccounts.h> |
|
30 #include <iapprefs.h> |
|
31 #include <pop3set.h> |
|
32 |
|
33 //Literals used |
|
34 _LIT(KPopAccountName,"PopAccountName"); |
|
35 _LIT(KPopConfigFileName,"PopConfigFileName"); |
|
36 |
|
37 /** |
|
38 Function : CT_MsgCreatePopAccountWithoutSmtp |
|
39 Description : Constructor |
|
40 @param : aSharedDataPOP Reference to CT_MsgSharedDataPop |
|
41 @return : N/A |
|
42 */ |
|
43 CT_MsgCreatePopAccountWithoutSmtp::CT_MsgCreatePopAccountWithoutSmtp(CT_MsgSharedDataPop& aSharedDataPOP) |
|
44 :CT_MsgSyncStepPOP(aSharedDataPOP) |
|
45 { |
|
46 SetTestStepName(KCreatePopAccountWithoutSmtp); |
|
47 } |
|
48 |
|
49 /** |
|
50 Function : ReadIni |
|
51 Description :Reads the corresponding .ini file and returns EPass or EFail if any of the inputs are missing |
|
52 @return : TBool |
|
53 */ |
|
54 TBool CT_MsgCreatePopAccountWithoutSmtp::ReadIni() |
|
55 { |
|
56 TBool result = ETrue; |
|
57 |
|
58 if(!GetStringFromConfig(ConfigSection(), KPopAccountName, iPopAccountName)) |
|
59 { |
|
60 ERR_PRINTF1(_L("Pop account name is not specified")); |
|
61 SetTestStepResult(EFail); |
|
62 result = EFalse; |
|
63 } |
|
64 |
|
65 if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, iConfigFileName)) |
|
66 { |
|
67 ERR_PRINTF1(_L("Configuration file path is not specified")); |
|
68 SetTestStepResult(EFail); |
|
69 } |
|
70 |
|
71 return result; |
|
72 } |
|
73 |
|
74 /** |
|
75 Function : doTestStepL |
|
76 Description : Reads the Pop account name and the settings file name from the .ini file |
|
77 and then creates a Pop account. |
|
78 @return : TVerdict - Test step result |
|
79 */ |
|
80 TVerdict CT_MsgCreatePopAccountWithoutSmtp::doTestStepL() |
|
81 { |
|
82 |
|
83 INFO_PRINTF1(_L("Test Step : CreatePopAccountWithoutSmtp")); |
|
84 if(ReadIni()) |
|
85 { |
|
86 CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); |
|
87 |
|
88 // Creates objects requried for POP account |
|
89 CImIAPPreferences *popIapPreferences = CImIAPPreferences::NewLC(); |
|
90 CImPop3Settings *popSettings = new (ELeave) CImPop3Settings; |
|
91 CleanupStack::PushL(popSettings); |
|
92 |
|
93 // Populates the default POP settings |
|
94 emailAccounts->PopulateDefaultPopSettingsL(*popSettings, *popIapPreferences); |
|
95 |
|
96 //If the config file name is provided as input, then reads the POP settings from it |
|
97 if(iConfigFileName.CompareF( _L("none") ) != 0) |
|
98 { |
|
99 TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(iConfigFileName, *popSettings, *popIapPreferences)); |
|
100 if(err) |
|
101 { |
|
102 ERR_PRINTF2(_L("Failure while setting the POP settings, failed with error %d"), err); |
|
103 SetTestStepError(err); |
|
104 CleanupStack::PopAndDestroy(3,emailAccounts); // popSettings, popIapPreferences, emailAccounts |
|
105 return TestStepResult(); |
|
106 } |
|
107 if(TestStepResult() == EPass) |
|
108 { |
|
109 // Creates the POP account for the name specified and for the settings objects |
|
110 TPopAccount popAccount = emailAccounts->CreatePopAccountL(iPopAccountName, *popSettings,*popIapPreferences,EFalse); |
|
111 } |
|
112 } |
|
113 CleanupStack::PopAndDestroy(3,emailAccounts); // popSettings, popIapPreferences, emailAccounts |
|
114 } |
|
115 return TestStepResult(); |
|
116 } |