Bug 1044721 - Part 4: Update IPC protocols and implementation for setSmscAddress API. r=btseng

This commit is contained in:
Samael Wang 2015-04-29 10:42:00 +08:00
Родитель 7316e2e40a
Коммит 28ed3918a4
6 изменённых файлов: 81 добавлений и 0 удалений

Просмотреть файл

@ -79,6 +79,14 @@ struct GetSmscAddressRequest
uint32_t serviceId;
};
struct SetSmscAddressRequest
{
uint32_t serviceId;
nsString number;
uint32_t typeOfNumber;
uint32_t numberPlanIdentification;
};
union IPCSmsRequest
{
SendMessageRequest;
@ -88,6 +96,7 @@ union IPCSmsRequest
MarkMessageReadRequest;
GetSegmentInfoForTextRequest;
GetSmscAddressRequest;
SetSmscAddressRequest;
};
union IPCMobileMessageCursor

Просмотреть файл

@ -94,6 +94,15 @@ struct ReplyGetSmscAddressFail
int32_t error;
};
struct ReplySetSmscAddress
{
};
struct ReplySetSmscAddressFail
{
int32_t error;
};
union MessageReply
{
ReplyMessageSend;
@ -108,6 +117,8 @@ union MessageReply
ReplyGetSegmentInfoForTextFail;
ReplyGetSmscAddress;
ReplyGetSmscAddressFail;
ReplySetSmscAddress;
ReplySetSmscAddressFail;
};
} // namespace mobilemessage

Просмотреть файл

@ -262,6 +262,12 @@ SmsRequestChild::Recv__delete__(const MessageReply& aReply)
case MessageReply::TReplyGetSmscAddressFail:
mReplyRequest->NotifyGetSmscAddressFailed(aReply.get_ReplyGetSmscAddressFail().error());
break;
case MessageReply::TReplySetSmscAddress:
mReplyRequest->NotifySetSmscAddress();
break;
case MessageReply::TReplySetSmscAddressFail:
mReplyRequest->NotifySetSmscAddressFailed(aReply.get_ReplySetSmscAddressFail().error());
break;
default:
MOZ_CRASH("Received invalid response parameters!");
}

Просмотреть файл

@ -181,6 +181,21 @@ SmsIPCService::GetSmscAddress(uint32_t aServiceId,
return SendRequest(GetSmscAddressRequest(aServiceId), aRequest);
}
NS_IMETHODIMP
SmsIPCService::SetSmscAddress(uint32_t aServiceId,
const nsAString& aNumber,
uint32_t aTypeOfNumber,
uint32_t aNumberPlanIdentification,
nsIMobileMessageCallback* aRequest)
{
return SendRequest(SetSmscAddressRequest(aServiceId,
nsString(aNumber),
aTypeOfNumber,
aNumberPlanIdentification),
aRequest);
}
NS_IMETHODIMP
SmsIPCService::Send(uint32_t aServiceId,
const nsAString& aNumber,

Просмотреть файл

@ -406,6 +406,8 @@ SmsParent::RecvPSmsRequestConstructor(PSmsRequestParent* aActor,
return actor->DoRequest(aRequest.get_GetSegmentInfoForTextRequest());
case IPCSmsRequest::TGetSmscAddressRequest:
return actor->DoRequest(aRequest.get_GetSmscAddressRequest());
case IPCSmsRequest::TSetSmscAddressRequest:
return actor->DoRequest(aRequest.get_SetSmscAddressRequest());
default:
MOZ_CRASH("Unknown type!");
}
@ -574,6 +576,29 @@ SmsRequestParent::DoRequest(const GetSmscAddressRequest& aRequest)
return true;
}
bool
SmsRequestParent::DoRequest(const SetSmscAddressRequest& aRequest)
{
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
if (smsService) {
rv = smsService->SetSmscAddress(aRequest.serviceId(),
aRequest.number(),
aRequest.typeOfNumber(),
aRequest.numberPlanIdentification(),
this);
} else {
return NS_SUCCEEDED(NotifySetSmscAddressFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
}
if (NS_FAILED(rv)) {
return NS_SUCCEEDED(NotifySetSmscAddressFailed(nsIMobileMessageCallback::INTERNAL_ERROR));
}
return true;
}
bool
SmsRequestParent::DoRequest(const DeleteMessageRequest& aRequest)
{
@ -746,6 +771,18 @@ SmsRequestParent::NotifyGetSmscAddressFailed(int32_t aError)
return SendReply(ReplyGetSmscAddressFail(aError));
}
NS_IMETHODIMP
SmsRequestParent::NotifySetSmscAddress()
{
return SendReply(ReplySetSmscAddress());
}
NS_IMETHODIMP
SmsRequestParent::NotifySetSmscAddressFailed(int32_t aError)
{
return SendReply(ReplySetSmscAddressFail(aError));
}
/*******************************************************************************
* MobileMessageCursorParent
******************************************************************************/

Просмотреть файл

@ -117,6 +117,9 @@ protected:
bool
DoRequest(const GetSmscAddressRequest& aRequest);
bool
DoRequest(const SetSmscAddressRequest& aRequest);
nsresult
SendReply(const MessageReply& aReply);
};