|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__ |
|
8 #define mozilla_dom_bluetooth_bluetoothrillistener_h__ |
|
9 |
|
10 #include "BluetoothCommon.h" |
|
11 |
|
12 #include "nsAutoPtr.h" |
|
13 |
|
14 #include "nsIIccProvider.h" |
|
15 #include "nsIMobileConnectionProvider.h" |
|
16 #include "nsITelephonyProvider.h" |
|
17 |
|
18 BEGIN_BLUETOOTH_NAMESPACE |
|
19 |
|
20 class BluetoothRilListener; |
|
21 |
|
22 class IccListener : public nsIIccListener |
|
23 { |
|
24 public: |
|
25 NS_DECL_ISUPPORTS |
|
26 NS_DECL_NSIICCLISTENER |
|
27 |
|
28 IccListener() { } |
|
29 virtual ~IccListener() { } |
|
30 |
|
31 bool Listen(bool aStart); |
|
32 void SetOwner(BluetoothRilListener *aOwner); |
|
33 |
|
34 private: |
|
35 BluetoothRilListener* mOwner; |
|
36 }; |
|
37 |
|
38 class MobileConnectionListener : public nsIMobileConnectionListener |
|
39 { |
|
40 public: |
|
41 NS_DECL_ISUPPORTS |
|
42 NS_DECL_NSIMOBILECONNECTIONLISTENER |
|
43 |
|
44 MobileConnectionListener(uint32_t aClientId) |
|
45 : mClientId(aClientId) { } |
|
46 virtual ~MobileConnectionListener() { } |
|
47 |
|
48 bool Listen(bool aStart); |
|
49 |
|
50 private: |
|
51 uint32_t mClientId; |
|
52 }; |
|
53 |
|
54 class TelephonyListener : public nsITelephonyListener |
|
55 { |
|
56 public: |
|
57 NS_DECL_ISUPPORTS |
|
58 NS_DECL_NSITELEPHONYLISTENER |
|
59 |
|
60 TelephonyListener() { } |
|
61 virtual ~TelephonyListener() { } |
|
62 |
|
63 bool Listen(bool aStart); |
|
64 }; |
|
65 |
|
66 class BluetoothRilListener |
|
67 { |
|
68 public: |
|
69 BluetoothRilListener(); |
|
70 ~BluetoothRilListener(); |
|
71 |
|
72 /** |
|
73 * Start/Stop listening. |
|
74 * |
|
75 * @param aStart [in] whether to start/stop listening |
|
76 */ |
|
77 bool Listen(bool aStart); |
|
78 |
|
79 /** |
|
80 * Be informed that certain client's service has changed. |
|
81 * |
|
82 * @param aClientId [in] the client id with service change |
|
83 * @param aRegistered [in] whether changed service is registered |
|
84 */ |
|
85 void ServiceChanged(uint32_t aClientId, bool aRegistered); |
|
86 |
|
87 /** |
|
88 * Enumerate current calls. |
|
89 */ |
|
90 void EnumerateCalls(); |
|
91 |
|
92 /** |
|
93 * The id of client that mobile connection and icc info listeners |
|
94 * are listening to. |
|
95 * |
|
96 * mClientId equals to number of total clients (array length of |
|
97 * mobile connection listeners) if there is no available client to listen. |
|
98 */ |
|
99 uint32_t mClientId; |
|
100 |
|
101 private: |
|
102 /** |
|
103 * Start/Stop listening of mobile connection and icc info. |
|
104 * |
|
105 * @param aStart [in] whether to start/stop listening |
|
106 */ |
|
107 bool ListenMobileConnAndIccInfo(bool aStart); |
|
108 |
|
109 /** |
|
110 * Select available client to listen and assign mClientId. |
|
111 * |
|
112 * mClientId is assigned to number of total clients (array length of |
|
113 * mobile connection listeners) if there is no available client to listen. |
|
114 */ |
|
115 void SelectClient(); |
|
116 |
|
117 /** |
|
118 * Array of mobile connection listeners. |
|
119 * |
|
120 * The length equals to number of total clients. |
|
121 */ |
|
122 nsTArray<nsRefPtr<MobileConnectionListener> > mMobileConnListeners; |
|
123 |
|
124 nsRefPtr<IccListener> mIccListener; |
|
125 nsRefPtr<TelephonyListener> mTelephonyListener; |
|
126 }; |
|
127 |
|
128 END_BLUETOOTH_NAMESPACE |
|
129 |
|
130 #endif |