30 @SYMTestPriority High |
29 @SYMTestPriority High |
31 @SYMTestActions Invokes RMobileUssdMessaging::ReceiveMessage |
30 @SYMTestActions Invokes RMobileUssdMessaging::ReceiveMessage |
32 @SYMTestExpectedResults Pass |
31 @SYMTestExpectedResults Pass |
33 @SYMTestType CT |
32 @SYMTestType CT |
34 */ |
33 */ |
35 TInt CCTsyUssdMessagingTestClient::ReceiveMessageL(TBool aAcceptDialogue, TBool aReceiveTimeout, TReal aAfterTimePeriod) |
34 TInt CCTsyUssdMessagingTestClient::ReceiveMessageL(TBool aAcceptDialogue, TBool aReceiveTimeout, TReal aAfterTimePeriod, TBool aMO) |
36 { |
35 { |
37 // Create a cleanup stack object |
36 // Create a cleanup stack object |
38 CTrapCleanup* cleanup=CTrapCleanup::New(); |
37 CTrapCleanup* cleanup=CTrapCleanup::New(); |
39 if (cleanup==NULL) |
38 if (cleanup==NULL) |
40 return KErrNoMemory; |
39 return KErrNoMemory; |
112 |
111 |
113 //RDebug::Printf("%x >> WaitForRequest", User::Identity()); |
112 //RDebug::Printf("%x >> WaitForRequest", User::Identity()); |
114 User::WaitForRequest(requestStatus); |
113 User::WaitForRequest(requestStatus); |
115 //RDebug::Printf("%x << WaitForRequest", User::Identity()); |
114 //RDebug::Printf("%x << WaitForRequest", User::Identity()); |
116 //RDebug::Printf("%x requestStatus = %d", User::Identity(), requestStatus.Int()); |
115 //RDebug::Printf("%x requestStatus = %d", User::Identity(), requestStatus.Int()); |
117 |
116 |
118 |
|
119 if (aAfterTimePeriod) |
117 if (aAfterTimePeriod) |
120 { |
118 { |
121 //RDebug::Printf("%x Waiting for %f seconds", User::Identity(), aAfterTimePeriod); |
119 //RDebug::Printf("%x Waiting for %f seconds", User::Identity(), aAfterTimePeriod); |
122 // Wait, mimic a bad client taking too long... |
120 // Wait, mimic a bad client taking too long... |
123 User::After(aAfterTimePeriod * 1000000); |
121 User::After(aAfterTimePeriod * 1000000); |
124 } |
122 } |
125 |
123 |
126 if (aAcceptDialogue) |
124 if(EFalse == aMO) |
127 { |
125 //network initiated dialog |
128 //RDebug::Printf("%x >> AcceptIncomingDialogue", User::Identity()); |
126 { |
129 // Client wants the dialogue |
127 //RDebug::Printf("NI Dialog"); |
130 ret = ussdMessaging.AcceptIncomingDialogue(); |
128 if (aAcceptDialogue) |
131 //RDebug::Printf("%x << AcceptIncomingDialogue", User::Identity()); |
129 { |
|
130 //RDebug::Printf("%x >> AcceptIncomingDialogue", User::Identity()); |
|
131 // Client wants the dialogue |
|
132 ret = ussdMessaging.AcceptIncomingDialogue(); |
|
133 //RDebug::Printf("%x << AcceptIncomingDialogue", User::Identity()); |
|
134 } |
|
135 else |
|
136 { |
|
137 // Client not interested |
|
138 //RDebug::Printf("%x >> RejectIncomingDialogue", User::Identity()); |
|
139 ret = ussdMessaging.RejectIncomingDialogue(); |
|
140 //RDebug::Printf("%x << RejectIncomingDialogue", User::Identity()); |
|
141 } |
132 } |
142 } |
133 else |
143 else |
134 { |
144 { |
135 // Client not interested |
145 //RDebug::Printf("MO Dialogue"); |
136 //RDebug::Printf("%x >> RejectIncomingDialogue", User::Identity()); |
146 ret = requestStatus.Int(); |
137 ret = ussdMessaging.RejectIncomingDialogue(); |
147 } |
138 //RDebug::Printf("%x << RejectIncomingDialogue", User::Identity()); |
148 //RDebug::Printf("%x Received Message: %S", User::Identity(), &name); |
139 } |
|
140 |
|
141 User::After(2 * 1000000); |
149 User::After(2 * 1000000); |
142 |
150 |
143 ussdMessaging.Close(); |
151 ussdMessaging.Close(); |
144 phone.Close(); |
152 phone.Close(); |
145 server.Close(); |
153 server.Close(); |
197 { |
205 { |
198 server.Close(); |
206 server.Close(); |
199 phone.Close(); |
207 phone.Close(); |
200 return ret; |
208 return ret; |
201 } |
209 } |
202 |
210 |
203 //RDebug::Printf(">> SendMessage"); |
|
204 ussdMessaging.SendMessage(requestStatus, msgData, msgAttributes); |
211 ussdMessaging.SendMessage(requestStatus, msgData, msgAttributes); |
205 //RDebug::Printf("<< SendMessage"); |
212 User::WaitForRequest(requestStatus); |
206 //RDebug::Printf(">> WaitForRequest"); |
|
207 User::WaitForRequest(requestStatus); |
|
208 //RDebug::Printf("<< WaitForRequest"); |
|
209 ret = requestStatus.Int(); |
213 ret = requestStatus.Int(); |
210 //RDebug::Printf("requestStatus = %d", ret); |
214 |
211 |
|
212 |
|
213 User::After(2 * 1000000); |
215 User::After(2 * 1000000); |
214 |
216 |
215 ussdMessaging.Close(); |
217 ussdMessaging.Close(); |
216 phone.Close(); |
218 phone.Close(); |
217 server.Close(); |
219 server.Close(); |
218 |
220 |
219 delete cleanup; |
221 delete cleanup; |
220 return KErrNone; |
222 return KErrNone; |
221 } |
223 } |
222 |
224 |
|
225 TInt CCTsyUssdMessagingTestClient::SendMessageDefaultHandlerL() |
|
226 { |
|
227 // Create a cleanup stack object |
|
228 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
229 if (cleanup==NULL) |
|
230 return KErrNoMemory; |
|
231 |
|
232 RTelServer server; |
|
233 RMobilePhone phone; |
|
234 |
|
235 TInt ret = server.Connect(); |
|
236 if (ret != KErrNone) |
|
237 { |
|
238 server.Close(); |
|
239 return ret; |
|
240 } |
|
241 |
|
242 RDebug::Printf(">> server.Connect() SUCCESS!"); |
|
243 ret = phone.Open(server,KMmTsyPhoneName); |
|
244 if (ret != KErrNone) |
|
245 { |
|
246 server.Close(); |
|
247 phone.Close(); |
|
248 return ret; |
|
249 } |
|
250 RDebug::Printf(">> phone.Open() SUCCESS!"); |
|
251 TRequestStatus requestStatus; |
|
252 |
|
253 TUint32 flags = 100; |
|
254 RMobileUssdMessaging::TMobileUssdDataFormat format = RMobileUssdMessaging::EFormatUnspecified; |
|
255 RMobileUssdMessaging::TMobileUssdMessageType type = RMobileUssdMessaging::EUssdMORequest; |
|
256 TUint8 dcs = 200; |
|
257 |
|
258 RMobileUssdMessaging::TMobileUssdAttributesV1 attributes; |
|
259 TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(attributes); |
|
260 |
|
261 attributes.iFlags = flags; |
|
262 attributes.iFormat = format; |
|
263 attributes.iType = type; |
|
264 attributes.iDcs = dcs; |
|
265 |
|
266 TName name = _L("Name1"); |
|
267 TPckg<TName> msgData(name); |
|
268 |
|
269 RMobileUssdMessaging ussdMessaging; |
|
270 ret = ussdMessaging.Open(phone); |
|
271 if (ret != KErrNone) |
|
272 { |
|
273 server.Close(); |
|
274 phone.Close(); |
|
275 return ret; |
|
276 } |
|
277 RDebug::Printf(">> ussdMessaging.Open() SUCCESS!"); |
|
278 |
|
279 ussdMessaging.SendMessage(requestStatus, msgData, msgAttributes, RMobileUssdMessaging::ETransferToDefaultHandler); |
|
280 User::WaitForRequest(requestStatus); |
|
281 ret = requestStatus.Int(); |
|
282 RDebug::Printf(">> ret = %d", ret); |
|
283 |
|
284 User::After(2 * 1000000); |
|
285 |
|
286 ussdMessaging.Close(); |
|
287 phone.Close(); |
|
288 server.Close(); |
|
289 |
|
290 delete cleanup; |
|
291 return ret; |
|
292 } |
223 TInt CCTsyUssdMessagingTestClient::RandomLoopL() |
293 TInt CCTsyUssdMessagingTestClient::RandomLoopL() |
224 { |
294 { |
225 // Create a cleanup stack object |
295 // Create a cleanup stack object |
226 CTrapCleanup* cleanup=CTrapCleanup::New(); |
296 CTrapCleanup* cleanup=CTrapCleanup::New(); |
227 if (cleanup==NULL) |
297 if (cleanup==NULL) |
331 _LIT(KReceiveTimeoutOption,"-RTimeout"); |
401 _LIT(KReceiveTimeoutOption,"-RTimeout"); |
332 _LIT(KSendOption,"-S"); |
402 _LIT(KSendOption,"-S"); |
333 _LIT(KAcceptOption,"-A"); |
403 _LIT(KAcceptOption,"-A"); |
334 _LIT(KTimerOption,"-T"); |
404 _LIT(KTimerOption,"-T"); |
335 _LIT(KRandomOption,"-Random"); |
405 _LIT(KRandomOption,"-Random"); |
|
406 _LIT(KDefaultOption,"-D"); |
|
407 _LIT(KMOOption,"-M"); |
336 TInt ParseCommandLine(TReal& aAfterTimePeriod) |
408 TInt ParseCommandLine(TReal& aAfterTimePeriod) |
337 { |
409 { |
338 TBuf<256> c; |
410 TBuf<256> c; |
339 User::CommandLine(c); |
411 User::CommandLine(c); |
340 |
412 |
361 } |
433 } |
362 else if (nextToken == KAcceptOption) |
434 else if (nextToken == KAcceptOption) |
363 { |
435 { |
364 option |= EOptionAccept; |
436 option |= EOptionAccept; |
365 } |
437 } |
|
438 else if (nextToken == KDefaultOption) |
|
439 { |
|
440 option |= EOptionDefault; |
|
441 } |
|
442 else if (nextToken == KMOOption) |
|
443 { |
|
444 option |= EOptionMO; |
|
445 } |
366 else if (nextToken == KTimerOption) |
446 else if (nextToken == KTimerOption) |
367 { |
447 { |
368 nextToken.Set(l.NextToken()); |
448 nextToken.Set(l.NextToken()); |
369 if (nextToken != KNullDesC) |
449 if (nextToken != KNullDesC) |
370 { |
450 { |
399 TInt err = KErrNone; |
479 TInt err = KErrNone; |
400 TInt ret = KErrNone; |
480 TInt ret = KErrNone; |
401 CCTsyUssdMessagingTestClient ussdClient; |
481 CCTsyUssdMessagingTestClient ussdClient; |
402 if (option & EOptionReceive) |
482 if (option & EOptionReceive) |
403 { |
483 { |
404 TRAPD(err, ret = ussdClient.ReceiveMessageL((option & EOptionAccept), (option & EOptionReceiveTimeout), afterTimePeriod)); |
484 TRAPD(err, ret = ussdClient.ReceiveMessageL((option & EOptionAccept), (option & EOptionReceiveTimeout), afterTimePeriod, (option & EOptionMO))); |
405 } |
485 } |
406 |
486 |
407 if (option & EOptionSend) |
487 if (option & EOptionSend) |
408 { |
488 { |
409 TRAPD(err, ret = ussdClient.SendMessageL()); |
489 TRAPD(err, ret = ussdClient.SendMessageL()); |
410 } |
490 } |
411 |
491 |
|
492 if (option & EOptionDefault) |
|
493 { |
|
494 TRAPD(err, ret = ussdClient.SendMessageDefaultHandlerL()); |
|
495 } |
|
496 |
412 if (option & EOptionRandom) |
497 if (option & EOptionRandom) |
413 { |
498 { |
414 TRAPD(err, ret = ussdClient.RandomLoopL()); |
499 TRAPD(err, ret = ussdClient.RandomLoopL()); |
415 } |
500 } |
416 |
501 |