зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077075 - Part 6: Internal architecture (IPC). r=aknow
--HG-- extra : histedit_source : 219eeae82328717287bb56c495ccff452d0cbe39
This commit is contained in:
Родитель
2a7565cc63
Коммит
24229edf18
|
@ -35,12 +35,47 @@ struct HangUpConferenceRequest
|
||||||
uint32_t clientId;
|
uint32_t clientId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AnswerCallRequest
|
||||||
|
{
|
||||||
|
uint32_t clientId;
|
||||||
|
uint32_t callIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HangUpCallRequest
|
||||||
|
{
|
||||||
|
uint32_t clientId;
|
||||||
|
uint32_t callIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RejectCallRequest
|
||||||
|
{
|
||||||
|
uint32_t clientId;
|
||||||
|
uint32_t callIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HoldCallRequest
|
||||||
|
{
|
||||||
|
uint32_t clientId;
|
||||||
|
uint32_t callIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ResumeCallRequest
|
||||||
|
{
|
||||||
|
uint32_t clientId;
|
||||||
|
uint32_t callIndex;
|
||||||
|
};
|
||||||
|
|
||||||
union IPCTelephonyRequest
|
union IPCTelephonyRequest
|
||||||
{
|
{
|
||||||
EnumerateCallsRequest;
|
EnumerateCallsRequest;
|
||||||
DialRequest;
|
DialRequest;
|
||||||
USSDRequest;
|
USSDRequest;
|
||||||
HangUpConferenceRequest;
|
HangUpConferenceRequest;
|
||||||
|
AnswerCallRequest;
|
||||||
|
HangUpCallRequest;
|
||||||
|
RejectCallRequest;
|
||||||
|
HoldCallRequest;
|
||||||
|
ResumeCallRequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
sync protocol PTelephony {
|
sync protocol PTelephony {
|
||||||
|
@ -76,16 +111,6 @@ parent:
|
||||||
|
|
||||||
UnregisterListener();
|
UnregisterListener();
|
||||||
|
|
||||||
HangUpCall(uint32_t aClientId, uint32_t aCallIndex);
|
|
||||||
|
|
||||||
AnswerCall(uint32_t aClientId, uint32_t aCallIndex);
|
|
||||||
|
|
||||||
RejectCall(uint32_t aClientId, uint32_t aCallIndex);
|
|
||||||
|
|
||||||
HoldCall(uint32_t aClientId, uint32_t aCallIndex);
|
|
||||||
|
|
||||||
ResumeCall(uint32_t aClientId, uint32_t aCallIndex);
|
|
||||||
|
|
||||||
ConferenceCall(uint32_t aClientId);
|
ConferenceCall(uint32_t aClientId);
|
||||||
|
|
||||||
SeparateCall(uint32_t aClientId, uint32_t aCallIndex);
|
SeparateCall(uint32_t aClientId, uint32_t aCallIndex);
|
||||||
|
|
|
@ -171,63 +171,63 @@ TelephonyIPCService::Dial(uint32_t aClientId, const nsAString& aNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelephonyIPCService::HangUp(uint32_t aClientId, uint32_t aCallIndex)
|
TelephonyIPCService::AnswerCall(uint32_t aClientId, uint32_t aCallIndex,
|
||||||
|
nsITelephonyCallback *aCallback)
|
||||||
{
|
{
|
||||||
if (!mPTelephonyChild) {
|
if (!mPTelephonyChild) {
|
||||||
NS_WARNING("TelephonyService used after shutdown has begun!");
|
NS_WARNING("TelephonyService used after shutdown has begun!");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPTelephonyChild->SendHangUpCall(aClientId, aCallIndex);
|
return SendRequest(nullptr, aCallback, AnswerCallRequest(aClientId, aCallIndex));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelephonyIPCService::AnswerCall(uint32_t aClientId, uint32_t aCallIndex)
|
TelephonyIPCService::HangUpCall(uint32_t aClientId, uint32_t aCallIndex,
|
||||||
|
nsITelephonyCallback *aCallback)
|
||||||
{
|
{
|
||||||
if (!mPTelephonyChild) {
|
if (!mPTelephonyChild) {
|
||||||
NS_WARNING("TelephonyService used after shutdown has begun!");
|
NS_WARNING("TelephonyService used after shutdown has begun!");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPTelephonyChild->SendAnswerCall(aClientId, aCallIndex);
|
return SendRequest(nullptr, aCallback, HangUpCallRequest(aClientId, aCallIndex));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelephonyIPCService::RejectCall(uint32_t aClientId, uint32_t aCallIndex)
|
TelephonyIPCService::RejectCall(uint32_t aClientId, uint32_t aCallIndex,
|
||||||
|
nsITelephonyCallback *aCallback)
|
||||||
{
|
{
|
||||||
if (!mPTelephonyChild) {
|
if (!mPTelephonyChild) {
|
||||||
NS_WARNING("TelephonyService used after shutdown has begun!");
|
NS_WARNING("TelephonyService used after shutdown has begun!");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPTelephonyChild->SendRejectCall(aClientId, aCallIndex);
|
return SendRequest(nullptr, aCallback, RejectCallRequest(aClientId, aCallIndex));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelephonyIPCService::HoldCall(uint32_t aClientId, uint32_t aCallIndex)
|
TelephonyIPCService::HoldCall(uint32_t aClientId, uint32_t aCallIndex,
|
||||||
|
nsITelephonyCallback *aCallback)
|
||||||
{
|
{
|
||||||
if (!mPTelephonyChild) {
|
if (!mPTelephonyChild) {
|
||||||
NS_WARNING("TelephonyService used after shutdown has begun!");
|
NS_WARNING("TelephonyService used after shutdown has begun!");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPTelephonyChild->SendHoldCall(aClientId, aCallIndex);
|
return SendRequest(nullptr, aCallback, HoldCallRequest(aClientId, aCallIndex));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelephonyIPCService::ResumeCall(uint32_t aClientId, uint32_t aCallIndex)
|
TelephonyIPCService::ResumeCall(uint32_t aClientId, uint32_t aCallIndex,
|
||||||
|
nsITelephonyCallback *aCallback)
|
||||||
{
|
{
|
||||||
if (!mPTelephonyChild) {
|
if (!mPTelephonyChild) {
|
||||||
NS_WARNING("TelephonyService used after shutdown has begun!");
|
NS_WARNING("TelephonyService used after shutdown has begun!");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPTelephonyChild->SendResumeCall(aClientId, aCallIndex);
|
return SendRequest(nullptr, aCallback, ResumeCallRequest(aClientId, aCallIndex));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -37,16 +37,71 @@ TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActo
|
||||||
const IPCTelephonyRequest& aRequest)
|
const IPCTelephonyRequest& aRequest)
|
||||||
{
|
{
|
||||||
TelephonyRequestParent* actor = static_cast<TelephonyRequestParent*>(aActor);
|
TelephonyRequestParent* actor = static_cast<TelephonyRequestParent*>(aActor);
|
||||||
|
nsCOMPtr<nsITelephonyService> service = do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
||||||
|
|
||||||
|
if (!service) {
|
||||||
|
return NS_SUCCEEDED(actor->NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
||||||
|
}
|
||||||
|
|
||||||
switch (aRequest.type()) {
|
switch (aRequest.type()) {
|
||||||
case IPCTelephonyRequest::TEnumerateCallsRequest:
|
case IPCTelephonyRequest::TEnumerateCallsRequest: {
|
||||||
return actor->DoRequest(aRequest.get_EnumerateCallsRequest());
|
nsresult rv = service->EnumerateCalls(actor);
|
||||||
case IPCTelephonyRequest::TDialRequest:
|
if (NS_FAILED(rv)) {
|
||||||
return actor->DoRequest(aRequest.get_DialRequest());
|
return NS_SUCCEEDED(EnumerateCallStateComplete());
|
||||||
case IPCTelephonyRequest::TUSSDRequest:
|
} else {
|
||||||
return actor->DoRequest(aRequest.get_USSDRequest());
|
return true;
|
||||||
case IPCTelephonyRequest::THangUpConferenceRequest:
|
}
|
||||||
return actor->DoRequest(aRequest.get_HangUpConferenceRequest());
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::TDialRequest: {
|
||||||
|
const DialRequest& request = aRequest.get_DialRequest();
|
||||||
|
service->Dial(request.clientId(), request.number(),
|
||||||
|
request.isEmergency(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::TUSSDRequest: {
|
||||||
|
const USSDRequest& request = aRequest.get_USSDRequest();
|
||||||
|
service->SendUSSD(request.clientId(), request.ussd(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::THangUpConferenceRequest: {
|
||||||
|
const HangUpConferenceRequest& request = aRequest.get_HangUpConferenceRequest();
|
||||||
|
service->HangUpConference(request.clientId(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::TAnswerCallRequest: {
|
||||||
|
const AnswerCallRequest& request = aRequest.get_AnswerCallRequest();
|
||||||
|
service->AnswerCall(request.clientId(), request.callIndex(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::THangUpCallRequest: {
|
||||||
|
const HangUpCallRequest& request = aRequest.get_HangUpCallRequest();
|
||||||
|
service->HangUpCall(request.clientId(), request.callIndex(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::TRejectCallRequest: {
|
||||||
|
const RejectCallRequest& request = aRequest.get_RejectCallRequest();
|
||||||
|
service->RejectCall(request.clientId(), request.callIndex(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::THoldCallRequest: {
|
||||||
|
const HoldCallRequest& request = aRequest.get_HoldCallRequest();
|
||||||
|
service->HoldCall(request.clientId(), request.callIndex(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IPCTelephonyRequest::TResumeCallRequest: {
|
||||||
|
const ResumeCallRequest& request = aRequest.get_ResumeCallRequest();
|
||||||
|
service->ResumeCall(request.clientId(), request.callIndex(), actor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
MOZ_CRASH("Unknown type!");
|
MOZ_CRASH("Unknown type!");
|
||||||
}
|
}
|
||||||
|
@ -105,66 +160,6 @@ TelephonyParent::RecvUnregisterListener()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyParent::RecvHangUpCall(const uint32_t& aClientId,
|
|
||||||
const uint32_t& aCallIndex)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(service, true);
|
|
||||||
|
|
||||||
service->HangUp(aClientId, aCallIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyParent::RecvAnswerCall(const uint32_t& aClientId,
|
|
||||||
const uint32_t& aCallIndex)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(service, true);
|
|
||||||
|
|
||||||
service->AnswerCall(aClientId, aCallIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyParent::RecvRejectCall(const uint32_t& aClientId,
|
|
||||||
const uint32_t& aCallIndex)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(service, true);
|
|
||||||
|
|
||||||
service->RejectCall(aClientId, aCallIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyParent::RecvHoldCall(const uint32_t& aClientId,
|
|
||||||
const uint32_t& aCallIndex)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(service, true);
|
|
||||||
|
|
||||||
service->HoldCall(aClientId, aCallIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyParent::RecvResumeCall(const uint32_t& aClientId,
|
|
||||||
const uint32_t& aCallIndex)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(service, true);
|
|
||||||
|
|
||||||
service->ResumeCall(aClientId, aCallIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TelephonyParent::RecvConferenceCall(const uint32_t& aClientId)
|
TelephonyParent::RecvConferenceCall(const uint32_t& aClientId)
|
||||||
{
|
{
|
||||||
|
@ -406,67 +401,6 @@ TelephonyRequestParent::ActorDestroy(ActorDestroyReason why)
|
||||||
mActorDestroyed = true;
|
mActorDestroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyRequestParent::DoRequest(const EnumerateCallsRequest& aRequest)
|
|
||||||
{
|
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
if (service) {
|
|
||||||
rv = service->EnumerateCalls(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return NS_SUCCEEDED(EnumerateCallStateComplete());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyRequestParent::DoRequest(const DialRequest& aRequest)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
if (service) {
|
|
||||||
service->Dial(aRequest.clientId(), aRequest.number(),
|
|
||||||
aRequest.isEmergency(), this);
|
|
||||||
} else {
|
|
||||||
return NS_SUCCEEDED(NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyRequestParent::DoRequest(const USSDRequest& aRequest)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
if (service) {
|
|
||||||
service->SendUSSD(aRequest.clientId(), aRequest.ussd(), this);
|
|
||||||
} else {
|
|
||||||
return NS_SUCCEEDED(NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TelephonyRequestParent::DoRequest(const HangUpConferenceRequest& aRequest)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsITelephonyService> service =
|
|
||||||
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
|
||||||
if (service) {
|
|
||||||
service->HangUpConference(aRequest.clientId(), this);
|
|
||||||
} else {
|
|
||||||
return NS_SUCCEEDED(NotifyError(NS_LITERAL_STRING("InvalidStateError")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse)
|
TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,21 +46,6 @@ protected:
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvUnregisterListener() MOZ_OVERRIDE;
|
RecvUnregisterListener() MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual bool
|
|
||||||
RecvHangUpCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
RecvAnswerCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
RecvRejectCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
RecvHoldCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
RecvResumeCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvConferenceCall(const uint32_t& aClientId) MOZ_OVERRIDE;
|
RecvConferenceCall(const uint32_t& aClientId) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
@ -120,18 +105,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mActorDestroyed;
|
bool mActorDestroyed;
|
||||||
|
|
||||||
bool
|
|
||||||
DoRequest(const EnumerateCallsRequest& aRequest);
|
|
||||||
|
|
||||||
bool
|
|
||||||
DoRequest(const DialRequest& aRequest);
|
|
||||||
|
|
||||||
bool
|
|
||||||
DoRequest(const USSDRequest& aRequest);
|
|
||||||
|
|
||||||
bool
|
|
||||||
DoRequest(const HangUpConferenceRequest& aRequest);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_TELEPHONY_NAMESPACE
|
END_TELEPHONY_NAMESPACE
|
||||||
|
|
Загрузка…
Ссылка в новой задаче