1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/bluez/BluetoothSocket.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_bluetooth_BluetoothSocket_h 1.11 +#define mozilla_dom_bluetooth_BluetoothSocket_h 1.12 + 1.13 +#include "BluetoothCommon.h" 1.14 +#include "mozilla/ipc/UnixSocket.h" 1.15 + 1.16 +BEGIN_BLUETOOTH_NAMESPACE 1.17 + 1.18 +class BluetoothSocketObserver; 1.19 + 1.20 +class BluetoothSocket : public mozilla::ipc::UnixSocketConsumer 1.21 +{ 1.22 +public: 1.23 + BluetoothSocket(BluetoothSocketObserver* aObserver, 1.24 + BluetoothSocketType aType, 1.25 + bool aAuth, 1.26 + bool aEncrypt); 1.27 + 1.28 + bool Connect(const nsACString& aDeviceAddress, int aChannel); 1.29 + bool Listen(int aChannel); 1.30 + inline void Disconnect() 1.31 + { 1.32 + CloseSocket(); 1.33 + } 1.34 + 1.35 + virtual void OnConnectSuccess() MOZ_OVERRIDE; 1.36 + virtual void OnConnectError() MOZ_OVERRIDE; 1.37 + virtual void OnDisconnect() MOZ_OVERRIDE; 1.38 + virtual void ReceiveSocketData( 1.39 + nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) MOZ_OVERRIDE; 1.40 + 1.41 + inline void GetAddress(nsAString& aDeviceAddress) 1.42 + { 1.43 + GetSocketAddr(aDeviceAddress); 1.44 + } 1.45 + 1.46 +private: 1.47 + BluetoothSocketObserver* mObserver; 1.48 + BluetoothSocketType mType; 1.49 + bool mAuth; 1.50 + bool mEncrypt; 1.51 +}; 1.52 + 1.53 +END_BLUETOOTH_NAMESPACE 1.54 + 1.55 +#endif