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
|
|
|
|
2015-01-15 02:22:08 -08:00
|
|
|
#include "nsIIccService.h"
|
2014-07-02 02:14:08 -07:00
|
|
|
#include "nsIMobileConnectionService.h"
|
2015-01-08 00:33:51 -08:00
|
|
|
#include "nsITelephonyCallInfo.h"
|
2014-06-03 07:15:25 -07:00
|
|
|
#include "nsITelephonyService.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() { }
|
|
|
|
|
|
|
|
bool Listen(bool aStart);
|
|
|
|
void SetOwner(BluetoothRilListener *aOwner);
|
|
|
|
|
2015-03-10 05:44:02 -07:00
|
|
|
protected:
|
|
|
|
virtual ~IccListener() { }
|
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
private:
|
|
|
|
BluetoothRilListener* mOwner;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MobileConnectionListener : public nsIMobileConnectionListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIMOBILECONNECTIONLISTENER
|
|
|
|
|
|
|
|
MobileConnectionListener(uint32_t aClientId)
|
|
|
|
: mClientId(aClientId) { }
|
|
|
|
|
|
|
|
bool Listen(bool aStart);
|
|
|
|
|
2015-03-10 05:44:02 -07:00
|
|
|
protected:
|
|
|
|
virtual ~MobileConnectionListener() { }
|
|
|
|
|
2013-11-25 22:11:06 -08:00
|
|
|
private:
|
|
|
|
uint32_t mClientId;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TelephonyListener : public nsITelephonyListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSITELEPHONYLISTENER
|
|
|
|
|
|
|
|
TelephonyListener() { }
|
|
|
|
|
|
|
|
bool Listen(bool aStart);
|
2015-01-08 00:33:51 -08:00
|
|
|
|
2015-03-10 05:44:02 -07:00
|
|
|
protected:
|
|
|
|
virtual ~TelephonyListener() { }
|
|
|
|
|
2015-01-08 00:33:51 -08:00
|
|
|
private:
|
|
|
|
nsresult HandleCallInfo(nsITelephonyCallInfo* aInfo, bool aSend);
|
2013-11-25 22:11:06 -08:00
|
|
|
};
|
|
|
|
|
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
|