|
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 DISCOVERYAGENT_H |
|
20 #define DISCOVERYAGENT_H |
|
21 |
|
22 #include "bluetoothfunctionserver.h" |
|
23 #include "bluetoothdevicediscoverer.h" |
|
24 #include "bluetoothplatformcontrol.h" |
|
25 #include "bluetoothnamelookup.h" |
|
26 #include "javajniutils.h" |
|
27 #include "monitor.h" |
|
28 #include "bluetoothstructs.h" |
|
29 |
|
30 #include "bluetoothservicesearcher.h" |
|
31 |
|
32 namespace java |
|
33 { |
|
34 namespace bluetooth |
|
35 { |
|
36 |
|
37 class BluetoothDeviceDiscoverer; |
|
38 class BluetoothNameLookup; |
|
39 class BluetoothServiceSearcher; |
|
40 |
|
41 #define SOCKETSERVER_CONNECTED 0 |
|
42 #define SOCKETSERVER_DISCONNECTED -1 |
|
43 |
|
44 class DiscoveryAgent |
|
45 { |
|
46 public: |
|
47 // |
|
48 // Methods related to Discovery Agent |
|
49 // |
|
50 DiscoveryAgent(BluetoothFunctionServer* aServer); |
|
51 |
|
52 ~DiscoveryAgent(); |
|
53 |
|
54 // |
|
55 // Methods related to Device Inquiry |
|
56 // |
|
57 int startDeviceDiscovery(JNIEnv* aJni, jobject& aPeer, int aAccessCode); |
|
58 |
|
59 int getNextDevice(DiscoveredDevice &aDiscoveredDevice); |
|
60 |
|
61 int doDeviceDiscoveryCallback(JNIEnv* aJni, jobject& aPeer, |
|
62 DiscoveredDevice &aDiscoveredDevice); |
|
63 |
|
64 void deviceDiscoveryCompleted(int aStatus); |
|
65 |
|
66 bool cancelDeviceDiscovery(); |
|
67 |
|
68 void deviceDiscovered(std::wstring* deviceAddr, std::wstring* deviceName, |
|
69 int deviceClass); |
|
70 |
|
71 // |
|
72 // Methods related to Name Lookup |
|
73 // |
|
74 std::wstring* lookupFriendlyNameL(long long devAddr); |
|
75 |
|
76 // Service Search Methods |
|
77 int StartSearchServices(JNIEnv* aJni, jobject& aPeer, |
|
78 TInt64 aRemoteAddress, TPtrC8 aUuidsDes, TPtrC16 aAttrIdsDes, |
|
79 java::util::Monitor* aMonitor); |
|
80 |
|
81 void ServiceSearchCompleted(int aStatus); |
|
82 |
|
83 bool CancelServiceSearch(); |
|
84 |
|
85 int getStatusOfCompletion(); |
|
86 |
|
87 int PopulateServiceRecordAttrValue(JNIEnv* aJni, jobject& aPeer, |
|
88 TInt64 aRemoteAddress, long aHandle, TPtrC16 aAttrIdsDes, |
|
89 jobject aServiceRecordImpl, java::util::Monitor* aMonitor); |
|
90 |
|
91 void PopulateRecordCompleted(int aStatus); |
|
92 |
|
93 int GetPopulateServiceRecordStatus(); |
|
94 |
|
95 bool CancelPopulateServiceRecordAttrValue(); |
|
96 |
|
97 private: |
|
98 // Discovery Agent Methods |
|
99 void cleanup(); |
|
100 |
|
101 // Device discovery Methods |
|
102 void discoverDevicesFsL(int aAccessCode); |
|
103 |
|
104 void cleanupDeviceDiscoverer(); |
|
105 |
|
106 void startedDeviceDiscovery(JNIEnv* aJni, jobject& aPeer); |
|
107 |
|
108 // Name lookup Methods |
|
109 std::wstring* nameLookupL(TInt64 aDevAddr); |
|
110 |
|
111 // Service Search Methods |
|
112 void searchServiceFsL(TInt64 aRemoteAddress, TPtrC8 aUuidsDes, |
|
113 TPtrC16 aAttrIdsDes); |
|
114 |
|
115 void cancelAndCleanupServiceSearchFs(); |
|
116 |
|
117 void CleanupServiceSearcher(); |
|
118 |
|
119 void CleanupAllServiceSearcherInfo(); |
|
120 |
|
121 void StartedServiceSearch(JNIEnv* aJni, jobject& aPeer); |
|
122 |
|
123 void populateServiceRecordAttrValueFs(TInt64 aRemoteAddress, long aHandle, |
|
124 TPtrC16 aAttrIdsDes, jobject aServiceRecordImpl); |
|
125 |
|
126 private: |
|
127 // Service Search Data |
|
128 bool mIsServiceSearchOn; |
|
129 |
|
130 int mServiceSearchStatus; |
|
131 // Discovery Agent Data |
|
132 int mSocketServerStatus; |
|
133 int mPopulateRecordStatus; |
|
134 |
|
135 // Device Inquiry Callback JNI Method IDs |
|
136 jmethodID mDeviceDiscoveredMethod; |
|
137 jmethodID mDeviceDiscoveryStartedMethod; |
|
138 // Service Search Callback JNI Method IDs |
|
139 jmethodID mServiceSearchStartedMethod; |
|
140 |
|
141 BluetoothFunctionServer* mFunctionServer; |
|
142 BluetoothServiceSearcher* mServiceSearcher; |
|
143 // Device Inquiry Data |
|
144 BluetoothDeviceDiscoverer* mDeviceDiscoverer; |
|
145 |
|
146 java::util::Monitor* mServiceSearchMonitor; |
|
147 |
|
148 }; |
|
149 |
|
150 } //end namespace bluetooth |
|
151 } //end namespace java |
|
152 |
|
153 |
|
154 #endif // DISCOVERYAGENT_H |