2013-09-09 04:54:56 -07:00
|
|
|
/* -*- 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"
|
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
#include "nsIIccProvider.h"
|
|
|
|
#include "nsIMobileConnectionProvider.h"
|
|
|
|
#include "nsITelephonyProvider.h"
|
2013-11-07 22:41:12 -08:00
|
|
|
|
2013-11-11 10:40:50 -08:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
2013-11-07 22:41:12 -08:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
class BluetoothRilListener;
|
|
|
|
|
|
|
|
class IccListener : public nsIIccListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIICCLISTENER
|
|
|
|
|
|
|
|
IccListener() { }
|
2013-12-05 20:20:07 -08:00
|
|
|
virtual ~IccListener() { }
|
2013-11-25 22:11:06 -08:00
|
|
|
|
|
|
|
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) { }
|
2013-12-05 20:20:07 -08:00
|
|
|
virtual ~MobileConnectionListener() { }
|
2013-11-25 22:11:06 -08:00
|
|
|
|
|
|
|
bool Listen(bool aStart);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t mClientId;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TelephonyListener : public nsITelephonyListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSITELEPHONYLISTENER
|
|
|
|
|
|
|
|
TelephonyListener() { }
|
2013-12-05 20:20:07 -08:00
|
|
|
virtual ~TelephonyListener() { }
|
2013-11-25 22:11:06 -08:00
|
|
|
|
|
|
|
bool Listen(bool aStart);
|
|
|
|
};
|
|
|
|
|
2013-09-09 04:54:56 -07:00
|
|
|
class BluetoothRilListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BluetoothRilListener();
|
2013-11-25 22:11:06 -08:00
|
|
|
~BluetoothRilListener();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start/Stop listening.
|
|
|
|
*
|
|
|
|
* @param aStart [in] whether to start/stop listening
|
|
|
|
*/
|
|
|
|
bool Listen(bool aStart);
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* 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);
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* Enumerate current calls.
|
|
|
|
*/
|
2013-09-09 04:54:56 -07:00
|
|
|
void EnumerateCalls();
|
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2013-09-09 04:54:56 -07:00
|
|
|
private:
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* Start/Stop listening of mobile connection and icc info.
|
|
|
|
*
|
|
|
|
* @param aStart [in] whether to start/stop listening
|
|
|
|
*/
|
|
|
|
bool ListenMobileConnAndIccInfo(bool aStart);
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* 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();
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
/**
|
|
|
|
* Array of mobile connection listeners.
|
|
|
|
*
|
|
|
|
* The length equals to number of total clients.
|
|
|
|
*/
|
|
|
|
nsTArray<nsRefPtr<MobileConnectionListener> > mMobileConnListeners;
|
2013-09-09 04:54:56 -07:00
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
nsRefPtr<IccListener> mIccListener;
|
|
|
|
nsRefPtr<TelephonyListener> mTelephonyListener;
|
2013-09-09 04:54:56 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|