michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_bluetooth_ipc_bluetoothparent_h__ michael@0: #define mozilla_dom_bluetooth_ipc_bluetoothparent_h__ michael@0: michael@0: #include "mozilla/dom/bluetooth/BluetoothCommon.h" michael@0: michael@0: #include "mozilla/dom/bluetooth/PBluetoothParent.h" michael@0: #include "mozilla/dom/bluetooth/PBluetoothRequestParent.h" michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/Observer.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsTArray.h" michael@0: #include "nsThreadUtils.h" michael@0: michael@0: template michael@0: class nsRevocableEventPtr; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class ContentParent; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: BEGIN_BLUETOOTH_NAMESPACE michael@0: michael@0: class BluetoothService; michael@0: michael@0: /******************************************************************************* michael@0: * BluetoothParent michael@0: ******************************************************************************/ michael@0: michael@0: class BluetoothParent : public PBluetoothParent, michael@0: public mozilla::Observer michael@0: { michael@0: friend class mozilla::dom::ContentParent; michael@0: michael@0: enum ShutdownState michael@0: { michael@0: Running = 0, michael@0: SentBeginShutdown, michael@0: ReceivedStopNotifying, michael@0: SentNotificationsStopped, michael@0: Dead michael@0: }; michael@0: michael@0: nsRefPtr mService; michael@0: ShutdownState mShutdownState; michael@0: bool mReceivedStopNotifying; michael@0: bool mSentBeginShutdown; michael@0: michael@0: public: michael@0: void michael@0: BeginShutdown(); michael@0: michael@0: protected: michael@0: BluetoothParent(); michael@0: virtual ~BluetoothParent(); michael@0: michael@0: bool michael@0: InitWithService(BluetoothService* aService); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvRegisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvUnregisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvStopNotifying() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPBluetoothRequestConstructor(PBluetoothRequestParent* aActor, michael@0: const Request& aRequest) MOZ_OVERRIDE; michael@0: michael@0: virtual PBluetoothRequestParent* michael@0: AllocPBluetoothRequestParent(const Request& aRequest) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual void michael@0: Notify(const BluetoothSignal& aSignal) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: void michael@0: UnregisterAllSignalHandlers(); michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * BluetoothAdapterRequestParent michael@0: ******************************************************************************/ michael@0: michael@0: class BluetoothRequestParent : public PBluetoothRequestParent michael@0: { michael@0: class ReplyRunnable; michael@0: friend class BluetoothParent; michael@0: michael@0: friend class ReplyRunnable; michael@0: michael@0: nsRefPtr mService; michael@0: nsRevocableEventPtr mReplyRunnable; michael@0: michael@0: #ifdef DEBUG michael@0: Request::Type mRequestType; michael@0: #endif michael@0: michael@0: protected: michael@0: BluetoothRequestParent(BluetoothService* aService); michael@0: virtual ~BluetoothRequestParent(); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: void michael@0: RequestComplete(); michael@0: michael@0: bool michael@0: DoRequest(const DefaultAdapterPathRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const SetPropertyRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const GetPropertyRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const StartDiscoveryRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const StopDiscoveryRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const PairRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const UnpairRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const PairedDevicePropertiesRequest& aRequest); michael@0: bool michael@0: DoRequest(const ConnectedDevicePropertiesRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const SetPinCodeRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const SetPasskeyRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const ConfirmPairingConfirmationRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const DenyPairingConfirmationRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const ConnectRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const DisconnectRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const SendFileRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const StopSendingFileRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const ConfirmReceivingFileRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const DenyReceivingFileRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const ConnectScoRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const DisconnectScoRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const IsScoConnectedRequest& aRequest); michael@0: michael@0: #ifdef MOZ_B2G_RIL michael@0: bool michael@0: DoRequest(const AnswerWaitingCallRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const IgnoreWaitingCallRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const ToggleCallsRequest& aRequest); michael@0: #endif michael@0: michael@0: bool michael@0: DoRequest(const SendMetaDataRequest& aRequest); michael@0: michael@0: bool michael@0: DoRequest(const SendPlayStatusRequest& aRequest); michael@0: }; michael@0: michael@0: END_BLUETOOTH_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_bluetooth_ipc_bluetoothparent_h__