|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __SOCKETLISTENER_H__ |
|
20 #define __SOCKETLISTENER_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <es_sock.h> |
|
24 |
|
25 #include <btmanclient.h> |
|
26 |
|
27 class MListenerObserver; |
|
28 |
|
29 /*! |
|
30 This class listens for incoming connection attempts on a BT L2CAP channel |
|
31 */ |
|
32 |
|
33 class CSocketListener : public CActive |
|
34 { |
|
35 public: |
|
36 |
|
37 /*! |
|
38 Create a CSocketListener object |
|
39 @param aSocketServ the socket server session |
|
40 @param aPort port to listen on |
|
41 @param aObserver an observer of this object |
|
42 @result A pointer to the created instance of CSocketListener |
|
43 */ |
|
44 static CSocketListener* NewL(RSocketServ& aSocketServ, TUint aPort, |
|
45 MListenerObserver& aObserver, TBool aAuthorisation); |
|
46 |
|
47 /*! |
|
48 Create a CSocketListener object |
|
49 @param aSocketServ the socket server session |
|
50 @param aPort port to listen on |
|
51 @param aObserver an observer of this object |
|
52 @result A pointer to the created instance of CSocketListener |
|
53 */ |
|
54 static CSocketListener* NewLC(RSocketServ& aSocketServ, TUint aPort, |
|
55 MListenerObserver& aObserver, TBool aAuthorisation); |
|
56 |
|
57 /*! |
|
58 Destroy the object and release all memory objects |
|
59 */ |
|
60 ~CSocketListener(); |
|
61 |
|
62 /*! |
|
63 Accept the next connection into a blank socket |
|
64 @param aSocket blank socket to accept into |
|
65 @return KErrNone if successful, or one of the system-wide error codes. |
|
66 */ |
|
67 TInt AcceptConnection(RSocket& aSocket); |
|
68 |
|
69 protected: |
|
70 // from CActive |
|
71 |
|
72 /*! |
|
73 Cancel any outstanding requests |
|
74 */ |
|
75 void DoCancel(); |
|
76 |
|
77 /*! |
|
78 Respond to an event |
|
79 */ |
|
80 void RunL(); |
|
81 |
|
82 private: |
|
83 |
|
84 /*! |
|
85 Perform the first phase of two phase construction |
|
86 @param aSocketServ the socket server session |
|
87 @param aPort port to listen on |
|
88 @param aObserver an observer of this object |
|
89 */ |
|
90 CSocketListener(RSocketServ& aSocketServ, TUint aPort, |
|
91 MListenerObserver& aObserver, TBool aAuthorisation); |
|
92 |
|
93 /*! |
|
94 Perform the second phase of two phase construction |
|
95 */ |
|
96 void ConstructL(); |
|
97 |
|
98 private: |
|
99 // Member variables |
|
100 |
|
101 /*! The socket server session */ |
|
102 RSocketServ& iSocketServer; |
|
103 |
|
104 /*! Socket port to listen on */ |
|
105 TUint iPort; |
|
106 |
|
107 /*! An observer for status reporting */ |
|
108 MListenerObserver& iObserver; |
|
109 |
|
110 /*! Listening Socket */ |
|
111 RSocket iListeningSocket; |
|
112 |
|
113 /*! The socket to accept into. Not owned */ |
|
114 RSocket* iAcceptSocket; |
|
115 |
|
116 /*! Whether to use authorisation in incoming connections when constructed */ |
|
117 TBool iAuthorisationAskedFlag; |
|
118 |
|
119 }; |
|
120 |
|
121 #endif // __SOCKETLISTENER_H__ |