|
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 // SendSmtpMessage |
|
16 // [Parameters] |
|
17 // ParentFolderName : Local folder name in which the message to be sent is |
|
18 // present |
|
19 // Subject : Subject of the message to be sent |
|
20 // Searches for the message with the specified subject and sends the message if the |
|
21 // message is found. If the local folder name is invalid or if the message is |
|
22 // not found in the given folder,the test step fails. |
|
23 // [APIs Used] |
|
24 // CMsvEntry::SetEntryL |
|
25 // CMsvEntry::CopyL |
|
26 // |
|
27 // |
|
28 |
|
29 |
|
30 |
|
31 /** |
|
32 @file |
|
33 */ |
|
34 |
|
35 |
|
36 |
|
37 //User Includes |
|
38 #include "T_SendSmtpMessage.h" |
|
39 #include <t_utilsenumconverter.h> |
|
40 #include <t_utils.h> |
|
41 #include <t_utilscentralrepository.h> |
|
42 |
|
43 |
|
44 // Literals Used |
|
45 _LIT(KSubject,"Subject"); |
|
46 _LIT(KParentFolderName,"ParentFolderName"); |
|
47 |
|
48 |
|
49 /** |
|
50 CT_MsgSendSmtpMessage |
|
51 Constructor |
|
52 |
|
53 @param : |
|
54 @return : N/A |
|
55 |
|
56 |
|
57 */ |
|
58 CT_MsgSendSmtpMessage::CT_MsgSendSmtpMessage(CT_MsgSharedDataSmtp& aSharedDataSMTP) |
|
59 : CT_MsgAsyncStepSMTP(aSharedDataSMTP) |
|
60 , iOperation(NULL) |
|
61 { |
|
62 SetTestStepName(KSendSmtpMessage); |
|
63 } |
|
64 |
|
65 |
|
66 /** |
|
67 NewL() |
|
68 Static factory constructor. Uses two phase |
|
69 construction. |
|
70 |
|
71 @param aSharedDataSMTP |
|
72 @leave KErrNoMemory |
|
73 @return |
|
74 A pointer to the newly created CT_MsgSendSmtpMessage object. |
|
75 */ |
|
76 CT_MsgSendSmtpMessage* CT_MsgSendSmtpMessage::NewL(CT_MsgSharedDataSmtp& aSharedDataSMTP) |
|
77 { |
|
78 CT_MsgSendSmtpMessage* self = new(ELeave) CT_MsgSendSmtpMessage(aSharedDataSMTP); |
|
79 CleanupStack::PushL(self); |
|
80 self->ConstructL(); // Call CT_AsyncStep::ConstructL() |
|
81 CleanupStack::Pop(self); |
|
82 return self; |
|
83 } |
|
84 |
|
85 |
|
86 /** |
|
87 ~CT_MsgSendSmtpMessage() |
|
88 Destructor |
|
89 */ |
|
90 CT_MsgSendSmtpMessage::~CT_MsgSendSmtpMessage() |
|
91 { |
|
92 delete iOperation; |
|
93 iOperation=NULL; |
|
94 } |
|
95 |
|
96 |
|
97 /** |
|
98 ProgressL() |
|
99 |
|
100 @param bFinal |
|
101 */ |
|
102 void CT_MsgSendSmtpMessage::ProgressL(TBool bFinal) |
|
103 { |
|
104 // TODO |
|
105 if ( bFinal ) |
|
106 { |
|
107 // Display final progress iOperation |
|
108 } |
|
109 else |
|
110 { |
|
111 // Display current progress iOperation |
|
112 } |
|
113 } |
|
114 |
|
115 |
|
116 /** |
|
117 CancelStep() |
|
118 */ |
|
119 void CT_MsgSendSmtpMessage::CancelStep() |
|
120 { |
|
121 iOperation->Cancel(); |
|
122 } |
|
123 |
|
124 |
|
125 /** |
|
126 doTestStepL() |
|
127 Reads the parent folder name, the message subject from the ini file |
|
128 Searches for the message under the specified folder, and sends the message |
|
129 |
|
130 @return |
|
131 Returns the test step result |
|
132 */ |
|
133 TVerdict CT_MsgSendSmtpMessage::doTestStepL() |
|
134 { |
|
135 INFO_PRINTF1( _L("Test Step : Send Smtp Message") ); |
|
136 TPtrC parentFolderName; |
|
137 if(!GetStringFromConfig( ConfigSection(), KParentFolderName, parentFolderName)) |
|
138 { |
|
139 ERR_PRINTF1(_L("Parent Folder is not specified")); |
|
140 SetTestStepResult(EFail); |
|
141 } |
|
142 else |
|
143 { |
|
144 TPtrC subject; |
|
145 if( !GetStringFromConfig(ConfigSection(), KSubject, subject )) |
|
146 { |
|
147 ERR_PRINTF1(_L("The subject of the message is not specified")); |
|
148 SetTestStepResult(EFail); |
|
149 } |
|
150 else |
|
151 { |
|
152 // retrieves the folder Id based on the local folder name read from the ini file |
|
153 TMsvId parentFolderId = CT_MsgUtilsEnumConverter::FindFolderIdByName(parentFolderName); |
|
154 if( parentFolderId == KErrNotFound) |
|
155 { |
|
156 ERR_PRINTF1(_L("Invalid local folder name specified")); |
|
157 SetTestStepResult(EFail); |
|
158 } |
|
159 else |
|
160 { |
|
161 INFO_PRINTF2(_L("The parent folder Id is %d"),parentFolderId ); |
|
162 |
|
163 // Retrieves the message Id based ont he message subject from the given local folder |
|
164 TMsvId messageId = CT_MsgUtils::SearchMessageBySubjectL(iSharedDataSMTP.iSession, parentFolderId , subject); |
|
165 if( messageId == KMsvNullIndexEntryId) |
|
166 { |
|
167 ERR_PRINTF1(_L("The given message is not found")); |
|
168 SetTestStepResult(EFail); |
|
169 } |
|
170 // Message found |
|
171 else |
|
172 { |
|
173 INFO_PRINTF2(_L("The Message Id is %d"),messageId ); |
|
174 |
|
175 // Retrieve the default Smtp service Id |
|
176 TMsvId smtpServiceId(0); |
|
177 TRAPD(err, smtpServiceId = CT_MsgUtilsCentralRepository::GetDefaultSmtpServiceIdL()); |
|
178 if(err != KErrNone) |
|
179 { |
|
180 ERR_PRINTF2(_L("Failure while getting the default SMTP Service Id. error = %d"),err); |
|
181 SetTestStepResult(EFail); |
|
182 } |
|
183 else |
|
184 { |
|
185 INFO_PRINTF2(_L("The Default Smtp Service Id is %d"),smtpServiceId ); |
|
186 |
|
187 // Setting the current context to the parent of the mesage |
|
188 CMsvEntry* folderEntry = CMsvEntry::NewL(*iSharedDataSMTP.iSession, messageId , TMsvSelectionOrdering()); |
|
189 CleanupStack::PushL(folderEntry); |
|
190 folderEntry->SetEntryL(messageId); |
|
191 folderEntry->SetEntryL(folderEntry->Entry().Parent()); |
|
192 |
|
193 // Sends the message |
|
194 CT_MsgActive& active=Active(); |
|
195 iOperation = folderEntry->CopyL(messageId, smtpServiceId, active.iStatus); |
|
196 active.Activate(); |
|
197 CActiveScheduler::Start(); |
|
198 |
|
199 TImSmtpProgress temp; |
|
200 TPckgC<TImSmtpProgress> paramPack(temp); |
|
201 paramPack.Set(iOperation->ProgressL()); |
|
202 TImSmtpProgress progress=paramPack(); |
|
203 SetTestStepError(progress.Error()); |
|
204 |
|
205 if (NULL!=iOperation) |
|
206 { |
|
207 delete iOperation; |
|
208 iOperation=NULL; |
|
209 } |
|
210 CleanupStack::PopAndDestroy(folderEntry); //operation,folderEntry |
|
211 } |
|
212 } |
|
213 } |
|
214 } |
|
215 } |
|
216 |
|
217 return TestStepResult(); |
|
218 } |