mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 969218 - Part 6: ipc r=khuey
This commit is contained in:
parent
c1a2d973df
commit
3844dff7fd
@ -12,6 +12,24 @@ 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;
|
||||
@ -37,17 +55,14 @@ parent:
|
||||
__delete__();
|
||||
|
||||
/**
|
||||
* Sent when the child makes an asynchronous request to the parent. It's
|
||||
* currently only for request call enumeration.
|
||||
* Sent when the child makes an asynchronous request to the parent.
|
||||
*/
|
||||
PTelephonyRequest();
|
||||
PTelephonyRequest(IPCTelephonyRequest request);
|
||||
|
||||
RegisterListener();
|
||||
|
||||
UnregisterListener();
|
||||
|
||||
DialCall(uint32_t aClientId, nsString aNumber, bool aIsEmergency);
|
||||
|
||||
HangUpCall(uint32_t aClientId, uint32_t aCallIndex);
|
||||
|
||||
AnswerCall(uint32_t aClientId, uint32_t aCallIndex);
|
||||
|
@ -11,6 +11,22 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace telephony {
|
||||
|
||||
struct EnumerateCallsResponse
|
||||
{
|
||||
// empty.
|
||||
};
|
||||
|
||||
struct DialResponse
|
||||
{
|
||||
// empty.
|
||||
};
|
||||
|
||||
union IPCTelephonyResponse
|
||||
{
|
||||
EnumerateCallsResponse;
|
||||
DialResponse;
|
||||
};
|
||||
|
||||
protocol PTelephonyRequest
|
||||
{
|
||||
manager PTelephony;
|
||||
@ -18,11 +34,14 @@ protocol PTelephonyRequest
|
||||
child:
|
||||
NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData);
|
||||
|
||||
NotifyDialError(nsString aError);
|
||||
|
||||
NotifyDialSuccess();
|
||||
|
||||
/**
|
||||
* Sent when the asynchronous request has completed. It's currently only for
|
||||
* request call enumeration.
|
||||
* Sent when the asynchronous request has completed.
|
||||
*/
|
||||
__delete__();
|
||||
__delete__(IPCTelephonyResponse aResponse);
|
||||
};
|
||||
|
||||
} /* namespace telephony */
|
||||
|
@ -24,7 +24,7 @@ TelephonyChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
PTelephonyRequestChild*
|
||||
TelephonyChild::AllocPTelephonyRequestChild()
|
||||
TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest)
|
||||
{
|
||||
MOZ_CRASH("Caller is supposed to manually construct a request!");
|
||||
}
|
||||
@ -109,24 +109,33 @@ TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId,
|
||||
* TelephonyRequestChild
|
||||
******************************************************************************/
|
||||
|
||||
TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener)
|
||||
: mListener(aListener)
|
||||
TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener,
|
||||
nsITelephonyCallback* aCallback)
|
||||
: mListener(aListener), mCallback(aCallback)
|
||||
{
|
||||
MOZ_ASSERT(aListener);
|
||||
}
|
||||
|
||||
void
|
||||
TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
mListener = nullptr;
|
||||
mCallback = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestChild::Recv__delete__()
|
||||
TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mListener);
|
||||
switch (aResponse.type()) {
|
||||
case IPCTelephonyResponse::TEnumerateCallsResponse:
|
||||
mListener->EnumerateCallStateComplete();
|
||||
break;
|
||||
case IPCTelephonyResponse::TDialResponse:
|
||||
// Do nothing.
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unknown type!");
|
||||
}
|
||||
|
||||
mListener->EnumerateCallStateComplete();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -146,3 +155,21 @@ 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;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ protected:
|
||||
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTelephonyRequestChild*
|
||||
AllocPTelephonyRequestChild() MOZ_OVERRIDE;
|
||||
AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) MOZ_OVERRIDE;
|
||||
@ -61,7 +61,8 @@ private:
|
||||
class TelephonyRequestChild : public PTelephonyRequestChild
|
||||
{
|
||||
public:
|
||||
TelephonyRequestChild(nsITelephonyListener* aListener);
|
||||
TelephonyRequestChild(nsITelephonyListener* aListener,
|
||||
nsITelephonyCallback* aCallback);
|
||||
|
||||
protected:
|
||||
virtual ~TelephonyRequestChild() {}
|
||||
@ -70,14 +71,21 @@ protected:
|
||||
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
Recv__delete__() MOZ_OVERRIDE;
|
||||
Recv__delete__(const IPCTelephonyResponse& aResponse) 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
|
||||
|
@ -117,22 +117,30 @@ TelephonyIPCProvider::UnregisterListener(nsITelephonyListener *aListener)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener)
|
||||
nsresult
|
||||
TelephonyIPCProvider::SendRequest(nsITelephonyListener *aListener,
|
||||
nsITelephonyCallback *aCallback,
|
||||
const IPCTelephonyRequest& aRequest)
|
||||
{
|
||||
// Life time of newly allocated TelephonyRequestChild instance is managed by
|
||||
// IPDL itself.
|
||||
TelephonyRequestChild* actor = new TelephonyRequestChild(aListener);
|
||||
mPTelephonyChild->SendPTelephonyRequestConstructor(actor);
|
||||
TelephonyRequestChild* actor = new TelephonyRequestChild(aListener, aCallback);
|
||||
mPTelephonyChild->SendPTelephonyRequestConstructor(actor, aRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber,
|
||||
bool aIsEmergency)
|
||||
TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener)
|
||||
{
|
||||
mPTelephonyChild->SendDialCall(aClientId, nsString(aNumber), aIsEmergency);
|
||||
return NS_OK;
|
||||
return SendRequest(aListener, nullptr, EnumerateCallsRequest());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber,
|
||||
bool aIsEmergency, nsITelephonyCallback *aCallback)
|
||||
{
|
||||
return SendRequest(nullptr, aCallback,
|
||||
DialRequest(aClientId, nsString(aNumber), aIsEmergency));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
BEGIN_TELEPHONY_NAMESPACE
|
||||
|
||||
struct IPCTelephonyRequest;
|
||||
class PTelephonyChild;
|
||||
|
||||
class TelephonyIPCProvider MOZ_FINAL : public nsITelephonyProvider
|
||||
@ -34,6 +35,10 @@ private:
|
||||
nsTArray<nsCOMPtr<nsITelephonyListener> > mListeners;
|
||||
PTelephonyChild* mPTelephonyChild;
|
||||
uint32_t mDefaultServiceId;
|
||||
|
||||
nsresult SendRequest(nsITelephonyListener *aListener,
|
||||
nsITelephonyCallback *aCallback,
|
||||
const IPCTelephonyRequest& aRequest);
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
@ -33,15 +33,25 @@ TelephonyParent::ActorDestroy(ActorDestroyReason why)
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor)
|
||||
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor,
|
||||
const IPCTelephonyRequest& aRequest)
|
||||
{
|
||||
TelephonyRequestParent* actor = static_cast<TelephonyRequestParent*>(aActor);
|
||||
|
||||
return actor->DoRequest();
|
||||
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;
|
||||
}
|
||||
|
||||
PTelephonyRequestParent*
|
||||
TelephonyParent::AllocPTelephonyRequestParent()
|
||||
TelephonyParent::AllocPTelephonyRequestParent(const IPCTelephonyRequest& aRequest)
|
||||
{
|
||||
TelephonyRequestParent* actor = new TelephonyRequestParent();
|
||||
// Add an extra ref for IPDL. Will be released in
|
||||
@ -91,19 +101,6 @@ 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)
|
||||
@ -372,7 +369,9 @@ TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
* TelephonyRequestParent
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS1(TelephonyRequestParent, nsITelephonyListener)
|
||||
NS_IMPL_ISUPPORTS2(TelephonyRequestParent,
|
||||
nsITelephonyListener,
|
||||
nsITelephonyCallback)
|
||||
|
||||
TelephonyRequestParent::TelephonyRequestParent()
|
||||
: mActorDestroyed(false)
|
||||
@ -389,7 +388,7 @@ TelephonyRequestParent::ActorDestroy(ActorDestroyReason why)
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestParent::DoRequest()
|
||||
TelephonyRequestParent::DoRequest(const EnumerateCallsRequest& aRequest)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
@ -406,6 +405,21 @@ TelephonyRequestParent::DoRequest()
|
||||
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
|
||||
@ -432,7 +446,7 @@ TelephonyRequestParent::EnumerateCallStateComplete()
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return Send__delete__(this) ? NS_OK : NS_ERROR_FAILURE;
|
||||
return Send__delete__(this, EnumerateCallsResponse()) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -482,3 +496,23 @@ 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;
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ protected:
|
||||
ActorDestroy(ActorDestroyReason why);
|
||||
|
||||
virtual bool
|
||||
RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor) MOZ_OVERRIDE;
|
||||
RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor, const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTelephonyRequestParent*
|
||||
AllocPTelephonyRequestParent() MOZ_OVERRIDE;
|
||||
AllocPTelephonyRequestParent(const IPCTelephonyRequest& aRequest) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
DeallocPTelephonyRequestParent(PTelephonyRequestParent* aActor) MOZ_OVERRIDE;
|
||||
@ -46,9 +46,6 @@ 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;
|
||||
|
||||
@ -101,12 +98,14 @@ private:
|
||||
|
||||
class TelephonyRequestParent : public PTelephonyRequestParent
|
||||
, public nsITelephonyListener
|
||||
, public nsITelephonyCallback
|
||||
{
|
||||
friend class TelephonyParent;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYLISTENER
|
||||
NS_DECL_NSITELEPHONYCALLBACK
|
||||
|
||||
protected:
|
||||
TelephonyRequestParent();
|
||||
@ -119,7 +118,10 @@ private:
|
||||
bool mActorDestroyed;
|
||||
|
||||
bool
|
||||
DoRequest();
|
||||
DoRequest(const EnumerateCallsRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const DialRequest& aRequest);
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user