1 /* |
1 /* |
2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
92 // |
92 // |
93 void CDunBtListen::IssueRequestL() |
93 void CDunBtListen::IssueRequestL() |
94 { |
94 { |
95 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL()" ) )); |
95 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL()" ) )); |
96 |
96 |
97 if ( iListenState == EBtListenStateListening ) |
97 if ( IsActive() ) |
98 { |
98 { |
99 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (already active) complete" ) )); |
99 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (already active) complete" ) )); |
100 User::Leave( KErrNotReady ); |
100 User::Leave( KErrNotReady ); |
101 } |
101 } |
102 |
102 |
139 if ( retTemp != KErrNone ) |
139 if ( retTemp != KErrNone ) |
140 { |
140 { |
141 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (ERROR) complete (%d)" ), retTemp)); |
141 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (ERROR) complete (%d)" ), retTemp)); |
142 User::Leave( retTemp ); |
142 User::Leave( retTemp ); |
143 } |
143 } |
144 iStatus = KRequestPending; |
|
145 iListenState = EBtListenStateListening; |
|
146 iListenSocket.Accept( iEntity.iBTPort, iStatus ); |
144 iListenSocket.Accept( iEntity.iBTPort, iStatus ); |
147 SetActive(); |
145 SetActive(); |
148 |
146 |
149 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() complete") )); |
147 FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() complete") )); |
150 } |
148 } |
151 |
149 |
152 // --------------------------------------------------------------------------- |
150 // --------------------------------------------------------------------------- |
153 // Stops listening |
151 // Stops listening |
154 // --------------------------------------------------------------------------- |
152 // --------------------------------------------------------------------------- |
155 // |
153 // |
156 TInt CDunBtListen::Stop() |
154 void CDunBtListen::Stop() |
157 { |
155 { |
158 FTRACE(FPrint( _L( "CDunBtListen::Stop()") )); |
156 FTRACE(FPrint( _L( "CDunBtListen::Stop()") )); |
159 if ( iListenState != EBtListenStateListening ) |
|
160 { |
|
161 FTRACE(FPrint( _L("CDunBtListen::Stop() (not ready) complete" ))); |
|
162 return KErrNotReady; |
|
163 } |
|
164 iListenSocket.CancelAccept(); |
|
165 Cancel(); |
157 Cancel(); |
166 iListenState = EBtListenStateIdle; |
|
167 FTRACE(FPrint( _L( "CDunBtListen::Stop() complete") )); |
158 FTRACE(FPrint( _L( "CDunBtListen::Stop() complete") )); |
168 return KErrNone; |
|
169 } |
159 } |
170 |
160 |
171 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
172 // CDunBtListen::CDunBtListen |
162 // CDunBtListen::CDunBtListen |
173 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
220 { |
210 { |
221 // Don't initialize iServer here (it is set through NewL) |
211 // Don't initialize iServer here (it is set through NewL) |
222 // Don't initialize iParent here (it is set through NewL) |
212 // Don't initialize iParent here (it is set through NewL) |
223 // Don't initialize iTransporter here (it is set through NewL) |
213 // Don't initialize iTransporter here (it is set through NewL) |
224 // Don't initialize iEntity here (it is set through NewL) |
214 // Don't initialize iEntity here (it is set through NewL) |
225 iListenState = EBtListenStateIdle; |
|
226 iDiscovery = NULL; |
215 iDiscovery = NULL; |
227 iChannelNum = 0; |
216 iChannelNum = 0; |
228 iSDPHandleDun = 0; |
217 iSDPHandleDun = 0; |
229 } |
218 } |
230 |
219 |
392 // --------------------------------------------------------------------------- |
381 // --------------------------------------------------------------------------- |
393 // |
382 // |
394 void CDunBtListen::RunL() |
383 void CDunBtListen::RunL() |
395 { |
384 { |
396 FTRACE(FPrint( _L( "CDunBtListen::RunL()" ) )); |
385 FTRACE(FPrint( _L( "CDunBtListen::RunL()" ) )); |
397 iListenState = EBtListenStateIdle; |
|
398 |
386 |
399 StopServiceAdvertisement(); |
387 StopServiceAdvertisement(); |
400 |
388 |
401 TInt retTemp = iStatus.Int(); |
389 TInt retTemp = iStatus.Int(); |
402 if ( retTemp != KErrNone ) |
390 if ( retTemp != KErrNone ) |
430 // Cancel current activity. |
418 // Cancel current activity. |
431 // --------------------------------------------------------------------------- |
419 // --------------------------------------------------------------------------- |
432 // |
420 // |
433 void CDunBtListen::DoCancel() |
421 void CDunBtListen::DoCancel() |
434 { |
422 { |
|
423 FTRACE(FPrint( _L( "CDunBtListen::DoCancel()" ) )); |
|
424 iListenSocket.CancelAccept(); |
|
425 FTRACE(FPrint( _L( "CDunBtListen::DoCancel() complete" ) )); |
435 } |
426 } |
436 |
427 |
437 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
438 // From class MDunServAdvMon. |
429 // From class MDunServAdvMon. |
439 // Gets called when advertisement status changes to start. |
430 // Gets called when advertisement status changes to start. |