2012-04-20 01:33:25 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
#ifndef mozilla_dom_MobileConnection_h
|
|
|
|
#define mozilla_dom_MobileConnection_h
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-05-05 10:36:20 +04:00
|
|
|
#include "mozilla/dom/DOMRequest.h"
|
2014-09-21 11:24:42 +04:00
|
|
|
#include "mozilla/dom/MobileConnectionInfo.h"
|
|
|
|
#include "mozilla/dom/MobileNetworkInfo.h"
|
2014-05-05 10:36:20 +04:00
|
|
|
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
2012-04-20 01:33:25 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-01-15 13:19:01 +03:00
|
|
|
#include "nsIIccService.h"
|
2014-07-02 13:38:23 +04:00
|
|
|
#include "nsIMobileConnectionService.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsWeakPtr.h"
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class MobileConnection final : public DOMEventTargetHelper
|
2015-01-15 13:19:01 +03:00
|
|
|
, private nsIMobileConnectionListener
|
|
|
|
, private nsIIccListener
|
2012-04-20 01:33:25 +04:00
|
|
|
{
|
2013-03-06 13:53:12 +04:00
|
|
|
/**
|
2014-08-20 05:01:49 +04:00
|
|
|
* Class MobileConnection doesn't actually expose
|
2013-03-06 13:53:12 +04:00
|
|
|
* nsIMobileConnectionListener. Instead, it owns an
|
|
|
|
* nsIMobileConnectionListener derived instance mListener and passes it to
|
2014-07-02 13:38:23 +04:00
|
|
|
* nsIMobileConnectionService. The onreceived events are first delivered to
|
2013-03-06 13:53:12 +04:00
|
|
|
* mListener and then forwarded to its owner, MobileConnection. See also bug
|
|
|
|
* 775997 comment #51.
|
|
|
|
*/
|
|
|
|
class Listener;
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
public:
|
2013-03-06 13:53:12 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIMOBILECONNECTIONLISTENER
|
2014-11-13 14:12:11 +03:00
|
|
|
NS_DECL_NSIICCLISTENER
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
2014-05-05 10:36:20 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
|
|
|
|
DOMEventTargetHelper)
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
MobileConnection(nsPIDOMWindow *aWindow, uint32_t aClientId);
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
Shutdown();
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-08-07 08:21:29 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
DisconnectFromOwner() override;
|
2014-08-07 08:21:29 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
// WrapperCache
|
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-05-05 10:36:20 +04:00
|
|
|
|
|
|
|
// WebIDL interface
|
|
|
|
void
|
|
|
|
GetLastKnownNetwork(nsString& aRetVal) const;
|
|
|
|
|
|
|
|
void
|
|
|
|
GetLastKnownHomeNetwork(nsString& aRetVal) const;
|
|
|
|
|
|
|
|
MobileConnectionInfo*
|
|
|
|
Voice() const;
|
|
|
|
|
|
|
|
MobileConnectionInfo*
|
|
|
|
Data() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
GetIccId(nsString& aRetVal) const;
|
|
|
|
|
|
|
|
Nullable<MobileNetworkSelectionMode>
|
|
|
|
GetNetworkSelectionMode() const;
|
|
|
|
|
|
|
|
Nullable<MobileRadioState>
|
|
|
|
GetRadioState() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const;
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetNetworks(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SelectNetworkAutomatically(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetPreferredNetworkType(MobilePreferredNetworkType& aType, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetPreferredNetworkType(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetRoamingPreference(MobileRoamingMode& aMode, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetRoamingPreference(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetVoicePrivacyMode(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetCallBarringOption(const MozCallBarringOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetCallWaitingOption(bool aEnabled, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetCallWaitingOption(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetCallingLineIdRestriction(uint16_t aMode, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetCallingLineIdRestriction(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
ExitEmergencyCbMode(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetRadioEnabled(bool aEnabled, ErrorResult& aRv);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(voicechange)
|
|
|
|
IMPL_EVENT_HANDLER(datachange)
|
|
|
|
IMPL_EVENT_HANDLER(dataerror)
|
|
|
|
IMPL_EVENT_HANDLER(cfstatechange)
|
|
|
|
IMPL_EVENT_HANDLER(emergencycbmodechange)
|
|
|
|
IMPL_EVENT_HANDLER(otastatuschange)
|
|
|
|
IMPL_EVENT_HANDLER(iccchange)
|
|
|
|
IMPL_EVENT_HANDLER(radiostatechange)
|
|
|
|
IMPL_EVENT_HANDLER(clirmodechange)
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-07-11 11:58:01 +04:00
|
|
|
private:
|
|
|
|
~MobileConnection();
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
private:
|
2014-11-13 14:12:11 +03:00
|
|
|
uint32_t mClientId;
|
|
|
|
nsString mIccId;
|
2014-09-21 11:24:43 +04:00
|
|
|
nsCOMPtr<nsIMobileConnection> mMobileConnection;
|
2015-01-15 13:19:01 +03:00
|
|
|
nsCOMPtr<nsIIcc> mIccHandler;
|
2013-03-06 13:53:12 +04:00
|
|
|
nsRefPtr<Listener> mListener;
|
2014-05-05 10:36:20 +04:00
|
|
|
nsRefPtr<MobileConnectionInfo> mVoice;
|
|
|
|
nsRefPtr<MobileConnectionInfo> mData;
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
bool
|
|
|
|
CheckPermission(const char* aType) const;
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateVoice();
|
2013-10-30 08:02:47 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
UpdateData();
|
2014-10-08 10:33:00 +04:00
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
bool
|
|
|
|
UpdateIccId();
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsresult
|
|
|
|
NotifyError(nsIDOMDOMRequest* aRequest, const nsAString& aMessage);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidPassword(const nsAString& aPassword);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidCallBarringOptions(const MozCallBarringOptions& aOptions, bool isSetting);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidCallForwardingOptions(const MozCallForwardingOptions& aOptions);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidCallForwardingReason(int32_t aReason);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidCallForwardingAction(int32_t aAction);
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValidCallBarringProgram(int32_t aProgram);
|
2012-04-20 01:33:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
#endif // mozilla_dom_MobileConnection_h
|