/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ /* vim: set ts=2 et sw=2 tw=40: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "BluetoothAdapter.h" #include "BluetoothUtils.h" #include "nsDOMClassInfo.h" #include "nsDOMEvent.h" #include "nsThreadUtils.h" #include "nsXPCOMCIDInternal.h" #include "mozilla/LazyIdleThread.h" #include "mozilla/Util.h" USING_BLUETOOTH_NAMESPACE DOMCI_DATA(BluetoothAdapter, BluetoothAdapter) NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothAdapter) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothAdapter) NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothAdapter) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothAdapter) NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) BluetoothAdapter::BluetoothAdapter(const nsCString& name) : mName(name) { } BluetoothAdapter::~BluetoothAdapter() { if (NS_FAILED(UnregisterBluetoothEventHandler(mName, this))) { NS_WARNING("Failed to unregister object with observer!"); } } // static already_AddRefed BluetoothAdapter::Create(const nsCString& name) { nsRefPtr adapter = new BluetoothAdapter(name); if (NS_FAILED(RegisterBluetoothEventHandler(name, adapter))) { NS_WARNING("Failed to register object with observer!"); return NULL; } return adapter.forget(); } void BluetoothAdapter::Notify(const BluetoothEvent& aData) { printf("Got an adapter message!\n"); }