|
1 /* |
|
2 * Copyright (c) 2004-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 * BTSap plugin header definition |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef BT_SAP_PLUGIN_H |
|
21 #define BT_SAP_PLUGIN_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <btengplugin.h> |
|
25 |
|
26 enum TBTSapRejectReason |
|
27 { |
|
28 ERejectGeneralError, |
|
29 ERejectReserved |
|
30 }; |
|
31 |
|
32 enum TBTSapDisconnectType |
|
33 { |
|
34 EDisconnectGraceful, |
|
35 EDisconnectImmediate |
|
36 }; |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class TBTDevAddr; |
|
40 class CBTSapServerState; |
|
41 |
|
42 /* |
|
43 * |
|
44 */ |
|
45 class MSapAsyncObserver |
|
46 { |
|
47 public: |
|
48 enum TOperation |
|
49 { |
|
50 EConnect, |
|
51 ECancelConnect, |
|
52 EDisconnect |
|
53 }; |
|
54 |
|
55 virtual void OperationCompletedL(TOperation aOperation, TInt aError) = 0; |
|
56 }; |
|
57 |
|
58 /* |
|
59 * A class that proveides a utility service for calling |
|
60 * CSapServerState methods asychronously |
|
61 */ |
|
62 class CBTSapAsyncHelper : public CActive |
|
63 { |
|
64 public: |
|
65 static CBTSapAsyncHelper* NewL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver); |
|
66 virtual ~CBTSapAsyncHelper(); |
|
67 |
|
68 void AsyncConnect(const TBTDevAddr& aAddr); |
|
69 void AsyncCancelConnect(const TBTDevAddr& aAddr); |
|
70 void AsyncDisconnect(const TBTDevAddr& aAddr, TBTSapDisconnectType aDiscType); |
|
71 |
|
72 private: |
|
73 void ConstructL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver); |
|
74 CBTSapAsyncHelper(); |
|
75 |
|
76 // From CActive |
|
77 virtual void DoCancel(); |
|
78 virtual void RunL(); |
|
79 |
|
80 private: |
|
81 MSapAsyncObserver::TOperation iOperation; |
|
82 CBTSapServerState* iServerState; |
|
83 MSapAsyncObserver* iObserver; |
|
84 TBTSapDisconnectType iDiscType; |
|
85 }; |
|
86 |
|
87 |
|
88 /** |
|
89 * CBTSapPlugin core class. |
|
90 * Implements the BT Engine ECom interface |
|
91 */ |
|
92 class CBTSapPlugin : public CBTEngPlugin, MSapAsyncObserver |
|
93 { |
|
94 public: // Constructors and destructor |
|
95 |
|
96 /** |
|
97 * Two-phased constructor. |
|
98 */ |
|
99 static CBTSapPlugin* NewL(); |
|
100 |
|
101 /** |
|
102 * Destructor. |
|
103 */ |
|
104 virtual ~CBTSapPlugin(); |
|
105 |
|
106 public: |
|
107 // From CBTEngPlugin (ECom) |
|
108 |
|
109 virtual void GetSupportedProfiles( RProfileArray& aProfiles ); |
|
110 |
|
111 virtual void SetObserver( MBTEngPluginObserver* aObserver ); |
|
112 |
|
113 virtual TBool IsProfileSupported( const TBTProfile aProfile ) const; |
|
114 |
|
115 virtual TInt Connect( const TBTDevAddr& aAddr ); |
|
116 |
|
117 virtual void CancelConnect( const TBTDevAddr& aAddr ); |
|
118 |
|
119 virtual TInt Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ); |
|
120 |
|
121 virtual void GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ); |
|
122 |
|
123 virtual TBTEngConnectionStatus IsConnected( const TBTDevAddr& aAddr ); |
|
124 |
|
125 // From MSapAsyncObserver |
|
126 |
|
127 void OperationCompletedL(MSapAsyncObserver::TOperation aOperation, TInt aError); |
|
128 |
|
129 public: |
|
130 |
|
131 TInt AcceptSapConnection(); |
|
132 |
|
133 TInt RejectSapConnection(TBTSapRejectReason aReason = ERejectGeneralError); |
|
134 |
|
135 TInt DisconnectSapConnection(TBTSapDisconnectType aType = EDisconnectGraceful); |
|
136 |
|
137 TBool IsSapConnected(); |
|
138 |
|
139 TInt GetRemoteBTAddress(TBTDevAddr& aBTDevAddr); |
|
140 |
|
141 void ConnectComplete(); |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * Default constructor |
|
147 */ |
|
148 CBTSapPlugin(); |
|
149 |
|
150 /** |
|
151 * Two-Phase constructor |
|
152 */ |
|
153 void ConstructL(); |
|
154 |
|
155 void StartBTSapServiceL(); |
|
156 |
|
157 void StopBTSapServiceL(); |
|
158 |
|
159 private: // Data |
|
160 |
|
161 enum TBTSapServiceState |
|
162 { |
|
163 EServiceOff, |
|
164 EServiceOn, |
|
165 EServiceShuttingDown |
|
166 }; |
|
167 |
|
168 CBTSapServerState* iBTSapServerState; |
|
169 TBTSapServiceState iServiceState; |
|
170 MBTEngPluginObserver* iObserver; |
|
171 CBTSapAsyncHelper* iAsyncHelper; |
|
172 TBTDevAddr iAddr; |
|
173 }; |
|
174 |
|
175 #endif // BT_SAP_PLUGIN_H |
|
176 // End of File |