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"
20 class MobileConnection MOZ_FINAL
: public DOMEventTargetHelper
,
21 private nsIMobileConnectionListener
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
34 NS_DECL_ISUPPORTS_INHERITED
35 NS_DECL_NSIMOBILECONNECTIONLISTENER
36 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper
)
37 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection
,
40 MobileConnection(nsPIDOMWindow
*aWindow
, uint32_t aClientId
);
46 DisconnectFromOwner() MOZ_OVERRIDE
;
49 GetParentObject() const
56 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
60 GetLastKnownNetwork(nsString
& aRetVal
) const;
63 GetLastKnownHomeNetwork(nsString
& aRetVal
) const;
72 GetIccId(nsString
& aRetVal
) const;
74 Nullable
<MobileNetworkSelectionMode
>
75 GetNetworkSelectionMode() const;
77 Nullable
<MobileRadioState
>
78 GetRadioState() const;
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
,
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
,
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
)
167 nsCOMPtr
<nsIMobileConnectionProvider
> mProvider
;
168 nsRefPtr
<Listener
> mListener
;
169 nsRefPtr
<MobileConnectionInfo
> mVoice
;
170 nsRefPtr
<MobileConnectionInfo
> mData
;
173 CheckPermission(const char* aType
) const;
183 } // namespace mozilla
185 #endif // mozilla_dom_MobileConnection_h