Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / mobileconnection / MobileConnection.h
blobe55cdefc78d2378125081dc65fec29f5894398a4
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 "MobileConnectionInfo.h"
9 #include "MobileNetworkInfo.h"
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/DOMRequest.h"
12 #include "mozilla/dom/MozMobileConnectionBinding.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsIMobileConnectionProvider.h"
15 #include "nsWeakPtr.h"
17 namespace mozilla {
18 namespace dom {
20 class MobileConnection MOZ_FINAL : public DOMEventTargetHelper,
21 private nsIMobileConnectionListener
23 /**
24 * Class MobileConnection doesn't actually expose
25 * nsIMobileConnectionListener. Instead, it owns an
26 * nsIMobileConnectionListener derived instance mListener and passes it to
27 * nsIMobileConnectionProvider. The onreceived events are first delivered to
28 * mListener and then forwarded to its owner, MobileConnection. See also bug
29 * 775997 comment #51.
31 class Listener;
33 public:
34 NS_DECL_ISUPPORTS_INHERITED
35 NS_DECL_NSIMOBILECONNECTIONLISTENER
36 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
37 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
38 DOMEventTargetHelper)
40 MobileConnection(nsPIDOMWindow *aWindow, uint32_t aClientId);
42 void
43 Shutdown();
45 virtual void
46 DisconnectFromOwner() MOZ_OVERRIDE;
48 nsPIDOMWindow*
49 GetParentObject() const
51 return GetOwner();
54 // WrapperCache
55 virtual JSObject*
56 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
58 // WebIDL interface
59 void
60 GetLastKnownNetwork(nsString& aRetVal) const;
62 void
63 GetLastKnownHomeNetwork(nsString& aRetVal) const;
65 MobileConnectionInfo*
66 Voice() const;
68 MobileConnectionInfo*
69 Data() const;
71 void
72 GetIccId(nsString& aRetVal) const;
74 Nullable<MobileNetworkSelectionMode>
75 GetNetworkSelectionMode() const;
77 Nullable<MobileRadioState>
78 GetRadioState() const;
80 void
81 GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const;
83 already_AddRefed<DOMRequest>
84 GetNetworks(ErrorResult& aRv);
86 already_AddRefed<DOMRequest>
87 SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv);
89 already_AddRefed<DOMRequest>
90 SelectNetworkAutomatically(ErrorResult& aRv);
92 already_AddRefed<DOMRequest>
93 SetPreferredNetworkType(MobilePreferredNetworkType& aType, ErrorResult& aRv);
95 already_AddRefed<DOMRequest>
96 GetPreferredNetworkType(ErrorResult& aRv);
98 already_AddRefed<DOMRequest>
99 SetRoamingPreference(MobileRoamingMode& aMode, ErrorResult& aRv);
101 already_AddRefed<DOMRequest>
102 GetRoamingPreference(ErrorResult& aRv);
104 already_AddRefed<DOMRequest>
105 SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv);
107 already_AddRefed<DOMRequest>
108 GetVoicePrivacyMode(ErrorResult& aRv);
110 already_AddRefed<DOMRequest>
111 SendMMI(const nsAString& aMmi, ErrorResult& aRv);
113 already_AddRefed<DOMRequest>
114 CancelMMI(ErrorResult& aRv);
116 already_AddRefed<DOMRequest>
117 SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
118 ErrorResult& aRv);
120 already_AddRefed<DOMRequest>
121 GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv);
123 already_AddRefed<DOMRequest>
124 SetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
126 already_AddRefed<DOMRequest>
127 GetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
129 already_AddRefed<DOMRequest>
130 ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
131 ErrorResult& aRv);
133 already_AddRefed<DOMRequest>
134 SetCallWaitingOption(bool aEnabled, ErrorResult& aRv);
136 already_AddRefed<DOMRequest>
137 GetCallWaitingOption(ErrorResult& aRv);
139 already_AddRefed<DOMRequest>
140 SetCallingLineIdRestriction(uint16_t aMode, ErrorResult& aRv);
142 already_AddRefed<DOMRequest>
143 GetCallingLineIdRestriction(ErrorResult& aRv);
145 already_AddRefed<DOMRequest>
146 ExitEmergencyCbMode(ErrorResult& aRv);
148 already_AddRefed<DOMRequest>
149 SetRadioEnabled(bool aEnabled, ErrorResult& aRv);
151 IMPL_EVENT_HANDLER(voicechange)
152 IMPL_EVENT_HANDLER(datachange)
153 IMPL_EVENT_HANDLER(ussdreceived)
154 IMPL_EVENT_HANDLER(dataerror)
155 IMPL_EVENT_HANDLER(cfstatechange)
156 IMPL_EVENT_HANDLER(emergencycbmodechange)
157 IMPL_EVENT_HANDLER(otastatuschange)
158 IMPL_EVENT_HANDLER(iccchange)
159 IMPL_EVENT_HANDLER(radiostatechange)
160 IMPL_EVENT_HANDLER(clirmodechange)
162 private:
163 ~MobileConnection();
165 private:
166 uint32_t mClientId;
167 nsCOMPtr<nsIMobileConnectionProvider> mProvider;
168 nsRefPtr<Listener> mListener;
169 nsRefPtr<MobileConnectionInfo> mVoice;
170 nsRefPtr<MobileConnectionInfo> mData;
172 bool
173 CheckPermission(const char* aType) const;
175 void
176 UpdateVoice();
178 void
179 UpdateData();
182 } // namespace dom
183 } // namespace mozilla
185 #endif // mozilla_dom_MobileConnection_h