1/*
2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef _DISCOVERY_LISTENER_H
6#define _DISCOVERY_LISTENER_H
7
8#include <Looper.h>
9#include <ObjectList.h>
10
11#include <bluetooth/DeviceClass.h>
12#include <bluetooth/RemoteDevice.h>
13
14
15#define BT_INQUIRY_COMPLETED	0x01 // HCI_EVENT_X check specs
16#define BT_INQUIRY_TERMINATED	0x02 // HCI_EVENT_X
17#define BT_INQUIRY_ERROR		0x03 // HCI_EVENT_X
18
19
20namespace Bluetooth {
21
22typedef BObjectList<RemoteDevice> RemoteDevicesList;
23
24class LocalDevice;
25
26class DiscoveryListener : public BLooper {
27
28public:
29
30	static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED;
31	static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED;
32	static const int INQUIRY_ERROR = BT_INQUIRY_ERROR;
33
34	static const int SERVICE_SEARCH_COMPLETED = 0x01;
35	static const int SERVICE_SEARCH_TERMINATED = 0x02;
36	static const int SERVICE_SEARCH_ERROR = 0x03;
37	static const int SERVICE_SEARCH_NO_RECORDS = 0x04;
38	static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06;
39
40	virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod);
41	/*
42	virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord);
43	virtual void serviceSearchCompleted(int transID, int respCode);
44	*/
45	virtual void InquiryCompleted(int discType);
46
47	/* JSR82 non-defined methods */
48	virtual void InquiryStarted(status_t status);
49
50private:
51
52	RemoteDevicesList GetRemoteDevicesList(void);
53
54	void MessageReceived(BMessage* msg);
55
56	LocalDevice* fLocalDevice;
57	RemoteDevicesList fRemoteDevicesList;
58
59	friend class DiscoveryAgent;
60
61protected:
62	DiscoveryListener();
63	void SetLocalDeviceOwner(LocalDevice* ld);
64};
65
66}
67
68#ifndef _BT_USE_EXPLICIT_NAMESPACE
69using Bluetooth::DiscoveryListener;
70#endif
71
72#endif // _DISCOVERY_LISTENER_H
73