Bumping manifests a=b2g-bump
[gecko.git] / dom / mobileconnection / MobileConnection.h
blob99517247b2089663d6a30e84b41111f970edfe1e
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_MobileConnection_h
6 #define mozilla_dom_MobileConnection_h
8 #include "mozilla/DOMEventTargetHelper.h"
9 #include "mozilla/dom/DOMRequest.h"
10 #include "mozilla/dom/MobileConnectionInfo.h"
11 #include "mozilla/dom/MobileNetworkInfo.h"
12 #include "mozilla/dom/MozMobileConnectionBinding.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsIMobileConnectionService.h"
15 #include "nsWeakPtr.h"
17 #ifdef MOZ_B2G_RIL
18 #include "nsIIccProvider.h"
19 #endif // MOZ_B2G_RIL
21 namespace mozilla {
22 namespace dom {
24 class ImsRegHandler;
26 class MobileConnection MOZ_FINAL : public DOMEventTargetHelper
27 , private nsIMobileConnectionListener
28 #ifdef MOZ_B2G_RIL
29 , private nsIIccListener
30 #endif // MOZ_B2G_RIL
32 /**
33 * Class MobileConnection doesn't actually expose
34 * nsIMobileConnectionListener. Instead, it owns an
35 * nsIMobileConnectionListener derived instance mListener and passes it to
36 * nsIMobileConnectionService. The onreceived events are first delivered to
37 * mListener and then forwarded to its owner, MobileConnection. See also bug
38 * 775997 comment #51.
40 class Listener;
42 public:
43 NS_DECL_ISUPPORTS_INHERITED
44 NS_DECL_NSIMOBILECONNECTIONLISTENER
45 #ifdef MOZ_B2G_RIL
46 NS_DECL_NSIICCLISTENER
47 #endif // MOZ_B2G_RIL
48 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
49 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
50 DOMEventTargetHelper)
52 MobileConnection(nsPIDOMWindow *aWindow, uint32_t aClientId);
54 void
55 Shutdown();
57 virtual void
58 DisconnectFromOwner() MOZ_OVERRIDE;
60 nsPIDOMWindow*
61 GetParentObject() const
63 return GetOwner();
66 // WrapperCache
67 virtual JSObject*
68 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
70 // WebIDL interface
71 void
72 GetLastKnownNetwork(nsString& aRetVal) const;
74 void
75 GetLastKnownHomeNetwork(nsString& aRetVal) const;
77 MobileConnectionInfo*
78 Voice() const;
80 MobileConnectionInfo*
81 Data() const;
83 void
84 GetIccId(nsString& aRetVal) const;
86 Nullable<MobileNetworkSelectionMode>
87 GetNetworkSelectionMode() const;
89 Nullable<MobileRadioState>
90 GetRadioState() const;
92 void
93 GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const;
95 already_AddRefed<ImsRegHandler>
96 GetImsHandler() const;
98 already_AddRefed<DOMRequest>
99 GetNetworks(ErrorResult& aRv);
101 already_AddRefed<DOMRequest>
102 SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv);
104 already_AddRefed<DOMRequest>
105 SelectNetworkAutomatically(ErrorResult& aRv);
107 already_AddRefed<DOMRequest>
108 SetPreferredNetworkType(MobilePreferredNetworkType& aType, ErrorResult& aRv);
110 already_AddRefed<DOMRequest>
111 GetPreferredNetworkType(ErrorResult& aRv);
113 already_AddRefed<DOMRequest>
114 SetRoamingPreference(MobileRoamingMode& aMode, ErrorResult& aRv);
116 already_AddRefed<DOMRequest>
117 GetRoamingPreference(ErrorResult& aRv);
119 already_AddRefed<DOMRequest>
120 SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv);
122 already_AddRefed<DOMRequest>
123 GetVoicePrivacyMode(ErrorResult& aRv);
125 already_AddRefed<DOMRequest>
126 SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
127 ErrorResult& aRv);
129 already_AddRefed<DOMRequest>
130 GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv);
132 already_AddRefed<DOMRequest>
133 SetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
135 already_AddRefed<DOMRequest>
136 GetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
138 already_AddRefed<DOMRequest>
139 ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
140 ErrorResult& aRv);
142 already_AddRefed<DOMRequest>
143 SetCallWaitingOption(bool aEnabled, ErrorResult& aRv);
145 already_AddRefed<DOMRequest>
146 GetCallWaitingOption(ErrorResult& aRv);
148 already_AddRefed<DOMRequest>
149 SetCallingLineIdRestriction(uint16_t aMode, ErrorResult& aRv);
151 already_AddRefed<DOMRequest>
152 GetCallingLineIdRestriction(ErrorResult& aRv);
154 already_AddRefed<DOMRequest>
155 ExitEmergencyCbMode(ErrorResult& aRv);
157 already_AddRefed<DOMRequest>
158 SetRadioEnabled(bool aEnabled, ErrorResult& aRv);
160 IMPL_EVENT_HANDLER(voicechange)
161 IMPL_EVENT_HANDLER(datachange)
162 IMPL_EVENT_HANDLER(dataerror)
163 IMPL_EVENT_HANDLER(cfstatechange)
164 IMPL_EVENT_HANDLER(emergencycbmodechange)
165 IMPL_EVENT_HANDLER(otastatuschange)
166 IMPL_EVENT_HANDLER(iccchange)
167 IMPL_EVENT_HANDLER(radiostatechange)
168 IMPL_EVENT_HANDLER(clirmodechange)
170 private:
171 ~MobileConnection();
173 private:
174 uint32_t mClientId;
175 nsString mIccId;
176 nsCOMPtr<nsIMobileConnection> mMobileConnection;
177 #ifdef MOZ_B2G_RIL
178 nsCOMPtr<nsIIccProvider> mIcc;
179 #endif // MOZ_B2G_RIL
180 nsRefPtr<Listener> mListener;
181 nsRefPtr<MobileConnectionInfo> mVoice;
182 nsRefPtr<MobileConnectionInfo> mData;
183 // mutable for lazy initialization in GetImsRegHandler() const.
184 mutable nsRefPtr<ImsRegHandler> mImsHandler;
186 bool
187 CheckPermission(const char* aType) const;
189 void
190 UpdateVoice();
192 void
193 UpdateData();
195 bool
196 UpdateIccId();
198 nsresult
199 NotifyError(nsIDOMDOMRequest* aRequest, const nsAString& aMessage);
201 bool
202 IsValidPassword(const nsAString& aPassword);
204 bool
205 IsValidCallBarringOptions(const MozCallBarringOptions& aOptions, bool isSetting);
207 bool
208 IsValidCallForwardingOptions(const MozCallForwardingOptions& aOptions);
210 bool
211 IsValidCallForwardingReason(int32_t aReason);
213 bool
214 IsValidCallForwardingAction(int32_t aAction);
216 bool
217 IsValidCallBarringProgram(int32_t aProgram);
220 } // namespace dom
221 } // namespace mozilla
223 #endif // mozilla_dom_MobileConnection_h