dom/bluetooth/BluetoothRilListener.h
author Wes Kocher <wkocher@mozilla.com>
Thu, 28 Aug 2014 16:51:41 -0700
changeset 224047 de824c1ec349b605618a5641bd4aa81e18c56775
parent 224031 82f8670f5c179b3519e7d710ed1ca81b39baedd8
child 226370 3468cd2bbf599071046376339e24b25ea37aab3e
permissions -rw-r--r--
Backed out 17 changesets (bug 843452) Backed out changeset e72a0297d488 (bug 843452) Backed out changeset 73f62ce4190f (bug 843452) Backed out changeset 6d4a49ebd9fc (bug 843452) Backed out changeset ac93e396669f (bug 843452) Backed out changeset cf4fc721821e (bug 843452) Backed out changeset 9a94ea71d232 (bug 843452) Backed out changeset b95ff097374d (bug 843452) Backed out changeset 8d6428a93500 (bug 843452) Backed out changeset e31b86ef0e80 (bug 843452) Backed out changeset bd4efde535cd (bug 843452) Backed out changeset 02bbcd8ac571 (bug 843452) Backed out changeset f7f41bf82b22 (bug 843452) Backed out changeset 20f42764cd38 (bug 843452) Backed out changeset 82f8670f5c17 (bug 843452) Backed out changeset 52f25f1278e3 (bug 843452) Backed out changeset 181337820a7c (bug 843452) Backed out changeset 9bd12641af03 (bug 843452)

/* -*- 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/. */

#ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__
#define mozilla_dom_bluetooth_bluetoothrillistener_h__

#include "BluetoothCommon.h"

#include "nsAutoPtr.h"

#include "nsIIccProvider.h"
#include "nsIMobileConnectionProvider.h"
#include "nsITelephonyService.h"

BEGIN_BLUETOOTH_NAMESPACE

class BluetoothRilListener;

class IccListener : public nsIIccListener
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIICCLISTENER

  IccListener() { }
  virtual ~IccListener() { }

  bool Listen(bool aStart);
  void SetOwner(BluetoothRilListener *aOwner);

private:
  BluetoothRilListener* mOwner;
};

class MobileConnectionListener : public nsIMobileConnectionListener
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIMOBILECONNECTIONLISTENER

  MobileConnectionListener(uint32_t aClientId)
  : mClientId(aClientId) { }
  virtual ~MobileConnectionListener() { }

  bool Listen(bool aStart);

private:
  uint32_t mClientId;
};

class TelephonyListener : public nsITelephonyListener
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSITELEPHONYLISTENER

  TelephonyListener() { }
  virtual ~TelephonyListener() { }

  bool Listen(bool aStart);
};

class BluetoothRilListener
{
public:
  BluetoothRilListener();
  ~BluetoothRilListener();

  /**
   * Start/Stop listening.
   *
   * @param aStart [in] whether to start/stop listening
   */
  bool Listen(bool aStart);

  /**
   * Be informed that certain client's service has changed.
   *
   * @param aClientId   [in] the client id with service change
   * @param aRegistered [in] whether changed service is registered
   */
  void ServiceChanged(uint32_t aClientId, bool aRegistered);

  /**
   * Enumerate current calls.
   */
  void EnumerateCalls();

  /**
   * The id of client that mobile connection and icc info listeners
   * are listening to.
   *
   * mClientId equals to number of total clients (array length of
   * mobile connection listeners) if there is no available client to listen.
   */
  uint32_t mClientId;

private:
  /**
   * Start/Stop listening of mobile connection and icc info.
   *
   * @param aStart [in] whether to start/stop listening
   */
  bool ListenMobileConnAndIccInfo(bool aStart);

  /**
   * Select available client to listen and assign mClientId.
   *
   * mClientId is assigned to number of total clients (array length of
   * mobile connection listeners) if there is no available client to listen.
   */
  void SelectClient();

  /**
   * Array of mobile connection listeners.
   *
   * The length equals to number of total clients.
   */
  nsTArray<nsRefPtr<MobileConnectionListener> > mMobileConnListeners;

  nsRefPtr<IccListener> mIccListener;
  nsRefPtr<TelephonyListener> mTelephonyListener;
};

END_BLUETOOTH_NAMESPACE

#endif