|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implementation of RWsfSession |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "wsfsession.h" |
|
22 |
|
23 // INTERNAL INCLUDES |
|
24 #include "wsfwlaninfoarray.h" |
|
25 #include "wsfeventhandler.h" |
|
26 #include "wsfactivewaiter.h" |
|
27 #include "wsfservercommon.h" |
|
28 #include "wsflogger.h" |
|
29 |
|
30 |
|
31 |
|
32 // LOCAL DEFINITIONS |
|
33 /** |
|
34 * Number of message slots at the server |
|
35 */ |
|
36 static const TInt KIPCSlots = 6; |
|
37 |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // RWsfSession::RWsfSession |
|
42 // --------------------------------------------------------------------------- |
|
43 EXPORT_C RWsfSession::RWsfSession(): |
|
44 RSessionBase(), |
|
45 iEventHandler( 0 ), |
|
46 iConnectingResult( KErrNone ) |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // RWsfSession::StartServer |
|
53 // --------------------------------------------------------------------------- |
|
54 TInt RWsfSession::StartServer() |
|
55 { |
|
56 LOG_ENTERFN( "RWsfSession::StartServerL" ); |
|
57 |
|
58 TInt res( KErrNone ); |
|
59 // create server - if one of this name does not already exist |
|
60 TFindServer findServer( KWlanSnifferServerName ); |
|
61 TFullName name; |
|
62 |
|
63 if ( findServer.Next( name ) != KErrNone ) // we don't exist already |
|
64 { |
|
65 RProcess server; |
|
66 // Create the server process |
|
67 res = server.Create( KWlanSnifferServerExe, KNullDesC ); |
|
68 |
|
69 if ( res != KErrNone ) // thread created ok - now start it going |
|
70 { |
|
71 return res; |
|
72 } |
|
73 |
|
74 // Rendezvous is used to detect server start |
|
75 TRequestStatus status; |
|
76 server.Rendezvous( status ); |
|
77 |
|
78 if ( status != KRequestPending ) |
|
79 { |
|
80 LOG_WRITEF( "StartServer Rendezvous ERROR: %d", status.Int() ); |
|
81 server.Kill( 0 ); // abort startup |
|
82 } |
|
83 else |
|
84 { |
|
85 server.Resume(); // logon OK - start the server |
|
86 } |
|
87 |
|
88 LOG_WRITE( "StartServer wait for start" ); |
|
89 User::WaitForRequest( status ); // wait for start or death |
|
90 |
|
91 // We can't use the 'exit reason' if the server paniced as this |
|
92 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
93 // from KErrNone |
|
94 res = ( server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int(); |
|
95 |
|
96 // we're no longer interested in the other process |
|
97 server.Close(); |
|
98 } |
|
99 |
|
100 return res; |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // RWsfSession::Connect |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C TInt RWsfSession::Connect() |
|
109 { |
|
110 LOG_ENTERFN( "RWsfSession::Connect" ); |
|
111 TInt err = StartServer(); |
|
112 |
|
113 if ( err == KErrNone ) |
|
114 { |
|
115 LOG_WRITE( "server started" ); |
|
116 |
|
117 err = CreateSession( KWlanSnifferServerName, Version(), KIPCSlots ); |
|
118 |
|
119 LOG_WRITEF( "CreateSession() returned %d", err ); |
|
120 |
|
121 if ( err == KErrNone ) |
|
122 { |
|
123 TRAP( err, iConnWaiter = new (ELeave) CActiveSchedulerWait() ); |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 LOG_WRITEF( "server starting failed with error %d", err ); |
|
129 } |
|
130 |
|
131 return err; |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // RWsfSession::Version |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 TVersion RWsfSession::Version() const |
|
140 { |
|
141 return TVersion( KWlanSnifferServerMajor, |
|
142 KWlanSnifferServerMinor, |
|
143 KWlanSnifferServerBuild ); |
|
144 } |
|
145 |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // RWsfSession::CancelNotifyEvent |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void RWsfSession::CancelNotifyEvent() |
|
152 { |
|
153 LOG_ENTERFN( "RWsfSession::CancelNotifyEvent" ); |
|
154 if ( iEventHandler ) |
|
155 { |
|
156 iEventHandler->Cancel(); |
|
157 } |
|
158 } |
|
159 |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // RWsfSession::ConnectedAccountNameL |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C HBufC* RWsfSession::ConnectedAccountNameL() |
|
166 { |
|
167 LOG_ENTERFN("RWsfSession::ConnectedAccountNameL"); |
|
168 TPckgBuf<TWsfQueryConnectedAccount> package; |
|
169 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
170 CleanupStack::PushL( waiter ); |
|
171 SendReceive( ESnifferCmdConnectionName, TIpcArgs( &package ), |
|
172 waiter->iStatus ); |
|
173 waiter->WaitForRequest(); |
|
174 LOG_WRITEF( "message[%d] call returned %d", |
|
175 ESnifferCmdConnectionName, |
|
176 waiter->iStatus.Int() ); |
|
177 User::LeaveIfError( waiter->iStatus.Int() ); |
|
178 CleanupStack::PopAndDestroy( waiter ); |
|
179 |
|
180 if ( package().iConnected ) |
|
181 { |
|
182 return package().iConnectedAccountName.AllocL(); |
|
183 } |
|
184 return KNullDesC().AllocL(); |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // RWsfSession::GetConnectedWlanDetailsL |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C TBool RWsfSession::GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo ) |
|
193 { |
|
194 LOG_ENTERFN("RWsfSession::GetConnectedWlanDetailsL"); |
|
195 TPckgBuf<TBool> ret( EFalse ); |
|
196 TPckg<TWsfWlanInfo> package( aWlanInfo ); |
|
197 |
|
198 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
199 CleanupStack::PushL( waiter ); |
|
200 |
|
201 SendReceive( ESnifferCmdConnectedDetails, TIpcArgs( &ret, &package ), |
|
202 waiter->iStatus ); |
|
203 waiter->WaitForRequest(); |
|
204 LOG_WRITEF( "message[%d] call returned %d", |
|
205 ESnifferCmdConnectedDetails, |
|
206 waiter->iStatus.Int() ); |
|
207 User::LeaveIfError( waiter->iStatus.Int() ); |
|
208 CleanupStack::PopAndDestroy( waiter ); |
|
209 |
|
210 return ret(); |
|
211 } |
|
212 |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // RWsfSession::NotifyEventL |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 EXPORT_C void RWsfSession::NotifyEventL( MWsfStateChangeObserver& aObserver ) |
|
219 { |
|
220 LOG_ENTERFN("RWsfSession::NotifyEventL"); |
|
221 if ( !iEventHandler ) |
|
222 { |
|
223 iEventHandler = CWsfEventHandler::NewL( *this, aObserver ); |
|
224 } |
|
225 iEventHandler->ResetObserver( aObserver ); |
|
226 if ( !iEventHandler->IsActive() ) |
|
227 { |
|
228 iEventHandler->Start(); |
|
229 SendReceive( ESnifferCmdNotifyEvents, |
|
230 TIpcArgs( &iEventHandler->EventContainer() ), |
|
231 iEventHandler->iStatus ); |
|
232 } |
|
233 } |
|
234 |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // RWsfSession::EnableScanL |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C TBool RWsfSession::EnableScanL() |
|
241 { |
|
242 LOG_ENTERFN("RWsfSession::EnableScanL"); |
|
243 |
|
244 TInt err = Send( ESnifferCmdActivateScan ); |
|
245 LOG_WRITEF( "message[%d] call returned %d", ESnifferCmdActivateScan, err ); |
|
246 |
|
247 User::LeaveIfError( err ); |
|
248 |
|
249 return !err; |
|
250 } |
|
251 |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // RWsfSession::DisableScanL |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 EXPORT_C TBool RWsfSession::DisableScanL() |
|
258 { |
|
259 LOG_ENTERFN("RWsfSession::DisableScanL"); |
|
260 |
|
261 TInt err = Send( ESnifferCmdDisableScan ); |
|
262 LOG_WRITEF( "message[%d] call returned %d", ESnifferCmdDisableScan, err ); |
|
263 |
|
264 User::LeaveIfError( err ); |
|
265 |
|
266 return !err; |
|
267 } |
|
268 |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // RWsfSession::IsScanEnabledL |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 EXPORT_C TBool RWsfSession::IsScanEnabledL() |
|
275 { |
|
276 LOG_ENTERFN("RWsfSession::IsScanEnabledL"); |
|
277 TBool res = 0; |
|
278 TPckgBuf<TInt> pckg; |
|
279 |
|
280 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
281 CleanupStack::PushL( waiter ); |
|
282 |
|
283 SendReceive( ESnifferCmdIsScanEnabled, TIpcArgs( &pckg ), |
|
284 waiter->iStatus ); |
|
285 waiter->WaitForRequest(); |
|
286 LOG_WRITEF( "message[%d] call returned %d", |
|
287 ESnifferCmdIsScanEnabled, |
|
288 waiter->iStatus.Int() ); |
|
289 User::LeaveIfError( waiter->iStatus.Int() ); |
|
290 CleanupStack::PopAndDestroy( waiter ); |
|
291 |
|
292 res = pckg(); |
|
293 return res; |
|
294 } |
|
295 |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // RWsfSession::UpdateWlanListL |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 EXPORT_C void RWsfSession::UpdateWlanListL( CWsfWlanInfoArray* aInfoArray ) |
|
302 { |
|
303 LOG_ENTERFN("RWsfSession::UpdateWlanListL"); |
|
304 // first request the buffer size for wlan data... |
|
305 TPckgBuf<TUint> pckg; |
|
306 TUint infoArrayElementCount = aInfoArray->Count(); |
|
307 |
|
308 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
309 CleanupStack::PushL( waiter ); |
|
310 |
|
311 SendReceive( ESnifferCmdWlanDataSize, TIpcArgs( &pckg ), waiter->iStatus ); |
|
312 waiter->WaitForRequest(); |
|
313 LOG_WRITEF( "message[%d] call returned %d", |
|
314 ESnifferCmdWlanDataSize, |
|
315 waiter->iStatus.Int() ); |
|
316 User::LeaveIfError( waiter->iStatus.Int() ); |
|
317 |
|
318 // alloc the required size buffer... |
|
319 TInt requiredSize = pckg(); |
|
320 LOG_WRITEF( "WLAN data buffer size = %d", requiredSize ); |
|
321 |
|
322 if ( !requiredSize ) |
|
323 { |
|
324 // no data ... |
|
325 CleanupStack::PopAndDestroy( waiter ); |
|
326 return; |
|
327 } |
|
328 |
|
329 HBufC8* buffer = HBufC8::NewLC( requiredSize ); |
|
330 TPtr8 ptr = buffer->Des(); |
|
331 |
|
332 SendReceive( ESnifferCmdGetWlanInfo, TIpcArgs( &pckg, &ptr ), |
|
333 waiter->iStatus ); |
|
334 waiter->WaitForRequest(); |
|
335 LOG_WRITEF( "message[%d] call returned %d", |
|
336 ESnifferCmdGetWlanInfo, |
|
337 waiter->iStatus.Int() ); |
|
338 User::LeaveIfError( waiter->iStatus.Int() ); |
|
339 |
|
340 |
|
341 LOG_WRITEF( "actual bytes occupied = %d", pckg() ); |
|
342 |
|
343 if ( requiredSize != pckg() ) |
|
344 { |
|
345 // the buffer is not long enough... we must try again... |
|
346 User::Leave( KErrOverflow ); |
|
347 } |
|
348 |
|
349 // Check that aInfoArray has not been modified |
|
350 // while we waited server response |
|
351 if ( aInfoArray->Count() != infoArrayElementCount ) |
|
352 { |
|
353 LOG_WRITEF( "aInfoArray data has changed %d != %d ", |
|
354 aInfoArray->Count(), infoArrayElementCount ); |
|
355 aInfoArray->Reset(); |
|
356 } |
|
357 |
|
358 aInfoArray->AppendFromStreamBufferL( ptr ); |
|
359 CleanupStack::PopAndDestroy( buffer ); |
|
360 CleanupStack::PopAndDestroy( waiter ); |
|
361 } |
|
362 |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // RWsfSession::MonitorAccessPointL |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 EXPORT_C void RWsfSession::MonitorAccessPointL( TUint32 aMonitoredIap ) |
|
369 { |
|
370 LOG_ENTERFN("RWsfSession::MonitorAccessPointL"); |
|
371 |
|
372 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
373 CleanupStack::PushL( waiter ); |
|
374 |
|
375 SendReceive( ESnifferCmdMonitorAp, TIpcArgs( aMonitoredIap ), |
|
376 waiter->iStatus ); |
|
377 waiter->WaitForRequest(); |
|
378 LOG_WRITEF( "message[%d] call returned %d", |
|
379 ESnifferCmdMonitorAp, |
|
380 waiter->iStatus.Int() ); |
|
381 User::LeaveIfError( waiter->iStatus.Int() ); |
|
382 |
|
383 CleanupStack::PopAndDestroy( waiter ); |
|
384 } |
|
385 |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // RWsfSession::RequestScanL |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 EXPORT_C TBool RWsfSession::RequestScanL() |
|
392 { |
|
393 LOG_ENTERFN("RWsfSession::RequestScanL"); |
|
394 TPckgBuf<TBool> pckg; |
|
395 |
|
396 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
397 CleanupStack::PushL( waiter ); |
|
398 |
|
399 SendReceive( ESnifferCmdRequestScan, TIpcArgs( &pckg ), waiter->iStatus ); |
|
400 waiter->WaitForRequest(); |
|
401 LOG_WRITEF( "message[%d] call returned %d", |
|
402 ESnifferCmdRequestScan, |
|
403 waiter->iStatus.Int() ); |
|
404 User::LeaveIfError( waiter->iStatus.Int() ); |
|
405 CleanupStack::PopAndDestroy( waiter ); |
|
406 return pckg(); |
|
407 } |
|
408 |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // RWsfSession::ConnectWlanBearerL |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 EXPORT_C TInt RWsfSession::ConnectWlanBearerL( TUint32 aIapId, |
|
415 TWsfIapPersistence aPersistence ) |
|
416 { |
|
417 LOG_ENTERFN( "RWsfSession::ConnectWlanBearerL" ); |
|
418 LOG_WRITEF( "IAP id = %d", aIapId ); |
|
419 |
|
420 // mark the beginning of the connection process |
|
421 iEventHandler->SetConnecting( ETrue ); |
|
422 |
|
423 TInt res( KErrNone ); |
|
424 TPckgBuf<TInt> pckg; |
|
425 |
|
426 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
427 CleanupStack::PushL( waiter ); |
|
428 |
|
429 SendReceive( ESnifferCmdConnect, TIpcArgs( &pckg, aIapId, aPersistence ), |
|
430 waiter->iStatus ); |
|
431 waiter->WaitForRequest(); |
|
432 LOG_WRITEF( "message[%d] call returned %d", |
|
433 ESnifferCmdConnect, |
|
434 waiter->iStatus.Int() ); |
|
435 User::LeaveIfError( waiter->iStatus.Int() ); |
|
436 CleanupStack::PopAndDestroy( waiter ); |
|
437 |
|
438 res = pckg(); |
|
439 |
|
440 if ( res != KErrNone ) |
|
441 { |
|
442 // on any error the flag should be cleared |
|
443 iEventHandler->SetConnecting( EFalse ); |
|
444 } |
|
445 else |
|
446 { |
|
447 // otherwise we must wait until the connected signal arrives |
|
448 iConnWaiter->Start(); |
|
449 } |
|
450 |
|
451 if ( iConnectingResult ) |
|
452 { |
|
453 // the caller must know if the connecting process was cancelled |
|
454 res = iConnectingResult; |
|
455 iConnectingResult = KErrNone; |
|
456 } |
|
457 |
|
458 return res; |
|
459 } |
|
460 |
|
461 |
|
462 // --------------------------------------------------------------------------- |
|
463 // RWsfSession::ConnectWlanBearerWithoutConnWaiterL |
|
464 // --------------------------------------------------------------------------- |
|
465 // |
|
466 EXPORT_C TInt RWsfSession::ConnectWlanBearerWithoutConnWaiterL( TUint32 aIapId, |
|
467 TWsfIapPersistence aPersistence ) |
|
468 { |
|
469 LOG_ENTERFN( "RWsfSession::ConnectWlanBearerWithoutConnWaiterL" ); |
|
470 LOG_WRITEF( "IAP id = %d", aIapId ); |
|
471 |
|
472 // mark the beginning of the connection process |
|
473 iEventHandler->SetConnecting( ETrue ); |
|
474 |
|
475 TInt res( KErrNone ); |
|
476 TPckgBuf<TInt> pckg; |
|
477 |
|
478 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
479 CleanupStack::PushL( waiter ); |
|
480 |
|
481 SendReceive( ESnifferCmdConnect, TIpcArgs( &pckg, aIapId, aPersistence ), |
|
482 waiter->iStatus ); |
|
483 waiter->WaitForRequest(); |
|
484 LOG_WRITEF( "message[%d] call returned %d", |
|
485 ESnifferCmdConnect, |
|
486 waiter->iStatus.Int() ); |
|
487 User::LeaveIfError( waiter->iStatus.Int() ); |
|
488 CleanupStack::PopAndDestroy( waiter ); |
|
489 |
|
490 res = pckg(); |
|
491 |
|
492 if ( res != KErrNone ) |
|
493 { |
|
494 // on any error the flag should be cleared |
|
495 iEventHandler->SetConnecting( EFalse ); |
|
496 } |
|
497 |
|
498 return res; |
|
499 } |
|
500 |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // RWsfSession::StopConnectingWait |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 void RWsfSession::StopConnectingWait() |
|
507 { |
|
508 LOG_ENTERFN( "RWsfSession::StopConnectingWait" ); |
|
509 if ( iConnWaiter->IsStarted() ) |
|
510 { |
|
511 iConnWaiter->AsyncStop(); |
|
512 } |
|
513 } |
|
514 |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // RWsfSession::DisconnectWlanBearerL |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 EXPORT_C TBool RWsfSession::DisconnectWlanBearerL() |
|
521 { |
|
522 LOG_ENTERFN("RWsfSession::DisconnectWlanBearerL"); |
|
523 TBool res = 0; |
|
524 TPckgBuf<TInt> pckg; |
|
525 |
|
526 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
527 CleanupStack::PushL( waiter ); |
|
528 |
|
529 SendReceive( ESnifferCmdDisconnect, TIpcArgs( &pckg ), waiter->iStatus ); |
|
530 waiter->WaitForRequest(); |
|
531 LOG_WRITEF( "message[%d] call returned %d", |
|
532 ESnifferCmdDisconnect, |
|
533 waiter->iStatus.Int() ); |
|
534 User::LeaveIfError( waiter->iStatus.Int() ); |
|
535 |
|
536 CleanupStack::PopAndDestroy( waiter ); |
|
537 |
|
538 res = pckg(); |
|
539 return res; |
|
540 } |
|
541 |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // RWsfSession::Close |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 EXPORT_C void RWsfSession::Close() |
|
548 { |
|
549 LOG_ENTERFN("RWsfSession::Close"); |
|
550 delete iEventHandler; iEventHandler = NULL; |
|
551 delete iConnWaiter; iConnWaiter = NULL; |
|
552 |
|
553 RSessionBase::Close(); |
|
554 } |
|
555 |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // RWsfSession::DoCancelNotifyEvent |
|
559 // --------------------------------------------------------------------------- |
|
560 // |
|
561 void RWsfSession::DoCancelNotifyEvent() |
|
562 { |
|
563 LOG_ENTERFN("RWsfSession::DoCancelNotifyEvent"); |
|
564 // used only by CWsfEventHandler |
|
565 TInt err = Send( ESnifferCmdCancelNotifyEvents ); |
|
566 LOG_WRITEF( "message[%d] call returned %d", |
|
567 ESnifferCmdCancelNotifyEvents, err ); |
|
568 } |
|
569 |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // RWsfSession::CancelAll |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 void RWsfSession::CancelAll() |
|
576 { |
|
577 LOG_ENTERFN("RWsfSession::CancelAll"); |
|
578 TInt err = Send( ESnifferCmdCancelAll ); |
|
579 |
|
580 LOG_WRITEF( "message[%d] call returned %d", ESnifferCmdCancelAll, err ); |
|
581 } |
|
582 |
|
583 |
|
584 // --------------------------------------------------------------------------- |
|
585 // RWsfSession::IsConnectedL |
|
586 // --------------------------------------------------------------------------- |
|
587 // |
|
588 EXPORT_C TBool RWsfSession::IsConnectedL() |
|
589 { |
|
590 LOG_ENTERFN("RWsfSession::IsConnectedL"); |
|
591 TPckgBuf<TBool> pckg; |
|
592 |
|
593 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
594 CleanupStack::PushL( waiter ); |
|
595 |
|
596 SendReceive( ESnifferCmdIsConnected, TIpcArgs( &pckg ), waiter->iStatus ); |
|
597 waiter->WaitForRequest(); |
|
598 LOG_WRITEF( "message[%d] call returned %d", |
|
599 ESnifferCmdIsConnected, |
|
600 waiter->iStatus.Int() ); |
|
601 User::LeaveIfError( waiter->iStatus.Int() ); |
|
602 CleanupStack::PopAndDestroy( waiter ); |
|
603 |
|
604 return pckg(); |
|
605 } |
|
606 |
|
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // RWsfSession::RecoverFromServerTermination |
|
610 // --------------------------------------------------------------------------- |
|
611 // |
|
612 TBool RWsfSession::RecoverFromServerTermination( |
|
613 MWsfStateChangeObserver& aObserver ) |
|
614 { |
|
615 RSessionBase::Close(); |
|
616 |
|
617 TBool ret( EFalse ); |
|
618 |
|
619 ret = ( Connect() == KErrNone ); |
|
620 if ( ret ) |
|
621 { |
|
622 TRAPD( err, NotifyEventL( aObserver ) ); |
|
623 ret = ( err == KErrNone ); |
|
624 } |
|
625 |
|
626 return ret; |
|
627 } |
|
628 |
|
629 |
|
630 // --------------------------------------------------------------------------- |
|
631 // RWsfSession::AbortConnectingL |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 EXPORT_C void RWsfSession::AbortConnectingL() |
|
635 { |
|
636 LOG_ENTERFN("RWsfSession::AbortConnectingL"); |
|
637 |
|
638 if ( iEventHandler->Connecting() ) |
|
639 { |
|
640 iConnectingResult = KErrCancel; |
|
641 iEventHandler->BlockNextConnectedEvent(); |
|
642 |
|
643 TInt err = Send( ESnifferCmdAbortConnecting ); |
|
644 LOG_WRITEF( "message[%d] call returned %d", |
|
645 ESnifferCmdAbortConnecting, err ); |
|
646 |
|
647 User::LeaveIfError( err ); |
|
648 StopConnectingWait(); |
|
649 } |
|
650 |
|
651 } |
|
652 |
|
653 |
|
654 // --------------------------------------------------------------------------- |
|
655 // RWsfSession::AbortScanningL |
|
656 // --------------------------------------------------------------------------- |
|
657 // |
|
658 EXPORT_C void RWsfSession::AbortScanningL() |
|
659 { |
|
660 LOG_ENTERFN("RWsfSession::AbortScanningL"); |
|
661 |
|
662 TInt err = Send( ESnifferCmdAbortScanning ); |
|
663 LOG_WRITEF( "message[%d] call returned %d", |
|
664 ESnifferCmdAbortScanning, err ); |
|
665 |
|
666 User::LeaveIfError( err ); |
|
667 } |
|
668 |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // RWsfSession::SetIapPersistenceL |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 EXPORT_C TBool RWsfSession::SetIapPersistenceL( |
|
675 TWsfIapPersistence aPersistence ) |
|
676 { |
|
677 LOG_ENTERFN("RWsfSession::SetIapPersistenceL"); |
|
678 TPckgBuf<TBool> ret( EFalse ); |
|
679 |
|
680 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
681 CleanupStack::PushL( waiter ); |
|
682 |
|
683 SendReceive( ESnifferCmdSetIapPersistence, TIpcArgs( &ret, aPersistence ), |
|
684 waiter->iStatus ); |
|
685 waiter->WaitForRequest(); |
|
686 LOG_WRITEF( "message[%d] call returned %d", |
|
687 ESnifferCmdSetIapPersistence, |
|
688 waiter->iStatus.Int() ); |
|
689 User::LeaveIfError( waiter->iStatus.Int() ); |
|
690 CleanupStack::PopAndDestroy( waiter ); |
|
691 |
|
692 return ret(); |
|
693 } |
|
694 |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // RWsfSession::ControlDisconnectTimerL |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 EXPORT_C TBool RWsfSession::ControlDisconnectTimerL( TUint aAdcCommand ) |
|
701 { |
|
702 LOG_ENTERFN("RWsfSession::ControlDisconnectTimerL"); |
|
703 |
|
704 TPckgBuf<TBool> ret( EFalse ); |
|
705 |
|
706 CWsfActiveWaiter *waiter = CWsfActiveWaiter::NewL(); |
|
707 CleanupStack::PushL( waiter ); |
|
708 |
|
709 SendReceive( ESnifferCmdControlDisconnectTimer, |
|
710 TIpcArgs( &ret, aAdcCommand ), |
|
711 waiter->iStatus ); |
|
712 |
|
713 waiter->WaitForRequest(); |
|
714 LOG_WRITEF( "message[%d] call returned %d", |
|
715 ESnifferCmdControlDisconnectTimer, |
|
716 waiter->iStatus.Int() ); |
|
717 User::LeaveIfError( waiter->iStatus.Int() ); |
|
718 CleanupStack::PopAndDestroy( waiter ); |
|
719 |
|
720 return ret(); |
|
721 } |
|
722 |
|
723 |