Backed out 6 changesets (bug 969218) for bustage. DONTBUILD

Backed out changeset 86356906ecf0 (bug 969218)
Backed out changeset 46fa16a18c27 (bug 969218)
Backed out changeset 75219ceb5175 (bug 969218)
Backed out changeset b9f4ba525eec (bug 969218)
Backed out changeset 323c1329614b (bug 969218)
Backed out changeset e0fa4e0eee36 (bug 969218)
This commit is contained in:
Ryan VanderMeulen 2014-02-26 14:27:54 -05:00
parent 3844dff7fd
commit 6e2138ee8a
38 changed files with 542 additions and 721 deletions

View File

@ -6,7 +6,6 @@
#include "Telephony.h"
#include "mozilla/dom/TelephonyBinding.h"
#include "mozilla/dom/Promise.h"
#include "nsIURI.h"
#include "nsPIDOMWindow.h"
@ -62,38 +61,6 @@ public:
}
};
class Telephony::Callback : public nsITelephonyCallback
{
nsRefPtr<Telephony> mTelephony;
nsRefPtr<Promise> mPromise;
uint32_t mServiceId;
nsString mNumber;
public:
NS_DECL_ISUPPORTS
Callback(Telephony* aTelephony, Promise* aPromise, uint32_t aServiceId, const nsAString& aNumber)
: mTelephony(aTelephony), mPromise(aPromise), mServiceId(aServiceId), mNumber(aNumber)
{
MOZ_ASSERT(mTelephony);
}
NS_IMETHODIMP
NotifyDialError(const nsAString& aError) {
mPromise->MaybeReject(aError);
return NS_OK;
}
NS_IMETHODIMP
NotifyDialSuccess() {
nsRefPtr<TelephonyCall> call =
mTelephony->CreateNewDialingCall(mServiceId, mNumber);
mPromise->MaybeResolve(call);
return NS_OK;
}
};
class Telephony::EnumerationAck : public nsRunnable
{
nsRefPtr<Telephony> mTelephony;
@ -113,7 +80,8 @@ public:
};
Telephony::Telephony(nsPIDOMWindow* aOwner)
: nsDOMEventTargetHelper(aOwner), mActiveCall(nullptr), mEnumerated(false)
: nsDOMEventTargetHelper(aOwner),
mActiveCall(nullptr), mEnumerated(false)
{
if (!gTelephonyList) {
gTelephonyList = new TelephonyList();
@ -267,37 +235,40 @@ Telephony::MatchActiveCall(TelephonyCall* aCall)
mActiveCall->ServiceId() == aCall->ServiceId());
}
already_AddRefed<Promise>
already_AddRefed<TelephonyCall>
Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber,
bool aIsEmergency)
bool aIsEmergency, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
if (!window) {
return nullptr;
}
nsRefPtr<Promise> promise = new Promise(window);
if (!IsValidNumber(aNumber) || !IsValidServiceId(aServiceId)) {
promise->MaybeReject(NS_LITERAL_STRING("InvalidAccessError"));
return promise.forget();
aRv.Throw(NS_ERROR_INVALID_ARG);
return nullptr;
}
// We only support one outgoing call at a time.
if (HasDialingCall()) {
promise->MaybeReject(NS_LITERAL_STRING("InvalidStateError"));
return promise.forget();
NS_WARNING("Only permitted to dial one call at a time!");
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
nsCOMPtr<nsITelephonyCallback> callback =
new Callback(this, promise, aServiceId, aNumber);
nsresult rv = mProvider->Dial(aServiceId, aNumber, aIsEmergency, callback);
nsresult rv = mProvider->Dial(aServiceId, aNumber, aIsEmergency);
if (NS_FAILED(rv)) {
promise->MaybeReject(NS_LITERAL_STRING("InvalidStateError"));
return promise.forget();
aRv.Throw(rv);
return nullptr;
}
return promise.forget();
nsRefPtr<TelephonyCall> call = CreateNewDialingCall(aServiceId, aNumber);
// Notify other telephony objects that we just dialed.
for (uint32_t i = 0; i < gTelephonyList->Length(); i++) {
Telephony*& telephony = gTelephonyList->ElementAt(i);
if (telephony != this) {
nsRefPtr<Telephony> kungFuDeathGrip = telephony;
telephony->NoteDialedCallFromOtherInstance(aServiceId, aNumber);
}
}
return call.forget();
}
already_AddRefed<TelephonyCall>
@ -313,6 +284,14 @@ Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber)
return call.forget();
}
void
Telephony::NoteDialedCallFromOtherInstance(uint32_t aServiceId,
const nsAString& aNumber)
{
// We don't need to hang on to this call object, it is held alive by mCalls.
nsRefPtr<TelephonyCall> call = CreateNewDialingCall(aServiceId, aNumber);
}
nsresult
Telephony::NotifyCallsChanged(TelephonyCall* aCall)
{
@ -403,25 +382,26 @@ NS_IMPL_ADDREF_INHERITED(Telephony, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(Telephony, nsDOMEventTargetHelper)
NS_IMPL_ISUPPORTS1(Telephony::Listener, nsITelephonyListener)
NS_IMPL_ISUPPORTS1(Telephony::Callback, nsITelephonyCallback)
// Telephony WebIDL
already_AddRefed<Promise>
Telephony::Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId)
already_AddRefed<TelephonyCall>
Telephony::Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId,
ErrorResult& aRv)
{
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
nsRefPtr<Promise> promise = DialInternal(serviceId, aNumber, false);
return promise.forget();
nsRefPtr<TelephonyCall> call = DialInternal(serviceId, aNumber, false, aRv);
return call.forget();
}
already_AddRefed<Promise>
already_AddRefed<TelephonyCall>
Telephony::DialEmergency(const nsAString& aNumber,
const Optional<uint32_t>& aServiceId)
const Optional<uint32_t>& aServiceId,
ErrorResult& aRv)
{
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
nsRefPtr<Promise> promise = DialInternal(serviceId, aNumber, true);
return promise.forget();
nsRefPtr<TelephonyCall> call = DialInternal(serviceId, aNumber, true, aRv);
return call.forget();
}
void
@ -664,7 +644,7 @@ Telephony::SupplementaryServiceNotification(uint32_t aServiceId,
uint16_t aNotification)
{
nsRefPtr<TelephonyCall> associatedCall;
if (!mCalls.IsEmpty()) {
if (!mCalls.IsEmpty() && aCallIndex != -1) {
associatedCall = GetCall(aServiceId, aCallIndex);
}
@ -695,7 +675,11 @@ Telephony::NotifyError(uint32_t aServiceId,
return NS_ERROR_UNEXPECTED;
}
nsRefPtr<TelephonyCall> callToNotify = GetCall(aServiceId, aCallIndex);
nsRefPtr<TelephonyCall> callToNotify;
callToNotify = (aCallIndex == -1) ? GetOutgoingCall()
: GetCall(aServiceId, aCallIndex);
if (!callToNotify) {
NS_ERROR("Don't call me with a bad call index!");
return NS_ERROR_UNEXPECTED;

View File

@ -8,7 +8,6 @@
#define mozilla_dom_telephony_telephony_h__
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/telephony/TelephonyCommon.h"
#include "nsITelephonyProvider.h"
@ -35,9 +34,6 @@ class Telephony MOZ_FINAL : public nsDOMEventTargetHelper
*/
class Listener;
class Callback;
friend class Callback;
class EnumerationAck;
friend class EnumerationAck;
@ -70,11 +66,13 @@ public:
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
already_AddRefed<Promise>
Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
already_AddRefed<TelephonyCall>
Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId,
ErrorResult& aRv);
already_AddRefed<Promise>
DialEmergency(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
already_AddRefed<TelephonyCall>
DialEmergency(const nsAString& aNumber, const Optional<uint32_t>& aServiceId,
ErrorResult& aRv);
void
StartTone(const nsAString& aDTMFChar, const Optional<uint32_t>& aServiceId,
@ -172,12 +170,17 @@ private:
bool
MatchActiveCall(TelephonyCall* aCall);
already_AddRefed<Promise>
DialInternal(uint32_t aServiceId, const nsAString& aNumber, bool isEmergency);
already_AddRefed<TelephonyCall>
DialInternal(uint32_t aServiceId, const nsAString& aNumber,
bool isEmergency, ErrorResult& aRv);
already_AddRefed<TelephonyCall>
CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber);
void
NoteDialedCallFromOtherInstance(uint32_t aServiceId,
const nsAString& aNumber);
nsresult
NotifyCallsChanged(TelephonyCall* aCall);

View File

@ -400,44 +400,34 @@ TelephonyProvider.prototype = {
});
},
isDialing: false,
dial: function(aClientId, aNumber, aIsEmergency, aTelephonyCallback) {
dial: function(aClientId, aNumber, aIsEmergency) {
if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber);
if (this.isDialing) {
if (DEBUG) debug("Already has a dialing call. Drop.");
aTelephonyCallback.notifyDialError("InvalidStateError");
return;
}
// we don't try to be too clever here, as the phone is probably in the
// locked state. Let's just check if it's a number without normalizing
if (!aIsEmergency) {
aNumber = gPhoneNumberUtils.normalize(aNumber);
}
// Validate the number.
if (!gPhoneNumberUtils.isPlainPhoneNumber(aNumber)) {
// Note: isPlainPhoneNumber also accepts USSD and SS numbers
if (DEBUG) debug("Number '" + aNumber + "' is not viable. Drop.");
let errorMsg = RIL.RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[RIL.CALL_FAIL_UNOBTAINABLE_NUMBER];
aTelephonyCallback.notifyDialError(errorMsg);
Services.tm.currentThread.dispatch(
this.notifyCallError.bind(this, aClientId, -1, errorMsg),
Ci.nsIThread.DISPATCH_NORMAL);
return;
}
this.isDialing = true;
this._getClient(aClientId).sendWorkerMessage("dial", {
number: aNumber,
isDialEmergency: aIsEmergency
}, (function(response) {
this.isDialing = false;
if (response.success) {
aTelephonyCallback.notifyDialSuccess();
} else {
aTelephonyCallback.notifyDialError(response.errorMsg);
}, (function(clientId, response) {
if (!response.success) {
this.notifyCallError(clientId, -1, response.errorMsg);
}
return false;
}).bind(this));
}).bind(this, aClientId));
},
hangUp: function(aClientId, aCallIndex) {

View File

@ -12,24 +12,6 @@ namespace mozilla {
namespace dom {
namespace telephony {
struct EnumerateCallsRequest
{
// empty.
};
struct DialRequest
{
uint32_t clientId;
nsString number;
bool isEmergency;
};
union IPCTelephonyRequest
{
EnumerateCallsRequest;
DialRequest;
};
sync protocol PTelephony {
manager PContent;
manages PTelephonyRequest;
@ -55,14 +37,17 @@ parent:
__delete__();
/**
* Sent when the child makes an asynchronous request to the parent.
* Sent when the child makes an asynchronous request to the parent. It's
* currently only for request call enumeration.
*/
PTelephonyRequest(IPCTelephonyRequest request);
PTelephonyRequest();
RegisterListener();
UnregisterListener();
DialCall(uint32_t aClientId, nsString aNumber, bool aIsEmergency);
HangUpCall(uint32_t aClientId, uint32_t aCallIndex);
AnswerCall(uint32_t aClientId, uint32_t aCallIndex);

View File

@ -11,22 +11,6 @@ namespace mozilla {
namespace dom {
namespace telephony {
struct EnumerateCallsResponse
{
// empty.
};
struct DialResponse
{
// empty.
};
union IPCTelephonyResponse
{
EnumerateCallsResponse;
DialResponse;
};
protocol PTelephonyRequest
{
manager PTelephony;
@ -34,14 +18,11 @@ protocol PTelephonyRequest
child:
NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData);
NotifyDialError(nsString aError);
NotifyDialSuccess();
/**
* Sent when the asynchronous request has completed.
* Sent when the asynchronous request has completed. It's currently only for
* request call enumeration.
*/
__delete__(IPCTelephonyResponse aResponse);
__delete__();
};
} /* namespace telephony */

View File

@ -24,7 +24,7 @@ TelephonyChild::ActorDestroy(ActorDestroyReason aWhy)
}
PTelephonyRequestChild*
TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest)
TelephonyChild::AllocPTelephonyRequestChild()
{
MOZ_CRASH("Caller is supposed to manually construct a request!");
}
@ -109,33 +109,24 @@ TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId,
* TelephonyRequestChild
******************************************************************************/
TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener,
nsITelephonyCallback* aCallback)
: mListener(aListener), mCallback(aCallback)
TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener)
: mListener(aListener)
{
MOZ_ASSERT(aListener);
}
void
TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy)
{
mListener = nullptr;
mCallback = nullptr;
}
bool
TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
TelephonyRequestChild::Recv__delete__()
{
switch (aResponse.type()) {
case IPCTelephonyResponse::TEnumerateCallsResponse:
mListener->EnumerateCallStateComplete();
break;
case IPCTelephonyResponse::TDialResponse:
// Do nothing.
break;
default:
MOZ_CRASH("Unknown type!");
}
MOZ_ASSERT(mListener);
mListener->EnumerateCallStateComplete();
return true;
}
@ -155,21 +146,3 @@ TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
aData.isConference());
return true;
}
bool
TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
{
MOZ_ASSERT(mCallback);
mCallback->NotifyDialError(aError);
return true;
}
bool
TelephonyRequestChild::RecvNotifyDialSuccess()
{
MOZ_ASSERT(mCallback);
mCallback->NotifyDialSuccess();
return true;
}

View File

@ -25,7 +25,7 @@ protected:
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
virtual PTelephonyRequestChild*
AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
AllocPTelephonyRequestChild() MOZ_OVERRIDE;
virtual bool
DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) MOZ_OVERRIDE;
@ -61,8 +61,7 @@ private:
class TelephonyRequestChild : public PTelephonyRequestChild
{
public:
TelephonyRequestChild(nsITelephonyListener* aListener,
nsITelephonyCallback* aCallback);
TelephonyRequestChild(nsITelephonyListener* aListener);
protected:
virtual ~TelephonyRequestChild() {}
@ -71,21 +70,14 @@ protected:
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
virtual bool
Recv__delete__(const IPCTelephonyResponse& aResponse) MOZ_OVERRIDE;
Recv__delete__() MOZ_OVERRIDE;
virtual bool
RecvNotifyEnumerateCallState(const uint32_t& aClientId,
const IPCCallStateData& aData) MOZ_OVERRIDE;
virtual bool
RecvNotifyDialError(const nsString& aError) MOZ_OVERRIDE;
virtual bool
RecvNotifyDialSuccess() MOZ_OVERRIDE;
private:
nsCOMPtr<nsITelephonyListener> mListener;
nsCOMPtr<nsITelephonyCallback> mCallback;
};
END_TELEPHONY_NAMESPACE

View File

@ -117,30 +117,22 @@ TelephonyIPCProvider::UnregisterListener(nsITelephonyListener *aListener)
return NS_OK;
}
nsresult
TelephonyIPCProvider::SendRequest(nsITelephonyListener *aListener,
nsITelephonyCallback *aCallback,
const IPCTelephonyRequest& aRequest)
NS_IMETHODIMP
TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener)
{
// Life time of newly allocated TelephonyRequestChild instance is managed by
// IPDL itself.
TelephonyRequestChild* actor = new TelephonyRequestChild(aListener, aCallback);
mPTelephonyChild->SendPTelephonyRequestConstructor(actor, aRequest);
TelephonyRequestChild* actor = new TelephonyRequestChild(aListener);
mPTelephonyChild->SendPTelephonyRequestConstructor(actor);
return NS_OK;
}
NS_IMETHODIMP
TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener)
{
return SendRequest(aListener, nullptr, EnumerateCallsRequest());
}
NS_IMETHODIMP
TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber,
bool aIsEmergency, nsITelephonyCallback *aCallback)
bool aIsEmergency)
{
return SendRequest(nullptr, aCallback,
DialRequest(aClientId, nsString(aNumber), aIsEmergency));
mPTelephonyChild->SendDialCall(aClientId, nsString(aNumber), aIsEmergency);
return NS_OK;
}
NS_IMETHODIMP

View File

@ -13,7 +13,6 @@
BEGIN_TELEPHONY_NAMESPACE
struct IPCTelephonyRequest;
class PTelephonyChild;
class TelephonyIPCProvider MOZ_FINAL : public nsITelephonyProvider
@ -35,10 +34,6 @@ private:
nsTArray<nsCOMPtr<nsITelephonyListener> > mListeners;
PTelephonyChild* mPTelephonyChild;
uint32_t mDefaultServiceId;
nsresult SendRequest(nsITelephonyListener *aListener,
nsITelephonyCallback *aCallback,
const IPCTelephonyRequest& aRequest);
};
END_TELEPHONY_NAMESPACE

View File

@ -33,25 +33,15 @@ TelephonyParent::ActorDestroy(ActorDestroyReason why)
}
bool
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor,
const IPCTelephonyRequest& aRequest)
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor)
{
TelephonyRequestParent* actor = static_cast<TelephonyRequestParent*>(aActor);
switch (aRequest.type()) {
case IPCTelephonyRequest::TEnumerateCallsRequest:
return actor->DoRequest(aRequest.get_EnumerateCallsRequest());
case IPCTelephonyRequest::TDialRequest:
return actor->DoRequest(aRequest.get_DialRequest());
default:
MOZ_CRASH("Unknown type!");
}
return false;
return actor->DoRequest();
}
PTelephonyRequestParent*
TelephonyParent::AllocPTelephonyRequestParent(const IPCTelephonyRequest& aRequest)
TelephonyParent::AllocPTelephonyRequestParent()
{
TelephonyRequestParent* actor = new TelephonyRequestParent();
// Add an extra ref for IPDL. Will be released in
@ -101,6 +91,19 @@ TelephonyParent::RecvUnregisterListener()
return true;
}
bool
TelephonyParent::RecvDialCall(const uint32_t& aClientId,
const nsString& aNumber,
const bool& aIsEmergency)
{
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
NS_ENSURE_TRUE(provider, true);
provider->Dial(aClientId, aNumber, aIsEmergency);
return true;
}
bool
TelephonyParent::RecvHangUpCall(const uint32_t& aClientId,
const uint32_t& aCallIndex)
@ -369,9 +372,7 @@ TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId,
* TelephonyRequestParent
******************************************************************************/
NS_IMPL_ISUPPORTS2(TelephonyRequestParent,
nsITelephonyListener,
nsITelephonyCallback)
NS_IMPL_ISUPPORTS1(TelephonyRequestParent, nsITelephonyListener)
TelephonyRequestParent::TelephonyRequestParent()
: mActorDestroyed(false)
@ -388,7 +389,7 @@ TelephonyRequestParent::ActorDestroy(ActorDestroyReason why)
}
bool
TelephonyRequestParent::DoRequest(const EnumerateCallsRequest& aRequest)
TelephonyRequestParent::DoRequest()
{
nsresult rv = NS_ERROR_FAILURE;
@ -405,21 +406,6 @@ TelephonyRequestParent::DoRequest(const EnumerateCallsRequest& aRequest)
return true;
}
bool
TelephonyRequestParent::DoRequest(const DialRequest& aRequest)
{
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
if (provider) {
provider->Dial(aRequest.clientId(), aRequest.number(),
aRequest.isEmergency(), this);
} else {
return NS_SUCCEEDED(NotifyDialError(NS_LITERAL_STRING("InvalidStateError")));
}
return true;
}
// nsITelephonyListener
NS_IMETHODIMP
@ -446,7 +432,7 @@ TelephonyRequestParent::EnumerateCallStateComplete()
{
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
return Send__delete__(this, EnumerateCallsResponse()) ? NS_OK : NS_ERROR_FAILURE;
return Send__delete__(this) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -496,23 +482,3 @@ TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId,
{
MOZ_CRASH("Not a TelephonyParent!");
}
// nsITelephonyCallback
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialError(const nsAString& aError)
{
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
return (SendNotifyDialError(nsString(aError)) &&
Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialSuccess()
{
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
return (SendNotifyDialSuccess() &&
Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
}

View File

@ -29,10 +29,10 @@ protected:
ActorDestroy(ActorDestroyReason why);
virtual bool
RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor, const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor) MOZ_OVERRIDE;
virtual PTelephonyRequestParent*
AllocPTelephonyRequestParent(const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
AllocPTelephonyRequestParent() MOZ_OVERRIDE;
virtual bool
DeallocPTelephonyRequestParent(PTelephonyRequestParent* aActor) MOZ_OVERRIDE;
@ -46,6 +46,9 @@ protected:
virtual bool
RecvUnregisterListener() MOZ_OVERRIDE;
virtual bool
RecvDialCall(const uint32_t& aClientId, const nsString& aNumber, const bool& aIsEmergency) MOZ_OVERRIDE;
virtual bool
RecvHangUpCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
@ -98,14 +101,12 @@ private:
class TelephonyRequestParent : public PTelephonyRequestParent
, public nsITelephonyListener
, public nsITelephonyCallback
{
friend class TelephonyParent;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSITELEPHONYLISTENER
NS_DECL_NSITELEPHONYCALLBACK
protected:
TelephonyRequestParent();
@ -118,10 +119,7 @@ private:
bool mActorDestroyed;
bool
DoRequest(const EnumerateCallsRequest& aRequest);
bool
DoRequest(const DialRequest& aRequest);
DoRequest();
};
END_TELEPHONY_NAMESPACE

View File

@ -132,22 +132,6 @@ interface nsITelephonyListener : nsISupports
in AString message);
};
[scriptable, uuid(c095aa82-aacb-4e53-a787-56a89c3f638e)]
interface nsITelephonyCallback : nsISupports
{
/**
* Called when a dial request fails.
* @param error
* Error from RIL.
*/
void notifyDialError(in AString error);
/**
* Called when a dial request succeeds.
*/
void notifyDialSuccess();
};
%{C++
#define TELEPHONY_PROVIDER_CID \
{ 0x9cf8aa52, 0x7c1c, 0x4cde, { 0x97, 0x4e, 0xed, 0x2a, 0xa0, 0xe7, 0x35, 0xfa } }
@ -159,7 +143,7 @@ interface nsITelephonyCallback : nsISupports
* XPCOM component (in the content process) that provides the telephony
* information.
*/
[scriptable, uuid(b16ca98f-994f-4ae1-8c2d-e7b18e08d1f3)]
[scriptable, uuid(4ff3ecb7-b024-4752-9dd6-c3623c6e6b8a)]
interface nsITelephonyProvider : nsISupports
{
const unsigned short CALL_STATE_UNKNOWN = 0;
@ -197,7 +181,7 @@ interface nsITelephonyProvider : nsISupports
* Functionality for making and managing phone calls.
*/
void dial(in unsigned long clientId, in DOMString number,
in boolean isEmergency, in nsITelephonyCallback callback);
in boolean isEmergency);
void hangUp(in unsigned long clientId, in unsigned long callIndex);
void startTone(in unsigned long clientId, in DOMString dtmfChar);

View File

@ -49,8 +49,8 @@ function dial(number) {
log("Make an outgoing call: " + number);
let deferred = Promise.defer();
let call = telephony.dial(number);
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
@ -61,7 +61,6 @@ function dial(number) {
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -106,8 +106,8 @@ function dial(number) {
log("Make an outgoing call: " + number);
let deferred = Promise.defer();
let call = telephony.dial(number);
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
@ -118,7 +118,6 @@ function dial(number) {
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -9,13 +9,12 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
answer();
};
});
}
function answer() {

View File

@ -73,8 +73,8 @@ function dial(number, serviceId) {
log("Make an outgoing call: " + number + ", serviceId: " + serviceId);
let deferred = Promise.defer();
let call = telephony.dial(number, serviceId);
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
@ -86,7 +86,6 @@ function dial(number, serviceId) {
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -11,8 +11,7 @@ let calls;
function dial() {
log("Make an emergency call.");
telephony.dialEmergency(number).then(call => {
outgoing = call;
outgoing = telephony.dialEmergency(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -26,7 +25,6 @@ function dial() {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
is(outgoing.emergency, true);
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
@ -35,7 +33,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -5,23 +5,37 @@ MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let number = "not a valid emergency number";
let outgoing;
let calls;
function dial() {
log("Make an outgoing call to an invalid number.");
telephony.dialEmergency(number).then(null, cause => {
log("Received promise 'reject'");
outgoing = telephony.dialEmergency(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "BadNumberError");
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "BadNumberError");
is(telephony.active, null);
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
is(result[0], "OK");
cleanUp();
});
});
};
}
function cleanUp() {

View File

@ -26,8 +26,7 @@ function createGoldenCallListResult0(number, state) {
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -49,7 +48,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -12,8 +12,7 @@ let gotOriginalConnected = false;
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -34,7 +33,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -12,8 +12,7 @@ let gotOriginalConnected = false;
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -34,7 +33,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -96,8 +96,7 @@ function holdCall() {
function dial() {
log("Making an outgoing call (while have one call already held).");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -119,7 +118,6 @@ function dial() {
answerOutgoing();
});
};
});
}
// Have the outgoing call answered

View File

@ -109,8 +109,7 @@ function holdCall(){
function dial() {
log("Making an outgoing call (while have one call already held).");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -133,7 +132,6 @@ function dial() {
answerOutgoing();
});
};
});
}
// Have the outgoing call answered

View File

@ -11,8 +11,7 @@ let calls;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -34,7 +33,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -10,8 +10,7 @@ let outNumber = "5555551111";
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -33,7 +32,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -30,7 +30,8 @@ function dial(number) {
log("Make an outgoing call.");
let deferred = Promise.defer();
telephony.dial(number).then(call => {
let call = telephony.dial(number);
ok(call);
is(call.number, number);
is(call.state, "dialing");
@ -42,7 +43,6 @@ function dial(number) {
is(call.state, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -7,15 +7,10 @@ MARIONETTE_HEAD_JS = 'head.js';
let number = "****5555552368****";
let outgoing;
function dial() {
log("Make an outgoing call to an invalid number.");
// Note: The number is valid from the view of phone and the call could be
// dialed out successfully. However, it will later receive the BadNumberError
// from network side.
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -36,7 +31,6 @@ function dial() {
cleanUp();
});
};
});
}
function cleanUp() {

View File

@ -10,8 +10,7 @@ let outgoing;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -32,7 +31,6 @@ function dial() {
busy();
});
};
});
}
function busy() {

View File

@ -46,8 +46,7 @@ function setRadioEnabled(enabled, callback) {
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -68,7 +67,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -11,8 +11,7 @@ let calls;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -31,7 +30,6 @@ function dial() {
hangUp();
});
};
});
}
function hangUp() {

View File

@ -11,8 +11,7 @@ let calls;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -33,7 +32,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -11,8 +11,7 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(number);
ok(outgoingCall);
is(outgoingCall.number, number);
is(outgoingCall.state, "dialing");
@ -33,7 +32,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -10,8 +10,7 @@ let outNumber = "5555551111";
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -36,7 +35,6 @@ function dial() {
});
}
};
});
}
function answer() {

View File

@ -5,6 +5,7 @@ MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let connection;
let outgoing;
function receivedPending(received, pending, nextAction) {
let index = pending.indexOf(received);
@ -49,13 +50,21 @@ function dial(number) {
is(telephony.calls.length, 0);
log("Make an outgoing call.");
outgoing = telephony.dial(number);
telephony.dial(number).then(null, cause => {
log("Received promise 'reject'");
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "RadioNotAvailable");
is(telephony.active, outgoing);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "RadioNotAvailable");
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
@ -63,7 +72,7 @@ function dial(number) {
setRadioEnabled(true, cleanUp);
});
});
};
}
function cleanUp() {

View File

@ -10,8 +10,7 @@ let outgoing;
function dial() {
log("Make an outgoing call.");
telephony.dial(number).then(call => {
outgoing = call;
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
@ -32,7 +31,6 @@ function dial() {
reject();
});
};
});
}
function reject() {

View File

@ -9,8 +9,7 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -32,7 +31,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -14,8 +14,7 @@ let gotConnected = false;
function dial() {
log("Make an outgoing call.");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
@ -36,7 +35,6 @@ function dial() {
answer();
});
};
});
}
function answer() {

View File

@ -16,11 +16,11 @@ interface Telephony : EventTarget {
* |navigator.mozMobileConnections.length|.
*/
// Promise<TelephonyCall>
Promise dial(DOMString number, optional unsigned long serviceId);
[Throws]
TelephonyCall dial(DOMString number, optional unsigned long serviceId);
// Promise<TelephonyCall>
Promise dialEmergency(DOMString number, optional unsigned long serviceId);
[Throws]
TelephonyCall dialEmergency(DOMString number, optional unsigned long serviceId);
[Throws]
void startTone(DOMString tone, optional unsigned long serviceId);