|
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 // ConnectPop3Server |
|
16 // [Paramaters] |
|
17 // PopAccountName <input> : Name of the Pop account |
|
18 // Connects to the Pop3 Server |
|
19 // [APIs Used] |
|
20 // CMsvEntry::SetEntryL |
|
21 // CMsvEntrySelection::AppendL |
|
22 // CPop3ClientMtm::InvokeAsyncFunctionL |
|
23 // |
|
24 // |
|
25 |
|
26 |
|
27 |
|
28 /** |
|
29 @file |
|
30 */ |
|
31 |
|
32 // User Includes |
|
33 #include "T_ConnectPop3Server.h" |
|
34 #include <t_utilscentralrepository.h> |
|
35 |
|
36 |
|
37 // Epoc includes |
|
38 #include <miutset.h> |
|
39 #include <pop3cmds.h> |
|
40 #include <mtclbase.h> |
|
41 #include <pop3set.h> |
|
42 |
|
43 // Literals Used |
|
44 _LIT(KPopAccountName,"PopAccountName"); |
|
45 |
|
46 const TInt KMaxLenghtOfChar = 1; |
|
47 |
|
48 /** |
|
49 CT_MsgConnectPop3Server() |
|
50 Sets the teststep name to KConnectPop3Server |
|
51 |
|
52 @param aSharedDataPOP |
|
53 Data shared across the POP test steps. Ex. Session |
|
54 */ |
|
55 CT_MsgConnectPop3Server::CT_MsgConnectPop3Server(CT_MsgSharedDataPop& aSharedDataPOP) |
|
56 : CT_MsgAsyncStepPOP(aSharedDataPOP) |
|
57 , iOperation(NULL) |
|
58 { |
|
59 SetTestStepName(KConnectPop3Server); |
|
60 } |
|
61 |
|
62 /** |
|
63 NewL() |
|
64 Allocates and creates a new CT_MsgConnectPop3Server object |
|
65 |
|
66 @param aSharedDataPOP |
|
67 Data shared across the POP test steps. Ex. Session |
|
68 |
|
69 @leave KErrNoMemory |
|
70 @return |
|
71 Returns pointer to an object of CT_MsgComparePopEmailMsgs |
|
72 */ |
|
73 CT_MsgConnectPop3Server* CT_MsgConnectPop3Server::NewL(CT_MsgSharedDataPop& aSharedDataPOP) |
|
74 { |
|
75 CT_MsgConnectPop3Server* self = new(ELeave) CT_MsgConnectPop3Server(aSharedDataPOP); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); // Call CT_AsyncStep::ConstructL() |
|
78 CleanupStack::Pop(self); |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 ~CT_MsgConnectPop3Server() |
|
85 Destructor |
|
86 */ |
|
87 CT_MsgConnectPop3Server::~CT_MsgConnectPop3Server() |
|
88 { |
|
89 delete iOperation; |
|
90 iOperation=NULL; |
|
91 } |
|
92 |
|
93 |
|
94 /** |
|
95 ProgressL() |
|
96 |
|
97 @param |
|
98 */ |
|
99 void CT_MsgConnectPop3Server::ProgressL(TBool bFinal) |
|
100 { |
|
101 // TODO |
|
102 if (bFinal) |
|
103 { |
|
104 // Display final progress iOperation |
|
105 } |
|
106 else |
|
107 { |
|
108 // Display current progress iOperation |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 /** |
|
114 CancelStep() |
|
115 |
|
116 @param |
|
117 */ |
|
118 void CT_MsgConnectPop3Server::CancelStep() |
|
119 { |
|
120 iOperation->Cancel(); |
|
121 } |
|
122 |
|
123 |
|
124 /** |
|
125 doTestStepL() |
|
126 It establishes connection with the Pop server using a POP account. |
|
127 The account is identified by the account name that is read from the INI file. |
|
128 |
|
129 @return |
|
130 Returns the test step result |
|
131 */ |
|
132 TVerdict CT_MsgConnectPop3Server::doTestStepL() |
|
133 { |
|
134 INFO_PRINTF1(_L(" Test Step : ConnectPop3Server")); |
|
135 TPtrC popAccountName; |
|
136 if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) |
|
137 { |
|
138 ERR_PRINTF1(_L("Pop Account Name is not specified")); |
|
139 SetTestStepResult(EFail); |
|
140 } |
|
141 |
|
142 else |
|
143 { |
|
144 // Retrieving the Pop service Id for the given Pop account |
|
145 TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); |
|
146 INFO_PRINTF2(_L("Pop service id is %d"),popServiceId); |
|
147 |
|
148 // Change the current context |
|
149 iSharedDataPOP.iMtm->SwitchCurrentEntryL(popServiceId); |
|
150 |
|
151 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
152 CleanupStack::PushL(selection); |
|
153 |
|
154 // Appends the popServiceId onto the end of the array |
|
155 selection->AppendL(popServiceId); |
|
156 |
|
157 TBuf8<KMaxLenghtOfChar> param; |
|
158 |
|
159 CT_MsgActive& active=Active(); |
|
160 // Attempts to connect to the Pop3 Service |
|
161 iOperation = iSharedDataPOP.iMtm->InvokeAsyncFunctionL(KPOP3MTMConnect,*selection,param, active.iStatus); |
|
162 |
|
163 active.Activate(); |
|
164 CActiveScheduler::Start(); |
|
165 |
|
166 // Get the error code from TPop3Progress |
|
167 TPop3Progress temp; |
|
168 TPckgC<TPop3Progress> paramPack(temp); |
|
169 paramPack.Set(iOperation->ProgressL()); |
|
170 TPop3Progress progress=paramPack(); |
|
171 SetTestStepError(progress.iErrorCode); |
|
172 |
|
173 delete iOperation; |
|
174 iOperation=NULL; |
|
175 |
|
176 CleanupStack::PopAndDestroy(selection); //operation,selection |
|
177 // User::LeaveIfError(active.Result()); |
|
178 } |
|
179 return TestStepResult(); |
|
180 } |