/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "nsIDOMEventTarget.idl"

interface nsIDOMDOMRequest;
interface nsIDOMBluetoothDevice;

[scriptable, builtinclass, uuid(db6b4dd6-64f1-415d-ac51-ae0fa0fe05ed)]
interface nsIDOMBluetoothAdapter : nsIDOMEventTarget
{
  readonly attribute DOMString address;
  [binaryname(AdapterClass)] readonly attribute unsigned long class;
  readonly attribute bool enabled;
  readonly attribute bool discovering;

  [implicit_jscontext]
  readonly attribute jsval devices;

  [implicit_jscontext]
  readonly attribute jsval uuids;
  
  readonly attribute DOMString name;
  readonly attribute bool discoverable;
  // Unit: sec
  readonly attribute unsigned long discoverableTimeout;

  nsIDOMDOMRequest setName(in DOMString name);
  nsIDOMDOMRequest setDiscoverable(in bool discoverable);
  nsIDOMDOMRequest setDiscoverableTimeout(in unsigned long timeout);
  nsIDOMDOMRequest startDiscovery();
  nsIDOMDOMRequest stopDiscovery();
  nsIDOMDOMRequest pair(in nsIDOMBluetoothDevice aDevice);
  nsIDOMDOMRequest unpair(in nsIDOMBluetoothDevice aDevice);
  nsIDOMDOMRequest getPairedDevices();
  void setPinCode(in DOMString aDeviceAddress, in DOMString aPinCode);
  void setPasskey(in DOMString aDeviceAddress, in unsigned long aPasskey);
  void setPairingConfirmation(in DOMString aDeviceAddress, in bool aConfirmation);
  void setAuthorization(in DOMString aDeviceAddress, in bool aAllow);

  // Fired when discoverying and any device is discovered.
  attribute nsIDOMEventListener ondevicefound;
  // Fired when any device is out of discoverable range.
  attribute nsIDOMEventListener ondevicedisappeared;
  // Fired when a property of the adapter is changed
  attribute nsIDOMEventListener onpropertychanged;
  // Pairing related events
  attribute nsIDOMEventListener onrequestconfirmation;
  attribute nsIDOMEventListener onrequestpincode;
  attribute nsIDOMEventListener onrequestpasskey;
  attribute nsIDOMEventListener onauthorize;
  attribute nsIDOMEventListener oncancel;
};
