|
1 /* |
|
2 * Copyright (c) 2004 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 * This class is a BTSapSocketHandler's state for receiving incoming SAP connection |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "BTSapSocketHandler.h" |
|
22 #include "BTSapRequestHandler.h" |
|
23 #include "debug.h" |
|
24 |
|
25 CBTSapSocketHandler::TStateRecv::TStateRecv(RSocket& aSocket, |
|
26 CBTSapRequestHandler& aRequestHandler, |
|
27 CBTSapSniffHandler** aSniffHandler) |
|
28 : TState(aSocket), |
|
29 iRequestHandler(aRequestHandler), |
|
30 iSniffHandler(aSniffHandler) |
|
31 { |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // Enter |
|
36 // --------------------------------------------------------- |
|
37 void CBTSapSocketHandler::TStateRecv:: Enter(TRequestStatus& aStatus) |
|
38 { |
|
39 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Enter"))); |
|
40 |
|
41 // Start the sniffer, which will enter sniff-mode after time-out |
|
42 (*iSniffHandler)->Enable(); |
|
43 |
|
44 iRequestData.SetLength(0); |
|
45 iSocket.RecvOneOrMore(iRequestData, 0, aStatus, iSockXfrLength); |
|
46 } |
|
47 |
|
48 // -------------------------------------------------------------------------------------------- |
|
49 // Complete |
|
50 // set next state |
|
51 // -------------------------------------------------------------------------------------------- |
|
52 // |
|
53 TBTSapSocketState CBTSapSocketHandler::TStateRecv::Complete(TInt /*aReason*/) |
|
54 { |
|
55 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Complete"))); |
|
56 BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] Recv: %S"), &iRequestData)); |
|
57 |
|
58 // We pause the sniffer, to allow time for the response to be sent |
|
59 (*iSniffHandler)->Pause(); |
|
60 |
|
61 iRequestHandler.HandleSapData(iRequestData); |
|
62 return EBTSapSocketStateRecv; |
|
63 } |
|
64 |
|
65 void CBTSapSocketHandler::TStateRecv::Cancel() |
|
66 { |
|
67 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Cancel"))); |
|
68 |
|
69 iSocket.CancelRecv(); |
|
70 } |
|
71 |
|
72 // End of File |