|
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: Declares main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __BTHIDSESSION_H__ |
|
20 #define __BTHIDSESSION_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "hidsdpobserver.h" |
|
24 #include "bthidclient.h" |
|
25 |
|
26 class CBTHidServer; |
|
27 class CHidSdpClient; |
|
28 |
|
29 /*! |
|
30 An instance of class CBTHidServerSession is created for each client |
|
31 */ |
|
32 class CBTHidServerSession : public CSession2, public MHidSdpObserver |
|
33 { |
|
34 |
|
35 public: |
|
36 |
|
37 /*! |
|
38 Create a CBTHidServerSession object using two phase construction, |
|
39 and return a pointer to the created object. |
|
40 @param aClient client's thread. |
|
41 @param aServer the server. |
|
42 @result Pointer to new session. |
|
43 */ |
|
44 static CBTHidServerSession* NewL(CBTHidServer& aServer); |
|
45 |
|
46 /*! |
|
47 Create a CBTHidServerSession object using two phase construction, |
|
48 and return a pointer to the created object |
|
49 (leaving a pointer to the object on the cleanup stack) |
|
50 @param aClient client's thread |
|
51 @param aServer the server |
|
52 @result Pointer to new session |
|
53 */ |
|
54 static CBTHidServerSession* NewLC(CBTHidServer& aServer); |
|
55 |
|
56 /*! |
|
57 Destroy the object and release all memory objects |
|
58 */ |
|
59 ~CBTHidServerSession(); |
|
60 |
|
61 /*! |
|
62 Updates the client of this session with the new status of a |
|
63 connection, if it has an outstanding update request. |
|
64 @param aUpdateParams details of the bluetooth device that has changed. |
|
65 */ |
|
66 void InformStatusChange(const THIDStateUpdateBuf& aUpdateParams); |
|
67 /*! |
|
68 Informs the session of the result of a first-time connection. |
|
69 @param aConnID id given to the connection when it was created |
|
70 @param aResult result of the connection attempt |
|
71 */ |
|
72 void InformConnectionResult(TInt aConnID, TInt aResult); |
|
73 |
|
74 public: |
|
75 // from CSession |
|
76 /*! |
|
77 Service request from client |
|
78 @param aMessage client message (containing requested operation and any data) |
|
79 */ |
|
80 void ServiceL(const RMessage2& aMessage); |
|
81 |
|
82 public: |
|
83 // from MHidSdpObserver |
|
84 |
|
85 void HidSdpSearchComplete(TInt aResult); |
|
86 |
|
87 private: |
|
88 |
|
89 /*! |
|
90 Perform the first phase of two phase construction |
|
91 @param aClient client's thread |
|
92 */ |
|
93 CBTHidServerSession(CBTHidServer& aServer); |
|
94 |
|
95 /*! |
|
96 Perform the second phase construction of a CBTHidServerSession object |
|
97 */ |
|
98 void ConstructL(); |
|
99 |
|
100 void DispatchMessageL(const RMessage2& aMessage); |
|
101 |
|
102 /*! |
|
103 Handle the connection message. |
|
104 @param aMessage message for request |
|
105 */ |
|
106 void RequestConnectionL(const RMessage2& aMessage); |
|
107 |
|
108 /*! |
|
109 Handle the disconnection message. |
|
110 @param aMessage message for request |
|
111 */ |
|
112 void RequestDisconnectionL(const RMessage2& aMessage); |
|
113 |
|
114 void IsConnectedL(const RMessage2& aMessage); |
|
115 |
|
116 void GetConnections(const RMessage2& aMessage); |
|
117 |
|
118 private: |
|
119 // Member variables |
|
120 |
|
121 /*! The hid server */ |
|
122 CBTHidServer& iServer; |
|
123 |
|
124 /*! ID of the connection being established */ |
|
125 TInt iConnectingID; |
|
126 |
|
127 /*! A hid sdp client */ |
|
128 CHidSdpClient* iHidSdpClient; |
|
129 |
|
130 TBool iSearchingSDP; |
|
131 |
|
132 /*! An outstanding connect message */ |
|
133 RMessage2 iConnectionMessage; |
|
134 |
|
135 RMessagePtr2 iDisconnectMsg; |
|
136 |
|
137 /*! Session has an outstanding update message */ |
|
138 RMessage2 iUpdateMessage; |
|
139 |
|
140 }; |
|
141 |
|
142 #endif |