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"
18 #include "nsIIccProvider.h"
26 class MobileConnection MOZ_FINAL
: public DOMEventTargetHelper
27 , private nsIMobileConnectionListener
29 , private nsIIccListener
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
43 NS_DECL_ISUPPORTS_INHERITED
44 NS_DECL_NSIMOBILECONNECTIONLISTENER
46 NS_DECL_NSIICCLISTENER
48 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper
)
49 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection
,
52 MobileConnection(nsPIDOMWindow
*aWindow
, uint32_t aClientId
);
58 DisconnectFromOwner() MOZ_OVERRIDE
;
61 GetParentObject() const
68 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
72 GetLastKnownNetwork(nsString
& aRetVal
) const;
75 GetLastKnownHomeNetwork(nsString
& aRetVal
) const;
84 GetIccId(nsString
& aRetVal
) const;
86 Nullable
<MobileNetworkSelectionMode
>
87 GetNetworkSelectionMode() const;
89 Nullable
<MobileRadioState
>
90 GetRadioState() const;
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
,
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
,
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
)
176 nsCOMPtr
<nsIMobileConnection
> mMobileConnection
;
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
;
187 CheckPermission(const char* aType
) const;
199 NotifyError(nsIDOMDOMRequest
* aRequest
, const nsAString
& aMessage
);
202 IsValidPassword(const nsAString
& aPassword
);
205 IsValidCallBarringOptions(const MozCallBarringOptions
& aOptions
, bool isSetting
);
208 IsValidCallForwardingOptions(const MozCallForwardingOptions
& aOptions
);
211 IsValidCallForwardingReason(int32_t aReason
);
214 IsValidCallForwardingAction(int32_t aAction
);
217 IsValidCallBarringProgram(int32_t aProgram
);
221 } // namespace mozilla
223 #endif // mozilla_dom_MobileConnection_h