Exemplo n.º 1
0
bool
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor,
                                                  const IPCTelephonyRequest& aRequest)
{
  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;
}
Exemplo n.º 2
0
bool
TelephonyParent::RecvPTelephonyRequestConstructor(PTelephonyRequestParent* aActor,
        const IPCTelephonyRequest& aRequest)
{
    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()) {
    case IPCTelephonyRequest::TEnumerateCallsRequest: {
        nsresult rv = service->EnumerateCalls(actor);
        if (NS_FAILED(rv)) {
            return NS_SUCCEEDED(EnumerateCallStateComplete());
        } else {
            return true;
        }
    }

    case IPCTelephonyRequest::TDialRequest: {
        const DialRequest& request = aRequest.get_DialRequest();
        service->Dial(request.clientId(), request.number(),
                      request.isEmergency(), actor);
        return true;
    }

    case IPCTelephonyRequest::TSendUSSDRequest: {
        const SendUSSDRequest& request = aRequest.get_SendUSSDRequest();
        service->SendUSSD(request.clientId(), request.ussd(), actor);
        return true;
    }

    case IPCTelephonyRequest::TCancelUSSDRequest: {
        const CancelUSSDRequest& request = aRequest.get_CancelUSSDRequest();
        service->CancelUSSD(request.clientId(), 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;
    }

    case IPCTelephonyRequest::TSendTonesRequest: {
        const SendTonesRequest& request = aRequest.get_SendTonesRequest();
        service->SendTones(request.clientId(),
                           request.dtmfChars(),
                           request.pauseDuration(),
                           request.toneDuration(),
                           actor);
        return true;
    }

    default:
        MOZ_CRASH("Unknown type!");
    }

    return false;
}