mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847736 - B2G MMS: provide nsIDOMMobileMessageManager.delete(). r=vicamo sr=sicking a=leo+
This commit is contained in:
parent
f14de5b3e1
commit
1eec334cb7
@ -19,7 +19,7 @@ dictionary MmsParameters
|
||||
jsval attachments; // MmsAttachment[]
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(4e3b73f6-8d45-11e2-a590-534c61399fe5)]
|
||||
[scriptable, builtinclass, uuid(1746e0dc-8e18-11e2-a73d-3f802fe818fb)]
|
||||
interface nsIDOMMozMobileMessageManager : nsIDOMEventTarget
|
||||
{
|
||||
nsIDOMMozSmsSegmentInfo getSegmentInfoForText(in DOMString text);
|
||||
@ -35,8 +35,8 @@ interface nsIDOMMozMobileMessageManager : nsIDOMEventTarget
|
||||
[binaryname(GetMessageMoz)]
|
||||
nsIDOMDOMRequest getMessage(in long id);
|
||||
|
||||
// The parameter can be either a message id or a SmsMessage.
|
||||
nsIDOMMozSmsRequest delete(in jsval param);
|
||||
// The parameter can be either a message id or a nsIDOMMoz{Mms,Sms}Message.
|
||||
nsIDOMDOMRequest delete(in jsval param);
|
||||
|
||||
nsIDOMMozSmsRequest getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
|
||||
|
||||
|
@ -35,6 +35,14 @@ MobileMessageCallback::~MobileMessageCallback()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
MobileMessageCallback::NotifySuccess(const jsval& aResult)
|
||||
{
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
return rs ? rs->FireSuccess(mDOMRequest, aResult) : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
|
||||
{
|
||||
@ -53,12 +61,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
|
||||
&wrappedMessage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
|
||||
rs->FireSuccess(mDOMRequest, wrappedMessage);
|
||||
|
||||
return NS_OK;
|
||||
return NotifySuccess(wrappedMessage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -110,13 +113,13 @@ MobileMessageCallback::NotifyGetMessageFailed(int32_t aError)
|
||||
NS_IMETHODIMP
|
||||
MobileMessageCallback::NotifyMessageDeleted(bool aDeleted)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NotifySuccess(aDeleted ? JSVAL_TRUE : JSVAL_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageCallback::NotifyDeleteMessageFailed(int32_t aError)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NotifyError(aError);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
|
||||
nsRefPtr<DOMRequest> mDOMRequest;
|
||||
|
||||
nsresult NotifySuccess(const jsval& aResult);
|
||||
nsresult NotifySuccess(nsISupports *aMessage);
|
||||
nsresult NotifyError(int32_t aError);
|
||||
};
|
||||
|
@ -219,22 +219,23 @@ MobileMessageManager::GetMessageMoz(int32_t aId, nsIDOMDOMRequest** aRequest)
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileMessageManager::Delete(int32_t aId, nsIDOMMozSmsRequest** aRequest)
|
||||
MobileMessageManager::Delete(int32_t aId, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
|
||||
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> forwarder =
|
||||
new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
|
||||
mobileMessageDBService->DeleteMessage(aId, forwarder);
|
||||
req.forget(aRequest);
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
||||
nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
|
||||
nsresult rv = mobileMessageDBService->DeleteMessage(aId, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
request.forget(aRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageManager::Delete(const jsval& aParam, nsIDOMMozSmsRequest** aRequest)
|
||||
MobileMessageManager::Delete(const jsval& aParam, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
if (aParam.isInt32()) {
|
||||
return Delete(aParam.toInt32(), aRequest);
|
||||
@ -248,12 +249,21 @@ MobileMessageManager::Delete(const jsval& aParam, nsIDOMMozSmsRequest** aRequest
|
||||
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
NS_ENSURE_STATE(sc);
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> message =
|
||||
do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, &aParam.toObject()));
|
||||
NS_ENSURE_TRUE(message, NS_ERROR_INVALID_ARG);
|
||||
|
||||
int32_t id;
|
||||
message->GetId(&id);
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMessage =
|
||||
do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, &aParam.toObject()));
|
||||
if (smsMessage) {
|
||||
smsMessage->GetId(&id);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMessage =
|
||||
do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, &aParam.toObject()));
|
||||
if (mmsMessage) {
|
||||
mmsMessage->GetId(&id);
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
return Delete(id, aRequest);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
/**
|
||||
* Internal Delete() method used to delete a message.
|
||||
*/
|
||||
nsresult Delete(int32_t aId, nsIDOMMozSmsRequest** aRequest);
|
||||
nsresult Delete(int32_t aId, nsIDOMDOMRequest** aRequest);
|
||||
|
||||
nsresult DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
|
||||
nsIDOMMozSmsMessage* aMessage);
|
||||
|
Loading…
Reference in New Issue
Block a user