mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 833229 - 3.c/4: implement MozVoicemailStatus in C++. r=smaug
This commit is contained in:
parent
0cc9bf05b0
commit
99f24feecf
@ -755,6 +755,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'mozilla::dom::Voicemail',
|
||||
},
|
||||
|
||||
'MozVoicemailStatus': {
|
||||
'nativeType': 'mozilla::dom::VoicemailStatus',
|
||||
},
|
||||
|
||||
'MutationObserver': {
|
||||
'nativeType': 'nsDOMMutationObserver',
|
||||
},
|
||||
|
@ -48,8 +48,6 @@ const GSMICCINFO_CID =
|
||||
Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}");
|
||||
const CDMAICCINFO_CID =
|
||||
Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}");
|
||||
const VOICEMAILSTATUS_CID=
|
||||
Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
|
||||
const CELLBROADCASTMESSAGE_CID =
|
||||
Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
|
||||
const CELLBROADCASTETWSINFO_CID =
|
||||
@ -179,21 +177,6 @@ VoicemailInfo.prototype = {
|
||||
displayName: null
|
||||
};
|
||||
|
||||
function VoicemailStatus(clientId) {
|
||||
this.serviceId = clientId;
|
||||
}
|
||||
VoicemailStatus.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([]),
|
||||
classID: VOICEMAILSTATUS_CID,
|
||||
contractID: "@mozilla.org/voicemailstatus;1",
|
||||
|
||||
serviceId: -1,
|
||||
hasMessages: false,
|
||||
messageCount: -1, // Count unknown.
|
||||
returnNumber: null,
|
||||
returnMessage: null
|
||||
};
|
||||
|
||||
function CellBroadcastMessage(clientId, pdu) {
|
||||
this.serviceId = clientId;
|
||||
this.gsmGeographicalScope = RIL.CB_GSM_GEOGRAPHICAL_SCOPE_NAMES[pdu.geographicalScope];
|
||||
|
@ -18,10 +18,8 @@ contract @mozilla.org/ril;1 {2d831c8d-6017-435b-a80c-e5d422810cea}
|
||||
category profile-after-change RadioInterfaceLayer @mozilla.org/ril;1
|
||||
|
||||
# RILContentHelper.js
|
||||
component {5467f2eb-e214-43ea-9b89-67711241ec8e} RILContentHelper.js
|
||||
component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js
|
||||
component {08a71987-408c-44ff-93fd-177c0a85c3dd} RILContentHelper.js
|
||||
contract @mozilla.org/voicemailstatus;1 {5467f2eb-e214-43ea-9b89-67711241ec8e}
|
||||
contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174}
|
||||
contract @mozilla.org/dom/icccardlock-error;1 {08a71987-408c-44ff-93fd-177c0a85c3dd}
|
||||
category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1
|
||||
|
@ -103,7 +103,7 @@ Voicemail::PassedOrDefaultServiceId(const Optional<uint32_t>& aServiceId,
|
||||
|
||||
// MozVoicemail WebIDL
|
||||
|
||||
already_AddRefed<MozVoicemailStatus>
|
||||
already_AddRefed<VoicemailStatus>
|
||||
Voicemail::GetStatus(const Optional<uint32_t>& aServiceId,
|
||||
ErrorResult& aRv) const
|
||||
{
|
||||
@ -129,7 +129,7 @@ Voicemail::GetStatus(const Optional<uint32_t>& aServiceId,
|
||||
return nullptr;
|
||||
}
|
||||
JS::Rooted<JSObject*> statusObj(cx, &status.toObject());
|
||||
nsRefPtr<MozVoicemailStatus> res = new MozVoicemailStatus(statusObj, GetParentObject());
|
||||
nsRefPtr<VoicemailStatus> res = new VoicemailStatus(statusObj, GetParentObject());
|
||||
return res.forget();
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ Voicemail::NotifyStatusChanged(JS::HandleValue aStatus)
|
||||
if (aStatus.isObject()) {
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContext();
|
||||
JS::Rooted<JSObject*> statusObj(cx, &aStatus.toObject());
|
||||
init.mStatus = new MozVoicemailStatus(statusObj, GetParentObject());
|
||||
init.mStatus = new VoicemailStatus(statusObj, GetParentObject());
|
||||
}
|
||||
|
||||
nsRefPtr<MozVoicemailEvent> event =
|
||||
|
@ -20,7 +20,7 @@ class nsPIDOMWindow;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MozVoicemailStatus;
|
||||
class VoicemailStatus;
|
||||
|
||||
class Voicemail MOZ_FINAL : public DOMEventTargetHelper,
|
||||
private nsIVoicemailListener
|
||||
@ -55,7 +55,7 @@ public:
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
already_AddRefed<MozVoicemailStatus>
|
||||
already_AddRefed<VoicemailStatus>
|
||||
GetStatus(const Optional<uint32_t>& aServiceId,
|
||||
ErrorResult& aRv) const;
|
||||
|
||||
|
83
dom/voicemail/VoicemailStatus.cpp
Normal file
83
dom/voicemail/VoicemailStatus.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/dom/VoicemailStatus.h"
|
||||
|
||||
#include "mozilla/dom/MozVoicemailStatusBinding.h"
|
||||
#include "nsIVoicemailService.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// mProvider is owned by internal service.
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VoicemailStatus, mParent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(VoicemailStatus)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(VoicemailStatus)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(VoicemailStatus)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
VoicemailStatus::VoicemailStatus(nsISupports* aParent,
|
||||
nsIVoicemailProvider* aProvider)
|
||||
: mParent(aParent)
|
||||
, mProvider(aProvider)
|
||||
{
|
||||
MOZ_ASSERT(mParent);
|
||||
MOZ_ASSERT(mProvider);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
VoicemailStatus::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return MozVoicemailStatusBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
VoicemailStatus::ServiceId() const
|
||||
{
|
||||
uint32_t result = 0;
|
||||
mProvider->GetServiceId(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
VoicemailStatus::HasMessages() const
|
||||
{
|
||||
bool result = false;
|
||||
mProvider->GetHasMessages(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
VoicemailStatus::MessageCount() const
|
||||
{
|
||||
int32_t result = 0;
|
||||
mProvider->GetMessageCount(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
VoicemailStatus::GetReturnNumber(nsString& aReturnNumber) const
|
||||
{
|
||||
aReturnNumber.SetIsVoid(true);
|
||||
mProvider->GetReturnNumber(aReturnNumber);
|
||||
}
|
||||
|
||||
void
|
||||
VoicemailStatus::GetReturnMessage(nsString& aReturnMessage) const
|
||||
{
|
||||
aReturnMessage.SetIsVoid(true);
|
||||
mProvider->GetReturnMessage(aReturnMessage);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
64
dom/voicemail/VoicemailStatus.h
Normal file
64
dom/voicemail/VoicemailStatus.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=40: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_voicemail_VoicemailStatus_h__
|
||||
#define mozilla_dom_voicemail_VoicemailStatus_h__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIVoicemailService.h" // For nsIVoicemailProvider.
|
||||
#include "nsString.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class VoicemailStatus MOZ_FINAL : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(VoicemailStatus)
|
||||
|
||||
VoicemailStatus(nsISupports* aParent,
|
||||
nsIVoicemailProvider* aProvider);
|
||||
|
||||
nsISupports*
|
||||
GetParentObject() const { return mParent; }
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL interface
|
||||
|
||||
uint32_t
|
||||
ServiceId() const;
|
||||
|
||||
bool
|
||||
HasMessages() const;
|
||||
|
||||
int32_t
|
||||
MessageCount() const;
|
||||
|
||||
void
|
||||
GetReturnNumber(nsString& aReturnNumber) const;
|
||||
|
||||
void
|
||||
GetReturnMessage(nsString& aReturnMessage) const;
|
||||
|
||||
private:
|
||||
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||
~VoicemailStatus() {}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsCOMPtr<nsIVoicemailProvider> mProvider;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_voicemail_VoicemailStatus_h__
|
@ -12,6 +12,7 @@ XPIDL_MODULE = 'dom_voicemail'
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'Voicemail.h',
|
||||
'VoicemailStatus.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom.voicemail += [
|
||||
@ -29,6 +30,10 @@ SOURCES += [
|
||||
'Voicemail.cpp',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'VoicemailStatus.cpp',
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
|
@ -79,8 +79,7 @@ function testLevel2DiscardActive() {
|
||||
|
||||
function onLevel2Active(event) {
|
||||
let status = event.status;
|
||||
// TODO: bug 905228 - MozVoicemailStatus is not defined.
|
||||
//ok(status instanceof MozVoicemailStatus);
|
||||
ok(status instanceof MozVoicemailStatus);
|
||||
is(status.hasMessages, true);
|
||||
is(status.messageCount, -1);
|
||||
is(status.returnNumber, MWI_LEVEL2_SENDER);
|
||||
@ -105,8 +104,7 @@ const MWI_LEVEL2_DISCARD_INACTIVE_PDU =
|
||||
function testLevel2DiscardInactive() {
|
||||
function onLevel2Inactive(event) {
|
||||
let status = event.status;
|
||||
// TODO: bug 905228 - MozVoicemailStatus is not defined.
|
||||
//ok(status instanceof MozVoicemailStatus);
|
||||
ok(status instanceof MozVoicemailStatus);
|
||||
is(status.hasMessages, false);
|
||||
is(status.messageCount, 0);
|
||||
is(status.returnNumber, MWI_LEVEL2_SENDER);
|
||||
@ -150,8 +148,7 @@ function testLevel3DiscardActive() {
|
||||
|
||||
function onLevel3Active(event) {
|
||||
let status = event.status;
|
||||
// TODO: bug 905228 - MozVoicemailStatus is not defined.
|
||||
//ok(status instanceof MozVoicemailStatus);
|
||||
ok(status instanceof MozVoicemailStatus);
|
||||
is(status.hasMessages, true);
|
||||
is(status.messageCount, MWI_LEVEL3_ACTIVE_UDH_MSG_COUNT);
|
||||
is(status.returnNumber, MWI_LEVEL3_SENDER);
|
||||
@ -188,8 +185,7 @@ const MWI_LEVEL3_DISCARD_INACTIVE_PDU =
|
||||
function testLevel3DiscardInactive() {
|
||||
function onLevel3Inactive(event) {
|
||||
let status = event.status;
|
||||
// TODO: bug 905228 - MozVoicemailStatus is not defined.
|
||||
//ok(status instanceof MozVoicemailStatus);
|
||||
ok(status instanceof MozVoicemailStatus);
|
||||
is(status.hasMessages, false);
|
||||
is(status.messageCount, 0);
|
||||
is(status.returnNumber, MWI_LEVEL3_SENDER);
|
||||
|
@ -4,9 +4,7 @@
|
||||
* 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/. */
|
||||
|
||||
[JSImplementation="@mozilla.org/voicemailstatus;1",
|
||||
Pref="dom.voicemail.enabled"]
|
||||
|
||||
[Pref="dom.voicemail.enabled"]
|
||||
interface MozVoicemailStatus
|
||||
{
|
||||
readonly attribute unsigned long serviceId;
|
||||
|
Loading…
Reference in New Issue
Block a user