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 #include "mozilla/dom/IccInfo.h"
7 #include "nsPIDOMWindow.h"
9 #define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum) \
12 for (const EnumEntry* entry = _enumType##Values::strings; \
15 if (_string.EqualsASCII(entry->value)) { \
16 _enum.SetValue(static_cast<_enumType>(i)); \
21 using namespace mozilla::dom
;
25 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IccInfo
, mWindow
, mIccInfo
)
27 NS_IMPL_CYCLE_COLLECTING_ADDREF(IccInfo
)
28 NS_IMPL_CYCLE_COLLECTING_RELEASE(IccInfo
)
30 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IccInfo
)
31 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
32 NS_INTERFACE_MAP_ENTRY(nsISupports
)
35 IccInfo::IccInfo(nsPIDOMWindow
* aWindow
)
41 IccInfo::Update(nsIIccInfo
* aInfo
)
47 IccInfo::WrapObject(JSContext
* aCx
)
49 return MozIccInfoBinding::Wrap(aCx
, this);
53 IccInfo::GetIccType() const
56 return Nullable
<IccType
>();
60 Nullable
<IccType
> iccType
;
62 mIccInfo
->GetIccType(type
);
63 CONVERT_STRING_TO_NULLABLE_ENUM(type
, IccType
, iccType
);
69 IccInfo::GetIccid(nsAString
& aIccId
) const
72 aIccId
.SetIsVoid(true);
76 mIccInfo
->GetIccid(aIccId
);
80 IccInfo::GetMcc(nsAString
& aMcc
) const
87 mIccInfo
->GetMcc(aMcc
);
91 IccInfo::GetMnc(nsAString
& aMnc
) const
98 mIccInfo
->GetMnc(aMnc
);
102 IccInfo::GetSpn(nsAString
& aSpn
) const
105 aSpn
.SetIsVoid(true);
109 mIccInfo
->GetSpn(aSpn
);
113 IccInfo::IsDisplayNetworkNameRequired() const
119 bool isDisplayNetworkNameRequired
;
120 mIccInfo
->GetIsDisplayNetworkNameRequired(&isDisplayNetworkNameRequired
);
122 return isDisplayNetworkNameRequired
;
126 IccInfo::IsDisplaySpnRequired() const
132 bool isDisplaySpnRequired
;
133 mIccInfo
->GetIsDisplaySpnRequired(&isDisplaySpnRequired
);
135 return isDisplaySpnRequired
;
140 NS_IMPL_CYCLE_COLLECTION_INHERITED(GsmIccInfo
, IccInfo
, mGsmIccInfo
)
142 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GsmIccInfo
)
143 NS_INTERFACE_MAP_END_INHERITING(IccInfo
)
145 NS_IMPL_ADDREF_INHERITED(GsmIccInfo
, IccInfo
)
146 NS_IMPL_RELEASE_INHERITED(GsmIccInfo
, IccInfo
)
148 GsmIccInfo::GsmIccInfo(nsPIDOMWindow
* aWindow
)
154 GsmIccInfo::Update(nsIGsmIccInfo
* aInfo
)
156 nsCOMPtr
<nsIIccInfo
> iccInfo
= do_QueryInterface(aInfo
);
159 IccInfo::Update(iccInfo
);
164 GsmIccInfo::WrapObject(JSContext
* aCx
)
166 return MozGsmIccInfoBinding::Wrap(aCx
, this);
170 GsmIccInfo::GetMsisdn(nsAString
& aMsisdn
) const
173 aMsisdn
.SetIsVoid(true);
177 mGsmIccInfo
->GetMsisdn(aMsisdn
);
182 NS_IMPL_CYCLE_COLLECTION_INHERITED(CdmaIccInfo
, IccInfo
, mCdmaIccInfo
)
184 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CdmaIccInfo
)
185 NS_INTERFACE_MAP_END_INHERITING(IccInfo
)
187 NS_IMPL_ADDREF_INHERITED(CdmaIccInfo
, IccInfo
)
188 NS_IMPL_RELEASE_INHERITED(CdmaIccInfo
, IccInfo
)
190 CdmaIccInfo::CdmaIccInfo(nsPIDOMWindow
* aWindow
)
196 CdmaIccInfo::Update(nsICdmaIccInfo
* aInfo
)
198 nsCOMPtr
<nsIIccInfo
> iccInfo
= do_QueryInterface(aInfo
);
201 IccInfo::Update(iccInfo
);
202 mCdmaIccInfo
= aInfo
;
206 CdmaIccInfo::WrapObject(JSContext
* aCx
)
208 return MozCdmaIccInfoBinding::Wrap(aCx
, this);
212 CdmaIccInfo::GetMdn(nsAString
& aMdn
) const
215 aMdn
.SetIsVoid(true);
219 mCdmaIccInfo
->GetMdn(aMdn
);
223 CdmaIccInfo::PrlVersion() const
230 mCdmaIccInfo
->GetPrlVersion(&prlVersion
);