|
1 // Copyright (c) 1997-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // PARAM_MESS_NAME_CStep.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 //Test Step header |
|
21 #include "PARAM_MESS_NAME_CStep.h" |
|
22 |
|
23 |
|
24 //TO BE SAFE |
|
25 IMPORT_C TInt StartDialogThread(); |
|
26 static const TInt KWaitPeriod = 3000000; |
|
27 static const TInt KListenQLength = 2; |
|
28 const TUint32 KInetAddrTestNetwork = INET_ADDR(10,22,64,10); //(127,0,0,1); |
|
29 |
|
30 CPARAM_MESS_NAMEStep::CPARAM_MESS_NAMEStep(TBool aUpsAuthorisationGranted) |
|
31 /** Each test step initialises it's own name |
|
32 */ |
|
33 { |
|
34 // store the name of this test case |
|
35 // this is the name that is used by the script file |
|
36 //DEF iTestStepName = _L("CPARAM_MESS_NAMEStep"); |
|
37 |
|
38 //The server name and IPC number is obtained and all messages are checked Sync |
|
39 SR_ServerName = _L("PARAM_SVR_NAME"); |
|
40 SR_MESSAGE_TYPE = 2; |
|
41 SR_MESSAGE_ID = PARAM_MESS_VALUE; |
|
42 SR_MESSAGE_MASK = PARAM_MESS_CAPMASK; |
|
43 |
|
44 //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName |
|
45 |
|
46 iServer_Panic = _L("PARAM_SVR_T16_PANIC"); |
|
47 |
|
48 TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit}; |
|
49 |
|
50 TSecurityInfo info; |
|
51 info.Set(RProcess()); |
|
52 TBool result = EFalse; |
|
53 |
|
54 for (TInt i = 0; cap[i] != ECapability_Limit; i++) |
|
55 { |
|
56 if ((!aUpsAuthorisationGranted || cap[i] != ECapabilityNetworkServices) && |
|
57 !(info.iCaps.HasCapability(cap[i]))) |
|
58 { |
|
59 result=ETrue; |
|
60 |
|
61 } |
|
62 |
|
63 } |
|
64 |
|
65 |
|
66 iExpect_Rejection = result; |
|
67 |
|
68 iStepCap = PARAM_MESS_CAPMASK; |
|
69 |
|
70 //Get a unique thread name |
|
71 ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); |
|
72 |
|
73 } |
|
74 |
|
75 /* |
|
76 Exec_SendReceive(): |
|
77 This Fn is called by the Child Thread |
|
78 1. Create a session with the server |
|
79 2. Test an SendReceive call |
|
80 3. Informs the main thread about the status of the call using |
|
81 a. iSessionCreated, if the a connection is established |
|
82 b. iResult_Server, holds the return value for connection |
|
83 c. iResult_SR, the return value of SendReceive call |
|
84 */ |
|
85 /*TInt CPARAM_MESS_NAMEStep::Exec_SendReceive() |
|
86 { |
|
87 iResult_Server = CreateSession(SR_ServerName,Version(),2); |
|
88 |
|
89 if (iResult_Server!=KErrNone) |
|
90 { |
|
91 |
|
92 iResult_Server=StartServer(); |
|
93 if (iResult_Server!=KErrNone) |
|
94 return(iResult_Server); |
|
95 |
|
96 iResult_Server = CreateSession(SR_ServerName,TVersion(),2); |
|
97 } |
|
98 if(iResult_Server == 0) |
|
99 { |
|
100 iSessionCreated = ETrue; |
|
101 if(SR_MESSAGE_ID >= 0) |
|
102 iResult_SR = SendReceive(SR_MESSAGE_ID,TIpcArgs(0,0,0,0)); |
|
103 } |
|
104 |
|
105 return iResult_Server; |
|
106 }*/ |
|
107 |
|
108 TInt CPARAM_MESS_NAMEStep::Exec_SendReceive() |
|
109 { |
|
110 _LIT(KEsockSessStartMutex,"KESSMTX"); //Keep the descriptor short |
|
111 RMutex mutex; |
|
112 TInt r; |
|
113 // Protect the openning of the session |
|
114 // with a mutex to stop thread collision |
|
115 FOREVER |
|
116 { |
|
117 r = mutex.CreateGlobal(KEsockSessStartMutex()); |
|
118 if (r == KErrNone) |
|
119 break; |
|
120 if (r != KErrAlreadyExists) |
|
121 return r; |
|
122 r=mutex.OpenGlobal(KEsockSessStartMutex()); |
|
123 if (r == KErrNone) |
|
124 break; |
|
125 if (r != KErrNotFound) |
|
126 return r; |
|
127 } |
|
128 mutex.Wait(); // the exclusion ensures the session is started atomically |
|
129 iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); |
|
130 // Because ESock is now loaded by the Comms Root Server which is generally started during |
|
131 // the boot this should commonly succeed; however for test code this is still a possibility |
|
132 // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) |
|
133 if (iResult_Server==KErrNotFound) |
|
134 { |
|
135 r=StartC32(); |
|
136 if (r==KErrNone || r==KErrAlreadyExists) |
|
137 { |
|
138 iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); |
|
139 } |
|
140 } |
|
141 mutex.Signal(); |
|
142 mutex.Close(); |
|
143 |
|
144 if (iResult_Server == KErrNone) |
|
145 { |
|
146 iSessionCreated = ETrue; |
|
147 |
|
148 const TInt test_id = dispatch_num<PARAM_MESS_VALUE>::result; |
|
149 |
|
150 iResult_SR = do_execute(Int2Type<test_id>()); |
|
151 } |
|
152 else |
|
153 { |
|
154 iSessionCreated = EFalse; |
|
155 return 0; |
|
156 } |
|
157 return r; |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 // Use ONLY for ESoConnect |
|
163 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoConnect>) |
|
164 { |
|
165 // Open and Bind socket |
|
166 TInt result = do_execute(Int2Type<ESoBind>()); |
|
167 |
|
168 if (result == KErrNone) |
|
169 { |
|
170 const TUint32 KInetAddr = PARAM_MESS_REMIP4ADDR; |
|
171 TInetAddr Addr(KInetAddr, PARAM_MESS_LOCALPORT); |
|
172 |
|
173 result = do_async_sr(ESoConnect, ESoCancelAll, |
|
174 TIpcArgs(&Addr, NULL, NULL,iSSRef)); |
|
175 } |
|
176 return result; |
|
177 } |
|
178 |
|
179 // Use ONLY for ESoConnect |
|
180 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoShutdown>) |
|
181 { |
|
182 // Open and Bind socket |
|
183 TInt result = do_execute(Int2Type<ESoBind>()); |
|
184 |
|
185 if (result == KErrNone) |
|
186 { |
|
187 |
|
188 result = do_async_sr(ESoShutdown, ESoCancelAll, |
|
189 TIpcArgs(0,0,0,iSSRef)); //RSocket::ENormal = 0 |
|
190 } |
|
191 return result; |
|
192 } |
|
193 /* |
|
194 TRequestStatus status; |
|
195 SendReceive(ESoIoctl, |
|
196 TIpcArgs(PARAM_MESS_OPTNAME,NULL,PARAM_MESS_OPTLEVEL,iSSRef),status); |
|
197 User::WaitForRequest(status); |
|
198 return status.Int(); |
|
199 |
|
200 */ |
|
201 |
|
202 // Use ONLY for ESoCancelConnect |
|
203 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelConnect>) |
|
204 { |
|
205 // Open and Bind socket |
|
206 TInt result = do_execute(Int2Type<ESoBind>()); |
|
207 |
|
208 if (result == KErrNone) |
|
209 { |
|
210 const TUint32 KInetAddr = PARAM_MESS_REMIP4ADDR; |
|
211 TInetAddr Addr(KInetAddr, PARAM_MESS_LOCALPORT); |
|
212 |
|
213 result = do_sync_cancel(ESoConnect, ESoCancelConnect, |
|
214 TIpcArgs(&Addr, NULL, NULL,iSSRef)); |
|
215 } |
|
216 return result; |
|
217 } |
|
218 // Use ONLY for ESoBind |
|
219 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoBind>) |
|
220 { |
|
221 TInt result = MakeSubsession(); |
|
222 // Do binding |
|
223 if (result == KErrNone) |
|
224 { |
|
225 TInetAddr Addr(PARAM_MESS_LOCALPORT); |
|
226 return SendReceive(ESoBind,TIpcArgs(&Addr, 0, 0, iSSRef)); |
|
227 } |
|
228 return result; |
|
229 } |
|
230 // ESoRecv |
|
231 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoRecv>) |
|
232 { |
|
233 // Open, Bind and Connect to socket |
|
234 TInt result = do_execute(Int2Type<ESoSend>()); |
|
235 |
|
236 return result; |
|
237 } |
|
238 // ESoCancelRecv , cancel ESoRecv prematually |
|
239 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelRecv>) |
|
240 { |
|
241 // Open, Bind and Connect to socket |
|
242 TInt result = do_execute(Int2Type<ESoConnect>()); |
|
243 |
|
244 // Send data |
|
245 if (result == KErrNone) |
|
246 { |
|
247 TPtr8 bufPtr = (HBufC8::NewL(0))->Des(); |
|
248 TSockXfrLength length = 0; |
|
249 |
|
250 result = do_sync_cancel(ESoRecv, ESoCancelRecv, |
|
251 TIpcArgs(NULL,&length,&bufPtr,iSSRef)); |
|
252 } |
|
253 return result; |
|
254 } |
|
255 // ESoRecvOneOrMore |
|
256 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoRecvOneOrMore>) |
|
257 { |
|
258 // Open, Bind and Connect to socket |
|
259 TInt result = do_execute(Int2Type<ESoSend>()); |
|
260 |
|
261 return result; |
|
262 } |
|
263 // ESoRecvOneOrMoreNoLength |
|
264 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoRecvOneOrMoreNoLength>) |
|
265 { |
|
266 // Open, Bind and Connect to socket |
|
267 TInt result = do_execute(Int2Type<ESoSend>()); |
|
268 |
|
269 return result; |
|
270 } |
|
271 // ESoRead |
|
272 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoRead>) |
|
273 { |
|
274 // Open, Bind and Connect to socket |
|
275 TInt result = do_execute(Int2Type<ESoSend>()); |
|
276 |
|
277 return result; |
|
278 } |
|
279 // ESoWrite |
|
280 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoWrite>) |
|
281 { |
|
282 // Open, Bind and Connect to socket |
|
283 TInt result = do_execute(Int2Type<ESoSend>()); |
|
284 |
|
285 return result; |
|
286 } |
|
287 // used for ESoSend and being called by ESoSendNoLength, |
|
288 // ESoRecv, ESoRecvNoLength, ESoRecvOneOrMore, ESoRecvOneOrMoreNoLength |
|
289 // ESoRead and ESoWrite |
|
290 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoSend>) |
|
291 { |
|
292 // Open, Bind and Connect to socket |
|
293 TInt result = do_execute(Int2Type<ESoConnect>()); |
|
294 |
|
295 // Send data |
|
296 if (result == KErrNone) |
|
297 { |
|
298 TPtr8 bufPtr = (HBufC8::NewL(0))->Des(); |
|
299 TSockXfrLength length = 0; |
|
300 |
|
301 if(PARAM_MESS_VALUE == ESoSendTo || PARAM_MESS_VALUE == ESoRecvFrom) |
|
302 { |
|
303 result = do_async_sr(PARAM_MESS_VALUE, ESoCancelAll, |
|
304 TIpcArgs(&length,NULL,&bufPtr,iSSRef)); |
|
305 } |
|
306 else |
|
307 { |
|
308 result = do_async_sr(PARAM_MESS_VALUE, ESoCancelAll, |
|
309 TIpcArgs(NULL,&length,&bufPtr,iSSRef)); |
|
310 } |
|
311 } |
|
312 return result; |
|
313 } |
|
314 |
|
315 // ESoCancelSend, used by ESoCancelAll |
|
316 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelSend>) |
|
317 { |
|
318 // Open, Bind and Connect to socket |
|
319 TInt result = do_execute(Int2Type<ESoConnect>()); |
|
320 |
|
321 // Send data |
|
322 if (result == KErrNone) |
|
323 { |
|
324 TPtr8 bufPtr = (HBufC8::NewL(0))->Des(); |
|
325 TSockXfrLength length = 0; |
|
326 |
|
327 result = do_sync_cancel(ESoSend, PARAM_MESS_VALUE, |
|
328 TIpcArgs(NULL,&length,&bufPtr,iSSRef)); |
|
329 } |
|
330 return result; |
|
331 } |
|
332 // ESoCancelAll, cancel action prematually |
|
333 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelAll>) |
|
334 { |
|
335 // Open, Bind and Connect to socket |
|
336 TInt result = do_execute(Int2Type<ESoCancelSend>()); |
|
337 |
|
338 return result; |
|
339 } |
|
340 // used for ESoSendTo and ESoSendToNoLength, |
|
341 // ESoRecvFrom and ESoRecvFromNoLength |
|
342 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoSendTo>) |
|
343 { |
|
344 TInt result = MakeSubsession(); |
|
345 // Use unconnected/unbound socket |
|
346 // Send data |
|
347 if (result == KErrNone) |
|
348 { |
|
349 TPtr8 bufPtr = (HBufC8::NewL(0))->Des(); |
|
350 |
|
351 const TUint32 KInetAddr = PARAM_MESS_REMIP4ADDR; |
|
352 TInetAddr Addr(KInetAddr, PARAM_MESS_LOCALPORT); |
|
353 |
|
354 TSockXfrLength length = 0; |
|
355 result = do_async_sr(PARAM_MESS_VALUE, ESoCancelAll, |
|
356 TIpcArgs(&length,&Addr,&bufPtr,iSSRef)); |
|
357 } |
|
358 return result; |
|
359 } |
|
360 // ESoRecvFrom |
|
361 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoRecvFrom>) |
|
362 { |
|
363 TInt result = do_execute(Int2Type<ESoSendTo>()); |
|
364 return result; |
|
365 } |
|
366 // Use ONLY for ESoAccept, ESoCancelAccept being tested as well |
|
367 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoAccept>) |
|
368 { |
|
369 // Open, bind and listen |
|
370 TInt result = do_execute(Int2Type<ESoListen>()); |
|
371 // Open a new blank subsession |
|
372 TInt reply = 0; |
|
373 TPckgBuf<TInt> session(reply); |
|
374 if (result == KErrNone) |
|
375 { |
|
376 result = SendReceive(ESoCreateNull, |
|
377 TIpcArgs(NULL,NULL,NULL, &session)); |
|
378 reply = session(); |
|
379 } |
|
380 |
|
381 // Call accept |
|
382 if (result == KErrNone) |
|
383 { |
|
384 result = do_async_sr(ESoAccept, ESoCancelAccept, |
|
385 TIpcArgs(NULL,reply,NULL,iSSRef)); |
|
386 } |
|
387 return result; |
|
388 } |
|
389 // Use ONLY for ESoCancelAccept for prematually stop action |
|
390 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelAccept>) |
|
391 { |
|
392 // Open, bind and listen |
|
393 TInt result = do_execute(Int2Type<ESoListen>()); |
|
394 // Open a new blank subsession |
|
395 TInt reply = 0; |
|
396 TPckgBuf<TInt> session(reply); |
|
397 if (result == KErrNone) |
|
398 { |
|
399 result = SendReceive(ESoCreateNull, |
|
400 TIpcArgs(NULL,NULL,NULL, &session)); // another session to accept |
|
401 reply = session(); |
|
402 } |
|
403 |
|
404 // Call accept |
|
405 if (result == KErrNone) |
|
406 { |
|
407 result = do_async_cancel(ESoAccept, ESoCancelAccept, |
|
408 TIpcArgs(NULL,reply,NULL,iSSRef)); |
|
409 } |
|
410 return result; |
|
411 } |
|
412 |
|
413 // Use ONLY for ESoListen |
|
414 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoListen>) |
|
415 { |
|
416 // Needs to be open and bound |
|
417 TInt result = do_execute(Int2Type<ESoBind>()); |
|
418 // Call Listen with arbitraty queue length |
|
419 if (result == KErrNone) |
|
420 { |
|
421 return SendReceive(ESoListen,TIpcArgs(KListenQLength,NULL,NULL,iSSRef)); |
|
422 } |
|
423 return result; |
|
424 } |
|
425 // Use only for ESoSetOpt and ESoGetOpt and ESoIoctl |
|
426 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoSetOpt>) |
|
427 { |
|
428 TInt result = MakeSubsession(); |
|
429 |
|
430 if (result == KErrNone) |
|
431 { |
|
432 TInt optionVal = PARAM_MESS_OPTVAL; |
|
433 TPtr8 optionDes((TUint8*)&optionVal,sizeof(TInt),sizeof(TInt)); |
|
434 result = SendReceive(ESoSetOpt, |
|
435 TIpcArgs(PARAM_MESS_OPTNAME,&optionDes,PARAM_MESS_OPTLEVEL,iSSRef)); |
|
436 } |
|
437 return result; |
|
438 } |
|
439 // Use only for ESoSetOpt and ESoGetOpt and ESoIoctl |
|
440 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoGetOpt>) |
|
441 { |
|
442 TInt result = do_execute(Int2Type<ESoSetOpt>()); |
|
443 |
|
444 if (result == KErrNone) |
|
445 { |
|
446 TInt optionVal; //expected return value packeted in a descriptor |
|
447 TPtr8 optionDes((TUint8*)&optionVal,sizeof(TInt),sizeof(TInt)); |
|
448 result = SendReceive(ESoGetOpt, |
|
449 TIpcArgs(PARAM_MESS_OPTNAME,&optionDes,PARAM_MESS_OPTLEVEL,iSSRef)); |
|
450 } |
|
451 return result; |
|
452 } |
|
453 |
|
454 // Use for ESoIoctl |
|
455 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoIoctl>) |
|
456 { |
|
457 TInt result = MakeSubsession(); |
|
458 |
|
459 if (result == KErrNone) |
|
460 { |
|
461 TRequestStatus status; |
|
462 SendReceive(ESoIoctl, |
|
463 TIpcArgs(PARAM_MESS_OPTNAME,NULL,PARAM_MESS_OPTLEVEL,iSSRef),status); |
|
464 User::WaitForRequest(status); |
|
465 return status.Int(); |
|
466 } |
|
467 return result; |
|
468 } |
|
469 // Use for ESoCancelIoctl |
|
470 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCancelIoctl>) |
|
471 { |
|
472 TInt result = MakeSubsession(); |
|
473 |
|
474 if (result == KErrNone) |
|
475 { |
|
476 result = do_sync_cancel(ESoIoctl, ESoCancelIoctl, |
|
477 TIpcArgs(PARAM_MESS_OPTNAME,NULL,PARAM_MESS_OPTLEVEL,iSSRef)); |
|
478 } |
|
479 return result; |
|
480 } |
|
481 |
|
482 // Use for ESoGetDiscData, ESoGetLocalName, ESoGetRemoteName |
|
483 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoGetDiscData>) |
|
484 { |
|
485 TInt result = do_execute(Int2Type<ESoConnect>()); |
|
486 if (result == KErrNone) |
|
487 { |
|
488 TSockAddr addr; |
|
489 result = do_async_sr(PARAM_MESS_VALUE, ESoCancelConnect, |
|
490 TIpcArgs(&addr,NULL,NULL,iSSRef)); |
|
491 } |
|
492 |
|
493 return result; |
|
494 } |
|
495 // Use for ESoGetLocalName |
|
496 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoGetLocalName>) |
|
497 { |
|
498 TInt result = do_execute(Int2Type<ESoBind>()); |
|
499 |
|
500 if (result == KErrNone) |
|
501 { |
|
502 // we can use local loopback for testing ESoGetLocalName/ESoGetRemoteName |
|
503 const TUint32 KInetAddr = PARAM_MESS_LOCALIP4ADDR; |
|
504 TInetAddr Addr(KInetAddr, PARAM_MESS_LOCALPORT); |
|
505 |
|
506 result = do_async_sr(ESoConnect, ESoCancelAll, |
|
507 TIpcArgs(&Addr, NULL, NULL,iSSRef)); |
|
508 |
|
509 if (result == KErrNone) |
|
510 { |
|
511 // This is where the actual test of ESoGetLocalName/ESoGetRemoteName takes place |
|
512 TSockAddr addr; |
|
513 result = do_async_sr(PARAM_MESS_VALUE, ESoCancelAll, |
|
514 TIpcArgs(&addr,NULL,NULL,iSSRef)); |
|
515 } |
|
516 } |
|
517 |
|
518 return result; |
|
519 } |
|
520 |
|
521 // Use for ESoGetRemoteName |
|
522 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoGetRemoteName>) |
|
523 { |
|
524 TInt result = do_execute(Int2Type<ESoGetLocalName>()); |
|
525 return result; |
|
526 } |
|
527 |
|
528 // Use for ESoSocketInfo |
|
529 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoSocketInfo>) |
|
530 { |
|
531 // Needs to be open |
|
532 TInt result = MakeSubsession(); |
|
533 TProtocolDesc protoInfo; |
|
534 TPckg<TProtocolDesc> protDesc(protoInfo); |
|
535 // Call ESoSocketInfo |
|
536 if (result == KErrNone) |
|
537 { |
|
538 result = SendReceive(ESoSocketInfo,TIpcArgs(&protDesc,0,0,iSSRef)); |
|
539 } |
|
540 return result; |
|
541 } |
|
542 // Use for ESoReference |
|
543 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoReference>) |
|
544 { |
|
545 // Needs to be open |
|
546 TInt result = MakeSubsession(); |
|
547 TName aName; |
|
548 // Call RSocket::Name() |
|
549 if (result == KErrNone) |
|
550 { |
|
551 result = SendReceive(ESoReference,TIpcArgs(&aName,0,0,iSSRef)); |
|
552 } |
|
553 return result; |
|
554 } |
|
555 // Use for ESoCreateWithSubConnection |
|
556 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCreateWithSubConnection>) |
|
557 { |
|
558 const TDesC& protName = _L("PARAM_MESS_PROTNAME"); |
|
559 TProtocolDesc protoInfo; |
|
560 TPckg<TProtocolDesc> protDesc(protoInfo); |
|
561 TInt result = SendReceive(ESSProtocolInfoByName,TIpcArgs(&protDesc,&protName)); |
|
562 if (result == KErrNone) |
|
563 { |
|
564 TPckgBuf<TInt> session(iSSRef); |
|
565 // Opens socket of the given type |
|
566 result = SendReceive(ESoCreate, |
|
567 TIpcArgs(protoInfo.iAddrFamily, protoInfo.iSockType, protoInfo.iProtocol, &session)); |
|
568 iSSRef = session(); |
|
569 } |
|
570 // Clean up |
|
571 if (result == KErrNone) |
|
572 { |
|
573 result = SendReceive(ESoClose,TIpcArgs(0,0,0,iSSRef)); |
|
574 } |
|
575 return result; |
|
576 } |
|
577 // Use for ESoCreate |
|
578 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESoCreate>) |
|
579 { |
|
580 // Needs to be open |
|
581 TInt result = MakeSubsession(); |
|
582 // Call RSocket::Close() |
|
583 if (result == KErrNone) |
|
584 { |
|
585 result = SendReceive(ESoClose,TIpcArgs(0,0,0,iSSRef)); |
|
586 } |
|
587 return result; |
|
588 } |
|
589 |
|
590 // Being called by many other as it does ESoCreate |
|
591 TInt CPARAM_MESS_NAMEStep::MakeSubsession() |
|
592 { |
|
593 const TDesC& protName = _L("PARAM_MESS_PROTNAME"); |
|
594 TProtocolDesc protoInfo; |
|
595 TPckg<TProtocolDesc> protDesc(protoInfo); |
|
596 TInt err = SendReceive(ESSProtocolInfoByName,TIpcArgs(&protDesc,&protName)); |
|
597 if (err == KErrNone) |
|
598 { |
|
599 TPckgBuf<TInt> session(iSSRef); |
|
600 // Opens socket of the given type |
|
601 err = SendReceive(ESoCreate, |
|
602 TIpcArgs(protoInfo.iAddrFamily, protoInfo.iSockType, protoInfo.iProtocol, &session)); |
|
603 iSSRef = session(); |
|
604 } |
|
605 return err; |
|
606 } |
|
607 |
|
608 |
|
609 TInt CPARAM_MESS_NAMEStep::do_async_sr(const TInt aMess, const TInt aCancelMess, const TIpcArgs& aArgs) |
|
610 { |
|
611 TRequestStatus stat, timerStatus; |
|
612 |
|
613 RTimer timer; |
|
614 timer.CreateLocal(); |
|
615 timer.After(timerStatus, KWaitPeriod); |
|
616 |
|
617 SendReceive(aMess, aArgs, stat); |
|
618 User::WaitForRequest(stat, timerStatus); |
|
619 |
|
620 // if timer has completed |
|
621 if (timerStatus.Int() == KErrNone) |
|
622 { |
|
623 // cancel the operation |
|
624 SendReceive(aCancelMess,TIpcArgs(0,0,0,iSSRef)); |
|
625 } |
|
626 else |
|
627 timer.Cancel(); |
|
628 |
|
629 timer.Close(); |
|
630 |
|
631 return stat.Int(); |
|
632 } |
|
633 |
|
634 // To be used for cancel sync action prematurely |
|
635 TInt CPARAM_MESS_NAMEStep::do_sync_cancel(const TInt aMess, const TInt aCancelMess, const TIpcArgs& aArgs) |
|
636 { |
|
637 |
|
638 TInt result = SendReceive(aMess, aArgs); |
|
639 |
|
640 // Cancel the action immidiately |
|
641 if (result == KErrNone) |
|
642 { |
|
643 // cancel the operation |
|
644 result = SendReceive(aCancelMess,TIpcArgs(0,0,0,iSSRef)); |
|
645 } |
|
646 |
|
647 return result; |
|
648 } |
|
649 // To be used for cancel async action prematurely |
|
650 TInt CPARAM_MESS_NAMEStep::do_async_cancel(const TInt aMess, const TInt aCancelMess, const TIpcArgs& aArgs) |
|
651 { |
|
652 |
|
653 TRequestStatus stat; |
|
654 |
|
655 SendReceive(aMess, aArgs, stat); |
|
656 TInt result = SendReceive(aCancelMess,TIpcArgs(0,0,0,iSSRef)); |
|
657 |
|
658 return result; |
|
659 } |
|
660 |