|
1 /* |
|
2 * Copyright (c) 2009 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ut_testenv.h" |
|
20 #include <etel.h> |
|
21 #include <etelmm.h> |
|
22 #include <etelmmcs.h> |
|
23 #include <QTest> |
|
24 |
|
25 |
|
26 // global variables |
|
27 CPeriodic* messageResponseTimer = 0; |
|
28 |
|
29 // ============================================================================== |
|
30 // RMobileUssdMessaging |
|
31 // ============================================================================== |
|
32 |
|
33 RMobileUssdMessaging::RMobileUssdMessaging() |
|
34 { |
|
35 } |
|
36 |
|
37 RMobileUssdMessaging::RMobileUssdMessaging(const RMobileUssdMessaging&) |
|
38 { |
|
39 } |
|
40 |
|
41 void RMobileUssdMessaging::ConstructL() |
|
42 { |
|
43 QVERIFY(!messageResponseTimer); |
|
44 messageResponseTimer = |
|
45 CPeriodic::NewL(CActive::EPriorityStandard+1); |
|
46 } |
|
47 |
|
48 TInt RMobileUssdMessaging::Open(RMobilePhone& /*aPhone*/) |
|
49 { |
|
50 TRAPD(err,ConstructL()); |
|
51 return err; |
|
52 } |
|
53 |
|
54 void RMobileUssdMessaging::Close() |
|
55 { |
|
56 delete messageResponseTimer; |
|
57 messageResponseTimer = 0; |
|
58 } |
|
59 |
|
60 void RMobileUssdMessaging::Destruct() |
|
61 { |
|
62 } |
|
63 |
|
64 TInt RMobileUssdMessaging::GetCaps(TDes8& aCaps) const |
|
65 { |
|
66 TMobileUssdCapsV1 caps; |
|
67 caps.iUssdFormat = KCapsPackedString; |
|
68 caps.iUssdTypes = KCapsMTUssd | KCapsMOUssd; |
|
69 TMobileUssdCapsV1Pckg pckgCaps( caps ); |
|
70 aCaps.Copy( pckgCaps ); |
|
71 return KErrNone; |
|
72 } |
|
73 |
|
74 void RMobileUssdMessaging::ReceiveMessage( |
|
75 TRequestStatus& aReqStatus, TDes8& aMsgData, |
|
76 TDes8& aMsgAttributes) const |
|
77 { |
|
78 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
79 QVERIFY2(!loop.mReceiveMessageReqStatus, |
|
80 "etel_mock: ReceiveMessage called twice!"); |
|
81 aReqStatus = KRequestPending; |
|
82 loop.mReceiveMessageReqStatus = &aReqStatus; |
|
83 loop.mReceiveMessageData = &aMsgData; |
|
84 loop.mReceiveMessageAttributes = &aMsgAttributes; |
|
85 } |
|
86 |
|
87 TInt SendMessageCallback(TAny* /*aPtr*/) |
|
88 { |
|
89 messageResponseTimer->Cancel(); |
|
90 |
|
91 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
92 const TestMode& mode = TestEnv::env().testMode(); |
|
93 if (mode.m_event == TestMode::Normal) |
|
94 { |
|
95 User::RequestComplete(loop.mSendMessageReqStatus, mode.m_error); |
|
96 } |
|
97 return 0; |
|
98 } |
|
99 |
|
100 void RMobileUssdMessaging::SendMessage( |
|
101 TRequestStatus& aReqStatus, const TDesC8& /*aMsgData*/, |
|
102 const TDesC8& /*aMsgAttributes*/) const |
|
103 { |
|
104 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
105 QVERIFY2(!loop.mSendMessageReqStatus, |
|
106 "etel_mock: SendMessage called twice!"); |
|
107 aReqStatus = KRequestPending; |
|
108 loop.mSendMessageReqStatus = &aReqStatus; |
|
109 |
|
110 const TestMode& mode = TestEnv::env().testMode(); |
|
111 if (mode.m_event != TestMode::NoResp) |
|
112 { |
|
113 // start timer to respond |
|
114 TTimeIntervalMicroSeconds32 delay( |
|
115 1000*mode.m_timeout); |
|
116 messageResponseTimer->Start(delay,delay, |
|
117 TCallBack(SendMessageCallback,(TAny*)this)); |
|
118 } |
|
119 } |
|
120 |
|
121 void RMobileUssdMessaging::SendMessageNoFdnCheck( |
|
122 TRequestStatus& /*aReqStatus*/, const TDesC8& /*aMsgData*/, |
|
123 const TDesC8& /*aMsgAttributes*/) const |
|
124 { |
|
125 // not used |
|
126 } |
|
127 |
|
128 void RMobileUssdMessaging::SendRelease( |
|
129 TRequestStatus& /*aReqStatus*/, TDes8& /*aReturnResult*/) const |
|
130 { |
|
131 // not used |
|
132 } |
|
133 |
|
134 void RMobileUssdMessaging::NotifyNetworkRelease( |
|
135 TRequestStatus& aReqStatus, TDes8& aReturnResult) const |
|
136 { |
|
137 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
138 QVERIFY2(!loop.mNetworkReleaseReqStatus, |
|
139 "etel_mock: NotifyNetworkRelease called twice!"); |
|
140 aReqStatus = KRequestPending; |
|
141 loop.mNetworkReleaseReqStatus = &aReqStatus; |
|
142 loop.mNetworkReleaseMessageData = &aReturnResult; |
|
143 loop.mNetworkReleaseMessageAttributes = 0; |
|
144 } |
|
145 |
|
146 void RMobileUssdMessaging::NotifyNetworkRelease( |
|
147 TRequestStatus& aReqStatus, TDes8& aMsgData, |
|
148 TDes8& aMsgAttributes) const |
|
149 { |
|
150 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
151 QVERIFY2(!loop.mNetworkReleaseReqStatus, |
|
152 "etel_mock: NotifyNetworkRelease called twice!"); |
|
153 aReqStatus = KRequestPending; |
|
154 loop.mNetworkReleaseReqStatus = &aReqStatus; |
|
155 loop.mNetworkReleaseMessageData = &aMsgData; |
|
156 loop.mNetworkReleaseMessageAttributes = &aMsgAttributes; |
|
157 } |
|
158 |
|
159 |
|
160 RMobileUssdMessaging::TMobileUssdAttributesV1::TMobileUssdAttributesV1() |
|
161 { |
|
162 iFlags = 0; |
|
163 iFormat = EFormatUnspecified; |
|
164 iType = EUssdUnknown; |
|
165 iDcs = 0; |
|
166 } |
|
167 |
|
168 RMobileUssdMessaging::TMobileUssdCapsV1::TMobileUssdCapsV1() |
|
169 { |
|
170 iUssdFormat = 0; |
|
171 iUssdTypes = 0; |
|
172 } |
|
173 |
|
174 // ============================================================================== |
|
175 // RMobilePhone |
|
176 // ============================================================================== |
|
177 |
|
178 RMobilePhone::TMobilePhoneSendSSRequestV3::TMobilePhoneSendSSRequestV3() |
|
179 { |
|
180 iOpCode = 0; |
|
181 } |
|
182 |
|
183 RMobilePhone::TMultimodeType::TMultimodeType() |
|
184 { |
|
185 iExtensionId = 0; |
|
186 } |
|
187 |
|
188 // ============================================================================== |
|
189 // RTelSubSessionBase |
|
190 // ============================================================================== |
|
191 |
|
192 RTelSubSessionBase::RTelSubSessionBase() |
|
193 { |
|
194 } |
|
195 |
|
196 void RTelSubSessionBase::CancelAsyncRequest(TInt aReqToCancel) const |
|
197 { |
|
198 if ( aReqToCancel == EMobileUssdMessagingSendMessage ) |
|
199 { |
|
200 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
201 if ( loop.mSendMessageReqStatus ) |
|
202 { |
|
203 User::RequestComplete( loop.mSendMessageReqStatus, KErrCancel ); |
|
204 } |
|
205 } |
|
206 else if ( aReqToCancel == EMobileUssdMessagingReceiveMessage ) |
|
207 { |
|
208 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
209 if ( loop.mReceiveMessageReqStatus ) |
|
210 { |
|
211 User::RequestComplete( loop.mReceiveMessageReqStatus, KErrCancel ); |
|
212 } |
|
213 } |
|
214 else if ( aReqToCancel == EMobileUssdMessagingNotifyNetworkRelease ) |
|
215 { |
|
216 EtelMsgLoop& loop = TestEnv::env().etelMsgLoop(); |
|
217 if ( loop.mNetworkReleaseReqStatus ) |
|
218 { |
|
219 User::RequestComplete( loop.mNetworkReleaseReqStatus, KErrCancel ); |
|
220 } |
|
221 } |
|
222 else if ( aReqToCancel == EMobileUssdMessagingSendRelease ) |
|
223 { |
|
224 // not used |
|
225 } |
|
226 } |
|
227 |