vfs: check userland buffers before reading them.
[haiku.git] / src / servers / bluetooth / BluetoothServer.h
blob42e96424b891228538045c2c73c7ad7f71df9430
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 _BLUETOOTH_SERVER_APP_H
6 #define _BLUETOOTH_SERVER_APP_H
8 #include <stdlib.h>
10 #include <Application.h>
11 #include <ObjectList.h>
12 #include <OS.h>
14 #include <bluetooth/bluetooth.h>
15 #include <bluetooth/HCI/btHCI.h>
16 #include <bluetooth/HCI/btHCI_transport.h>
17 #include <bluetooth/HCI/btHCI_command.h>
19 #include "HCIDelegate.h"
20 #include "DeviceManager.h"
21 #include "LocalDeviceImpl.h"
23 #include <PortListener.h>
25 #define BT "bluetooth_server: "
27 typedef enum {
28 BLACKBOARD_GENERAL = 0,
29 BLACKBOARD_DEVICEMANAGER,
30 BLACKBOARD_KIT,
31 BLACKBOARD_SDP,
32 // more blackboards
33 BLACKBOARD_END
34 } BluetoothServerBlackBoardIndex;
36 #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET)
38 typedef BObjectList<LocalDeviceImpl> LocalDevicesList;
39 typedef PortListener<struct hci_event_header,
40 HCI_MAX_EVENT_SIZE, // Event Body can hold max 255 + 2 header
41 24 // Some devices have sent chunks of 24 events(inquiry result)
42 > BluetoothPortListener;
44 class BluetoothServer : public BApplication
46 public:
48 BluetoothServer();
50 virtual bool QuitRequested(void);
51 virtual void ArgvReceived(int32 argc, char **argv);
52 virtual void ReadyToRun(void);
55 virtual void AppActivated(bool act);
56 virtual void MessageReceived(BMessage *message);
58 static int32 SDPServerThread(void* data);
60 /* Messages reply */
61 status_t HandleLocalDevicesCount(BMessage* message, BMessage* reply);
62 status_t HandleAcquireLocalDevice(BMessage* message, BMessage* reply);
64 status_t HandleGetProperty(BMessage* message, BMessage* reply);
65 status_t HandleSimpleRequest(BMessage* message, BMessage* reply);
68 LocalDeviceImpl* LocateLocalDeviceImpl(hci_id hid);
70 private:
72 LocalDeviceImpl* LocateDelegateFromMessage(BMessage* message);
74 void ShowWindow(BWindow* pWindow);
76 void _InstallDeskbarIcon();
77 void _RemoveDeskbarIcon();
79 LocalDevicesList fLocalDevicesList;
82 // Notification system
83 BluetoothPortListener* fEventListener2;
85 DeviceManager* fDeviceManager;
87 BPoint fCenter;
89 thread_id fSDPThreadID;
91 bool fIsShuttingDown;
94 #endif