0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: SendSm specific test class. Inherits CCommandBase.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <stifparser.h>
|
|
22 |
#include "commandsendsm.h"
|
|
23 |
|
|
24 |
// CONSTANTS
|
|
25 |
_LIT( KSmsTpdu, "SmsTpdu" );
|
|
26 |
_LIT( KSmsResult, "SmsResult" );
|
|
27 |
|
|
28 |
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
// CCommandSendSm::CommandSendSm
|
|
31 |
// C++ default constructor can NOT contain any code, that
|
|
32 |
// might leave.
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CCommandSendSm::CCommandSendSm
|
|
36 |
(
|
|
37 |
const TSatIpc aIpc,
|
|
38 |
const RSat& aSat,
|
|
39 |
CStifItemParser& aParser,
|
|
40 |
CStifLogger& aLog
|
|
41 |
) : CSatCommandBase ( aIpc, aSat, aParser, aLog, RSat::ESendSm ),
|
|
42 |
iDataPckg( iData ),
|
|
43 |
iRspPckg( iRsp )
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
// CCommandSendSm::~CCommandSendSm
|
|
49 |
// Destructor
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CCommandSendSm::~CCommandSendSm()
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CCommandSendSm::NotifySat
|
|
58 |
// Send a notify request to Etel and clear internal data
|
|
59 |
// (other items were commented in a header).
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
TInt CCommandSendSm::NotifySat
|
|
63 |
(
|
|
64 |
TRequestStatus& aSimAtkStatus
|
|
65 |
)
|
|
66 |
{
|
|
67 |
TInt ret ( KErrNone );
|
|
68 |
|
|
69 |
// Clear the package
|
|
70 |
Init( iData );
|
|
71 |
Init( iRsp );
|
|
72 |
|
|
73 |
iSat.NotifySendSmPCmd( aSimAtkStatus, iDataPckg );
|
|
74 |
|
|
75 |
return ret;
|
|
76 |
}
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CCommandSendSm::CheckData
|
|
80 |
// Verifies the validity of received command
|
|
81 |
// (other items were commented in a header).
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
TInt CCommandSendSm::CheckData()
|
|
85 |
{
|
|
86 |
iLog.Log( _L( "CCommandSendSm::CheckData" ) );
|
|
87 |
|
|
88 |
TInt ret( KErrNone );
|
|
89 |
|
|
90 |
switch( CheckBuffer( KSmsTpdu, iData.iSmsTpdu ) )
|
|
91 |
{
|
|
92 |
case KErrCorrupt:
|
|
93 |
{
|
|
94 |
iLog.Log( _L( "CCommandSendSm::CheckData: ERROR \
|
|
95 |
Parameter SmsTpdu did not match!" ) );
|
|
96 |
ret = KErrCorrupt;
|
|
97 |
break;
|
|
98 |
}
|
|
99 |
case KErrArgument:
|
|
100 |
{
|
|
101 |
iLog.Log( _L( "CCommandSendSm::CheckData: ERROR \
|
|
102 |
Mandatory parameter SmsTpdu missing" ) );
|
|
103 |
ret = KErrArgument;
|
|
104 |
break;
|
|
105 |
}
|
|
106 |
case KErrNone:
|
|
107 |
default:
|
|
108 |
{
|
|
109 |
// None
|
|
110 |
break;
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
// AlphaId
|
|
115 |
if ( KErrCorrupt == CheckAlphaId( iData.iAlphaId ) )
|
|
116 |
{
|
|
117 |
ret = KErrCorrupt;
|
|
118 |
}
|
|
119 |
|
|
120 |
// Icon
|
|
121 |
if ( KErrNone != CheckIcon( iData.iIconId ) )
|
|
122 |
{
|
|
123 |
ret = KErrCorrupt;
|
|
124 |
}
|
|
125 |
|
|
126 |
// Smsc address
|
|
127 |
if ( 0 < iData.iAddress.iTelNumber.Length() )
|
|
128 |
{
|
|
129 |
// Smsc provided by proactive command. Compare against scripted
|
|
130 |
// values
|
|
131 |
switch ( CheckAddress( iData.iAddress ) )
|
|
132 |
{
|
|
133 |
case KErrNotFound:
|
|
134 |
{
|
|
135 |
ret = KErrNotFound;
|
|
136 |
break;
|
|
137 |
}
|
|
138 |
case KErrCorrupt:
|
|
139 |
{
|
|
140 |
ret = KErrCorrupt;
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
case KErrNone:
|
|
144 |
default:
|
|
145 |
{
|
|
146 |
// None
|
|
147 |
break;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
}
|
|
151 |
else
|
|
152 |
{
|
|
153 |
// Proactive command did not provide SMSC address. Scripted SMSC
|
|
154 |
// is used as a default SMSC.
|
|
155 |
if ( KErrNone != GetAddress( iData.iAddress ) )
|
|
156 |
{
|
|
157 |
iLog.Log( _L( "CCommandSendSm::CheckData: ERROR \
|
|
158 |
Mandatory parameter default SMSC missing!" ) );
|
|
159 |
ret = KErrArgument;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// SendSmNoLogging
|
|
164 |
if ( KErrNone == ret )
|
|
165 |
{
|
|
166 |
iLog.Log( _L("CCommandSendSm::CheckData, starting to send an SMS" ) );
|
|
167 |
RSat::TSatSmsV1 satSm;
|
|
168 |
RSat::TSatSmsV1Pckg satSmPckg( satSm );
|
|
169 |
|
|
170 |
satSm.iBuf = iData.iSmsTpdu;
|
|
171 |
satSm.iServiceCenter = iData.iAddress;
|
|
172 |
TRequestStatus satSmStatus;
|
|
173 |
TUint16 satSmRef( 0x00 ); // Not used anywhere
|
|
174 |
|
|
175 |
iSat.SendMessageNoLogging( satSmStatus, satSmPckg, satSmRef );
|
|
176 |
|
|
177 |
User::WaitForRequest( satSmStatus );
|
|
178 |
|
|
179 |
ret = satSmStatus.Int();
|
|
180 |
|
|
181 |
TInt expectedResult( KErrNone ); //Default if SmsResult is not given
|
|
182 |
|
|
183 |
if ( KErrNone == GetValue( KSmsResult, expectedResult ) )
|
|
184 |
{
|
|
185 |
// Compare scripted and actual result
|
|
186 |
ret == expectedResult ? ret = KErrNone : ret = ret ;
|
|
187 |
}
|
|
188 |
if ( KErrNone != ret )
|
|
189 |
{
|
|
190 |
iLog.Log( _L("CCommandSendSm::CheckData: SMS sending failed \
|
|
191 |
with error code: %d"), ret ) ;
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
iLog.Log(_L("CCommandSendSm::CheckData: SMS sending succseed \
|
|
196 |
Expected vs. received result: OK ") );
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
return ret;
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// CCommandSendSm::SendResponse
|
|
205 |
// Creates terminal response according to scripted parameters
|
|
206 |
// (other items were commented in a header).
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
//
|
|
209 |
TInt CCommandSendSm::SendResponse()
|
|
210 |
{
|
|
211 |
iLog.Log( _L( "CCommandSendSm::SendResponse" ) );
|
|
212 |
|
|
213 |
TInt ret( KErrNone );
|
|
214 |
|
|
215 |
// General result
|
|
216 |
SetGeneralResult( iRsp.iGeneralResult );
|
|
217 |
|
|
218 |
// Additional info & type
|
|
219 |
SetAdditionalInfo( iRsp.iInfoType, iRsp.iAdditionalInfo );
|
|
220 |
|
|
221 |
if ( KErrNone == ret )
|
|
222 |
{
|
|
223 |
ret = CSatCommandBase::SendResponse( iRspPckg );
|
|
224 |
}
|
|
225 |
|
|
226 |
return ret;
|
|
227 |
}
|
|
228 |
|
|
229 |
// End of File
|