/* 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 "nsISupports.idl"

interface nsIPresentationDevice;
interface nsIPresentationControlChannel;

%{C++
#define PRESENTATION_DEVICE_PROVIDER_CATEGORY "presentation-device-provider"
%}

/*
 * The callbacks for any device updates and session request.
 */
[scriptable, uuid(46fd372b-2e40-4179-9b36-0478d141e440)]
interface nsIPresentationDeviceListener: nsISupports
{
  void addDevice(in nsIPresentationDevice device);
  void removeDevice(in nsIPresentationDevice device);
  void updateDevice(in nsIPresentationDevice device);

  /*
   * Callback while the remote device is requesting to start a presentation session.
   * @param device The remote device that sent session request.
   * @param url The URL requested to open by remote device.
   * @param presentationId The Id for representing this session.
   * @param controlChannel The control channel for this session.
   */
  void onSessionRequest(in nsIPresentationDevice device,
                        in DOMString url,
                        in DOMString presentationId,
                        in nsIPresentationControlChannel controlChannel);

  /*
   * Callback while the remote device is requesting to terminate a presentation session.
   * @param device The remote device that sent session request.
   * @param presentationId The Id for representing this session.
   * @param controlChannel The control channel for this session.
   * @param aIsFromReceiver true if termination is initiated by receiver.
   */
  void onTerminateRequest(in nsIPresentationDevice device,
                          in DOMString presentationId,
                          in nsIPresentationControlChannel controlChannel,
                          in boolean aIsFromReceiver);
};

/*
 * Device provider for any device protocol, can be registered as default
 * providers by adding its contractID to category "presentation-device-provider".
 */
[scriptable, uuid(3db2578a-0f50-44ad-b01b-28427b71b7bf)]
interface nsIPresentationDeviceProvider: nsISupports
{
  // The listener for handling any device update.
  attribute nsIPresentationDeviceListener listener;

  /*
   * Force to update device information.
   */
  void forceDiscovery();
};
