719
|
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
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
719
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
719
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// [TestStep Name]
|
|
15 |
// SmtpSendEmail
|
|
16 |
// [Parameters]
|
|
17 |
// sender : User name of email sender
|
|
18 |
// recipient : User name of email recipient
|
|
19 |
// mailFile : Path of the meta data file to check
|
|
20 |
// serverIP : IP address of SMTP server
|
|
21 |
// This test step will send an email from <sender> to <recipient> with the contents
|
|
22 |
// of <mailfile> as message body using the SMTP server specified by <serverIP>.
|
|
23 |
// [APIs Used]
|
|
24 |
// RFile::Open
|
|
25 |
// RFile::Read
|
|
26 |
// CImTextServerSession::QueueConnectL
|
|
27 |
// CImTextServerSession::Send
|
|
28 |
// CImTextServerSession::QueueReceiveNextTextLine
|
|
29 |
// CImTextServerSession::GetCurrentTextLine
|
|
30 |
// CImTextServerSession::Disconnect
|
|
31 |
// CImIAPPreferences::NewLC
|
|
32 |
//
|
|
33 |
//
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
@file
|
|
39 |
*/
|
|
40 |
|
|
41 |
|
|
42 |
//User includes
|
|
43 |
#include <t_utilsconfigfilemachinename.h>
|
|
44 |
#include "T_UtilsSendEmail.h"
|
|
45 |
#include "T_SmtpSendEmail.h"
|
|
46 |
|
|
47 |
|
|
48 |
// Literals Used
|
|
49 |
_LIT(KSender,"Sender");
|
|
50 |
_LIT(KRecipient,"Recipient");
|
|
51 |
_LIT(KMailFile,"MailFile");
|
|
52 |
_LIT(KServerIP,"ServerIP");
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
CT_MsgSmtpSendEmail()
|
|
57 |
Constructor
|
|
58 |
|
|
59 |
@param aSharedDataSMTP
|
|
60 |
*/
|
|
61 |
CT_MsgSmtpSendEmail::CT_MsgSmtpSendEmail(CT_MsgSharedDataSmtp& aSharedDataSMTP)
|
|
62 |
: CT_MsgAsyncStepSMTP(aSharedDataSMTP)
|
|
63 |
{
|
|
64 |
SetTestStepName(KSmtpSendEmail);
|
|
65 |
}
|
|
66 |
|
|
67 |
/**
|
|
68 |
NewL()
|
|
69 |
Static factory constructor. Uses two phase
|
|
70 |
construction.
|
|
71 |
|
|
72 |
@param aSharedDataSMTP
|
|
73 |
@leave KErrNoMemory
|
|
74 |
@return
|
|
75 |
A pointer to the newly created CT_MsgSendSmtpMessage object.
|
|
76 |
*/
|
|
77 |
CT_MsgSmtpSendEmail* CT_MsgSmtpSendEmail::NewL(CT_MsgSharedDataSmtp& aSharedDataSMTP)
|
|
78 |
{
|
|
79 |
CT_MsgSmtpSendEmail* self = new(ELeave) CT_MsgSmtpSendEmail(aSharedDataSMTP);
|
|
80 |
CleanupStack::PushL(self);
|
|
81 |
self->ConstructL(); // Call CT_AsyncStep::ConstructL()
|
|
82 |
CleanupStack::Pop(self);
|
|
83 |
return self;
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
/**
|
|
88 |
~CT_MsgSmtpSendEmail()
|
|
89 |
Destructor
|
|
90 |
*/
|
|
91 |
CT_MsgSmtpSendEmail::~CT_MsgSmtpSendEmail()
|
|
92 |
{
|
|
93 |
if(iSendEmail!=NULL)
|
|
94 |
{
|
|
95 |
delete iSendEmail;
|
|
96 |
iSendEmail = NULL;
|
|
97 |
}
|
|
98 |
|
|
99 |
if(iMachineNameFile!=NULL)
|
|
100 |
{
|
|
101 |
delete iMachineNameFile;
|
|
102 |
iMachineNameFile = NULL;
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
/**
|
|
108 |
ProgressL()
|
|
109 |
|
|
110 |
*/
|
|
111 |
void CT_MsgSmtpSendEmail::ProgressL(TBool bFinal)
|
|
112 |
{
|
|
113 |
// TODO
|
|
114 |
if ( bFinal )
|
|
115 |
{
|
|
116 |
// Display final progress iSendEmail
|
|
117 |
}
|
|
118 |
else
|
|
119 |
{
|
|
120 |
// Display current progress iSendEmail
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
CancelStep()
|
|
126 |
|
|
127 |
*/
|
|
128 |
void CT_MsgSmtpSendEmail::CancelStep()
|
|
129 |
{
|
|
130 |
// TODO cancel iSendEmail
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
/**
|
|
135 |
doTestStepL()
|
|
136 |
Reads the parent folder name, the message subject from the ini file
|
|
137 |
Searches for the message under the specified folder, and sends the message
|
|
138 |
|
|
139 |
@return
|
|
140 |
Returns the test step result
|
|
141 |
*/
|
|
142 |
TVerdict CT_MsgSmtpSendEmail::doTestStepL()
|
|
143 |
{
|
|
144 |
INFO_PRINTF1( _L("Test Step : Smtp Send Email") );
|
|
145 |
TPtrC8 string8Ptr;
|
|
146 |
TPtrC stringPtr = KNone();
|
|
147 |
// Gets the machine name of the system
|
|
148 |
if(iMachineNameFile==NULL)
|
|
149 |
{
|
|
150 |
iMachineNameFile = CT_MsgUtilsConfigFileMachineName::NewL(stringPtr);
|
|
151 |
}
|
|
152 |
|
|
153 |
TPtrC8 machineName(iMachineNameFile->MachineName());
|
|
154 |
|
|
155 |
// Read the username of the email sender from the ini file
|
|
156 |
TPtrC sender;
|
|
157 |
if(!GetStringFromConfig( ConfigSection(), KSender, sender))
|
|
158 |
{
|
|
159 |
ERR_PRINTF1(_L("Sender is not specified"));
|
|
160 |
SetTestStepResult(EFail);
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
// Read the username of the email recipient from the ini file
|
|
165 |
TPtrC recipient;
|
|
166 |
if( !GetStringFromConfig(ConfigSection(),KRecipient,recipient ))
|
|
167 |
{
|
|
168 |
ERR_PRINTF1(_L("Recipient is not specified"));
|
|
169 |
SetTestStepResult(EFail);
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
// Read the path of the mailfile from the ini file
|
|
174 |
TPtrC mailFile;
|
|
175 |
if( !GetStringFromConfig(ConfigSection(),KMailFile,mailFile ))
|
|
176 |
{
|
|
177 |
ERR_PRINTF1(_L("MailFile is not specified"));
|
|
178 |
SetTestStepResult(EFail);
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
// Read the server IP address from the ini file
|
|
183 |
TPtrC serverIP;
|
|
184 |
if( !GetStringFromConfig(ConfigSection(),KServerIP,serverIP ))
|
|
185 |
{
|
|
186 |
ERR_PRINTF1(_L("ServerIP is not specified"));
|
|
187 |
SetTestStepResult(EFail);
|
|
188 |
}
|
|
189 |
else
|
|
190 |
{
|
|
191 |
if(iSendEmail==NULL)
|
|
192 |
{
|
|
193 |
iSendEmail = CT_MsgUtilsSendEmail::NewL(*this);
|
|
194 |
}
|
|
195 |
|
|
196 |
CT_MsgActive& active=Active();
|
|
197 |
iSendEmail->StartL(sender,recipient,mailFile,serverIP, active.iStatus);
|
|
198 |
active.Activate();
|
|
199 |
CActiveScheduler::Start();
|
|
200 |
User::LeaveIfError(active.Result());
|
|
201 |
}
|
|
202 |
}
|
|
203 |
}
|
|
204 |
}
|
|
205 |
|
|
206 |
return TestStepResult();
|
|
207 |
}
|