1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/BluetoothRilListener.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__ 1.11 +#define mozilla_dom_bluetooth_bluetoothrillistener_h__ 1.12 + 1.13 +#include "BluetoothCommon.h" 1.14 + 1.15 +#include "nsAutoPtr.h" 1.16 + 1.17 +#include "nsIIccProvider.h" 1.18 +#include "nsIMobileConnectionProvider.h" 1.19 +#include "nsITelephonyProvider.h" 1.20 + 1.21 +BEGIN_BLUETOOTH_NAMESPACE 1.22 + 1.23 +class BluetoothRilListener; 1.24 + 1.25 +class IccListener : public nsIIccListener 1.26 +{ 1.27 +public: 1.28 + NS_DECL_ISUPPORTS 1.29 + NS_DECL_NSIICCLISTENER 1.30 + 1.31 + IccListener() { } 1.32 + virtual ~IccListener() { } 1.33 + 1.34 + bool Listen(bool aStart); 1.35 + void SetOwner(BluetoothRilListener *aOwner); 1.36 + 1.37 +private: 1.38 + BluetoothRilListener* mOwner; 1.39 +}; 1.40 + 1.41 +class MobileConnectionListener : public nsIMobileConnectionListener 1.42 +{ 1.43 +public: 1.44 + NS_DECL_ISUPPORTS 1.45 + NS_DECL_NSIMOBILECONNECTIONLISTENER 1.46 + 1.47 + MobileConnectionListener(uint32_t aClientId) 1.48 + : mClientId(aClientId) { } 1.49 + virtual ~MobileConnectionListener() { } 1.50 + 1.51 + bool Listen(bool aStart); 1.52 + 1.53 +private: 1.54 + uint32_t mClientId; 1.55 +}; 1.56 + 1.57 +class TelephonyListener : public nsITelephonyListener 1.58 +{ 1.59 +public: 1.60 + NS_DECL_ISUPPORTS 1.61 + NS_DECL_NSITELEPHONYLISTENER 1.62 + 1.63 + TelephonyListener() { } 1.64 + virtual ~TelephonyListener() { } 1.65 + 1.66 + bool Listen(bool aStart); 1.67 +}; 1.68 + 1.69 +class BluetoothRilListener 1.70 +{ 1.71 +public: 1.72 + BluetoothRilListener(); 1.73 + ~BluetoothRilListener(); 1.74 + 1.75 + /** 1.76 + * Start/Stop listening. 1.77 + * 1.78 + * @param aStart [in] whether to start/stop listening 1.79 + */ 1.80 + bool Listen(bool aStart); 1.81 + 1.82 + /** 1.83 + * Be informed that certain client's service has changed. 1.84 + * 1.85 + * @param aClientId [in] the client id with service change 1.86 + * @param aRegistered [in] whether changed service is registered 1.87 + */ 1.88 + void ServiceChanged(uint32_t aClientId, bool aRegistered); 1.89 + 1.90 + /** 1.91 + * Enumerate current calls. 1.92 + */ 1.93 + void EnumerateCalls(); 1.94 + 1.95 + /** 1.96 + * The id of client that mobile connection and icc info listeners 1.97 + * are listening to. 1.98 + * 1.99 + * mClientId equals to number of total clients (array length of 1.100 + * mobile connection listeners) if there is no available client to listen. 1.101 + */ 1.102 + uint32_t mClientId; 1.103 + 1.104 +private: 1.105 + /** 1.106 + * Start/Stop listening of mobile connection and icc info. 1.107 + * 1.108 + * @param aStart [in] whether to start/stop listening 1.109 + */ 1.110 + bool ListenMobileConnAndIccInfo(bool aStart); 1.111 + 1.112 + /** 1.113 + * Select available client to listen and assign mClientId. 1.114 + * 1.115 + * mClientId is assigned to number of total clients (array length of 1.116 + * mobile connection listeners) if there is no available client to listen. 1.117 + */ 1.118 + void SelectClient(); 1.119 + 1.120 + /** 1.121 + * Array of mobile connection listeners. 1.122 + * 1.123 + * The length equals to number of total clients. 1.124 + */ 1.125 + nsTArray<nsRefPtr<MobileConnectionListener> > mMobileConnListeners; 1.126 + 1.127 + nsRefPtr<IccListener> mIccListener; 1.128 + nsRefPtr<TelephonyListener> mTelephonyListener; 1.129 +}; 1.130 + 1.131 +END_BLUETOOTH_NAMESPACE 1.132 + 1.133 +#endif